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>
40 #ifdef HAVE_LCD_BITMAP
41 int compute_nb_lines(int w
, struct font
* font
)
46 if(logfindex
== 0 && !logfwrap
)
58 if(logfbuffer
[i
] == '\0')
65 /* does character fit on this line ? */
66 delta_x
= font_get_width(font
, logfbuffer
[i
]);
68 if(cur_x
+ delta_x
> w
)
79 if(i
>= MAX_LOGF_SIZE
)
81 } while(i
!= logfindex
);
86 bool logfdisplay(void)
91 int cur_x
, cur_y
, delta_y
, delta_x
;
93 int user_index
;/* user_index will be number of the first line to display (warning: line!=logf entry) */
96 fontnr
= lcd_getfont();
97 font
= font_get(fontnr
);
99 /* get the horizontal size of each line */
100 font_getstringsize("A", NULL
, &delta_y
, fontnr
);
105 /* start at the end of the log */
106 user_index
= compute_nb_lines(w
, font
) - h
/delta_y
-1; /* if negative, will be set 0 to zero later */
123 /* nothing to print ? */
124 if(logfindex
== 0 && !logfwrap
)
128 if(logfbuffer
[i
] == '\0')
130 /* should be display a newline ? */
131 if(index
>= user_index
)
138 /* does character fit on this line ? */
139 delta_x
= font_get_width(font
, logfbuffer
[i
]);
141 if(cur_x
+ delta_x
> w
)
143 /* should be display a newline ? */
144 if(index
>= user_index
)
150 /* should we print character ? */
151 if(index
>= user_index
)
153 buf
[0] = logfbuffer
[i
];
154 lcd_putsxy(cur_x
, cur_y
, buf
);
161 /* did we fill the screen ? */
166 if(i
>= MAX_LOGF_SIZE
)
168 } while(i
!= logfindex
);
173 action
= get_action(CONTEXT_STD
, HZ
);
176 case ACTION_STD_NEXT
:
177 case ACTION_STD_NEXTREPEAT
:
180 case ACTION_STD_PREV
:
181 case ACTION_STD_PREVREPEAT
:
187 #ifdef HAVE_TOUCHSCREEN
188 case ACTION_TOUCHSCREEN
:
193 action
= action_get_touchscreen_press(&x
, &y
);
195 if(action
& BUTTON_REL
)
200 user_index
+= (prev_y
- y
) / delta_y
;
209 } while(action
!= ACTION_STD_CANCEL
);
213 #else /* HAVE_LCD_BITMAP */
214 bool logfdisplay(void)
217 /* TODO: implement a browser for charcell bitmaps */
220 #endif /* HAVE_LCD_BITMAP */
222 /* Store the logf log to logf.txt in the .rockbox directory. The order of the
223 * entries will be "reversed" so that the most recently logged entry is on the
229 splashf(HZ
, "Log File Dumped");
231 /* nothing to print ? */
232 if(logfindex
== 0 && !logfwrap
)
233 /* nothing is logged just yet */
236 fd
= open(ROCKBOX_DIR
"/logf.txt", O_CREAT
|O_WRONLY
|O_TRUNC
);
246 if(logfbuffer
[i
]=='\0')
249 fdprintf(fd
, "%c", logfbuffer
[i
]);
252 if(i
>= MAX_LOGF_SIZE
)
254 } while(i
!= logfindex
);
261 #endif /* ROCKBOX_HAS_LOGF */