int printf(const char *format, ...) { static char printfbuf[256]; int len; unsigned char *ptr; va_list ap; va_start(ap, format); ptr = printfbuf; len = vsnprintf(ptr, sizeof(printfbuf), format, ap); va_end(ap); lcd_puts(0, line++, ptr); if (verbose) lcd_update(); if(line >= LCD_HEIGHT/SYSFONT_HEIGHT) line = 0; #ifdef HAVE_REMOTE_LCD lcd_remote_puts(0, remote_line++, ptr); if (verbose) lcd_remote_update(); if(remote_line >= LCD_REMOTE_HEIGHT/SYSFONT_HEIGHT) remote_line = 0; #endif return len; }
static void displayremote(void) { /* TODO: we should have a debug option that enables/disables this! */ int w, h; int lines; int columns; int i; int index; lcd_remote_getstringsize("A", &w, &h); lines = LCD_REMOTE_HEIGHT/h; columns = LCD_REMOTE_WIDTH/w; lcd_remote_setmargins(0, 0); lcd_remote_clear_display(); index = logfindex; for(i = lines-1; i>=0; i--) { unsigned char buffer[columns+1]; if(--index < 0) { if(logfwrap) index = MAX_LOGF_LINES-1; else break; /* done */ } memcpy(buffer, logfbuffer[index], columns); buffer[columns]=0; lcd_remote_puts(0, i, buffer); } lcd_remote_update(); }