1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 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 #ifdef ROCKBOX_HAS_LOGF
26 #include <timefuncs.h>
38 #ifdef HAVE_LCD_BITMAP
39 bool logfdisplay(void)
47 bool lcd
= false; /* fixed atm */
48 int index
, user_index
=0;
50 lcd_getstringsize("A", &w
, &h
);
52 #ifdef HAVE_REMOTE_LCD
59 #ifdef HAVE_REMOTE_LCD
66 if (columns
> MAX_LOGF_ENTRY
+1)
67 columns
= MAX_LOGF_ENTRY
+1;
75 index
= logfindex
+ user_index
;
76 for(i
= lines
-1; i
>=0; i
--) {
77 unsigned char buffer
[columns
+ 1];
81 index
= MAX_LOGF_LINES
-1;
86 memcpy(buffer
, logfbuffer
[index
], columns
);
87 if (logfbuffer
[index
][MAX_LOGF_ENTRY
] == LOGF_TERMINATE_CONTINUE_LINE
)
88 buffer
[columns
-1] = '>';
89 else if (logfbuffer
[index
][MAX_LOGF_ENTRY
] == LOGF_TERMINATE_MULTI_LINE
)
90 buffer
[columns
-1] = '\0';
91 buffer
[columns
] = '\0';
93 lcd_puts(0, i
, buffer
);
97 action
= get_action(CONTEXT_STD
, HZ
);
98 if(action
== ACTION_STD_NEXT
)
100 else if(action
== ACTION_STD_PREV
)
102 else if(action
== ACTION_STD_OK
)
104 #ifdef HAVE_TOUCHSCREEN
105 else if(action
== ACTION_TOUCHSCREEN
)
110 action
= action_get_touchscreen_press(&x
, &y
);
112 if(action
& BUTTON_REL
)
117 user_index
+= (prev_y
- y
) / h
;
123 } while(action
!= ACTION_STD_CANCEL
);
127 #else /* HAVE_LCD_BITMAP */
128 bool logfdisplay(void)
131 /* TODO: implement a browser for charcell bitmaps */
134 #endif /* HAVE_LCD_BITMAP */
136 /* Store the logf log to logf.txt in the .rockbox directory. The order of the
137 * entries will be "reversed" so that the most recently logged entry is on the
143 if(!logfindex
&& !logfwrap
)
144 /* nothing is logged just yet */
147 fd
= open(ROCKBOX_DIR
"/logf.txt", O_CREAT
|O_WRONLY
|O_TRUNC
);
149 unsigned char buffer
[MAX_LOGF_ONE_LINE_SIZE
+1];
151 int index
= logfindex
-1;
152 int stop
= logfindex
;
154 bool dumpwrap
= false;
157 while(!dumpwrap
|| (index
>= stop
)) {
161 index
= MAX_LOGF_LINES
-1;
169 if (logfbuffer
[index
][MAX_LOGF_ENTRY
] == LOGF_TERMINATE_MULTI_LINE
)
177 index
= MAX_LOGF_LINES
-1;
183 } while(logfbuffer
[index
][MAX_LOGF_ENTRY
] == LOGF_TERMINATE_CONTINUE_LINE
);
185 if (index
>= MAX_LOGF_LINES
)
193 memcpy(ptr
, logfbuffer
[tindex
], MAX_LOGF_ENTRY
);
194 ptr
+= MAX_LOGF_ENTRY
;
195 if (tindex
>= MAX_LOGF_LINES
)
197 } while(logfbuffer
[tindex
][MAX_LOGF_ENTRY
] == LOGF_TERMINATE_CONTINUE_LINE
);
200 fdprintf(fd
, "%s\n", buffer
);
209 #endif /* ROCKBOX_HAS_LOGF */