1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Daniel Stenberg
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
21 * logf() logs MAX_LOGF_ENTRY (21) bytes per entry in a circular buffer. Each
22 * logged string is space- padded for easier and faster output on screen. Just
23 * output MAX_LOGF_ENTRY characters on each line. MAX_LOGF_ENTRY bytes fit
24 * nicely on the iRiver remote LCD (128 pixels with an 8x6 pixels font).
32 #include "lcd-remote.h"
36 /* Only provide all this if asked to */
37 #ifdef ROCKBOX_HAS_LOGF
39 unsigned char logfbuffer
[MAX_LOGF_LINES
][MAX_LOGF_ENTRY
];
43 #ifdef HAVE_REMOTE_LCD
44 static void displayremote(void)
46 /* TODO: we should have a debug option that enables/disables this! */
53 lcd_remote_getstringsize("A", &w
, &h
);
54 lines
= LCD_REMOTE_HEIGHT
/h
;
55 columns
= LCD_REMOTE_WIDTH
/w
;
56 lcd_remote_setmargins(0, 0);
57 lcd_remote_clear_display();
60 for(i
= lines
-1; i
>=0; i
--) {
61 unsigned char buffer
[columns
+1];
65 index
= MAX_LOGF_LINES
-1;
70 memcpy(buffer
, logfbuffer
[index
], columns
);
72 lcd_remote_puts(0, i
, buffer
);
77 #define displayremote()
80 void logf(const char *format
, ...)
87 if(logfindex
>= MAX_LOGF_LINES
) {
92 ptr
= logfbuffer
[logfindex
];
93 len
= vsnprintf(ptr
, MAX_LOGF_ENTRY
, format
, ap
);
99 if(len
< MAX_LOGF_ENTRY
)
100 /* pad with spaces up to the MAX_LOGF_ENTRY byte border */
101 memset(ptr
+len
, ' ', MAX_LOGF_ENTRY
-len
);
103 logfindex
++; /* leave it where we write the next time */