1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Daniel Stenberg
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
23 * logf() logs MAX_LOGF_ENTRY (21) bytes per entry in a circular buffer. Each
24 * logged string is space- padded for easier and faster output on screen. Just
25 * output MAX_LOGF_ENTRY characters on each line. MAX_LOGF_ENTRY bytes fit
26 * nicely on the iRiver remote LCD (128 pixels with an 8x6 pixels font).
33 #include "lcd-remote.h"
39 #include "usbstack/usb_serial.h"
42 /* Only provide all this if asked to */
43 #ifdef ROCKBOX_HAS_LOGF
46 unsigned char logfbuffer
[MAX_LOGF_LINES
][MAX_LOGF_ENTRY
];
51 #ifdef HAVE_REMOTE_LCD
52 static void displayremote(void)
54 /* TODO: we should have a debug option that enables/disables this! */
61 lcd_remote_getstringsize("A", &w
, &h
);
62 lines
= LCD_REMOTE_HEIGHT
/h
;
63 columns
= LCD_REMOTE_WIDTH
/w
;
64 lcd_remote_clear_display();
67 for(i
= lines
-1; i
>=0; i
--) {
68 unsigned char buffer
[columns
+1];
72 index
= MAX_LOGF_LINES
-1;
77 memcpy(buffer
, logfbuffer
[index
], columns
);
79 lcd_remote_puts(0, i
, buffer
);
84 #define displayremote()
88 void _logf(const char *format
, ...)
94 vsnprintf(buf
, sizeof buf
, format
, ap
);
95 printf("DEBUG: %s\n", buf
);
98 void _logf(const char *format
, ...)
103 va_start(ap
, format
);
105 if(logfindex
>= MAX_LOGF_LINES
) {
110 ptr
= logfbuffer
[logfindex
];
111 len
= vsnprintf(ptr
, MAX_LOGF_ENTRY
, format
, ap
);
117 usb_serial_send(ptr
,len
);
118 usb_serial_send("\r\n",2);
122 if(len
< MAX_LOGF_ENTRY
)
123 /* pad with spaces up to the MAX_LOGF_ENTRY byte border */
124 memset(ptr
+len
, ' ', MAX_LOGF_ENTRY
-len
);
126 logfindex
++; /* leave it where we write the next time */