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>
39 #ifdef HAVE_LCD_BITMAP
40 int compute_nb_lines(int w
, struct font
* font
)
45 if(logfindex
== 0 && !logfwrap
)
57 if(logfbuffer
[i
] == '\0')
64 /* does character fit on this line ? */
65 delta_x
= font_get_width(font
, logfbuffer
[i
]);
67 if(cur_x
+ delta_x
> w
)
78 if(i
>= MAX_LOGF_SIZE
)
80 } while(i
!= logfindex
);
85 bool logfdisplay(void)
90 int cur_x
, cur_y
, delta_y
, delta_x
;
92 int user_index
;/* user_index will be number of the first line to display (warning: line!=logf entry) */
95 fontnr
= lcd_getfont();
96 font
= font_get(fontnr
);
98 /* get the horizontal size of each line */
99 font_getstringsize("A", NULL
, &delta_y
, fontnr
);
104 /* start at the end of the log */
105 user_index
= compute_nb_lines(w
, font
) - h
/delta_y
-1; /* if negative, will be set 0 to zero later */
122 /* nothing to print ? */
123 if(logfindex
== 0 && !logfwrap
)
127 if(logfbuffer
[i
] == '\0')
129 /* should be display a newline ? */
130 if(index
>= user_index
)
137 /* does character fit on this line ? */
138 delta_x
= font_get_width(font
, logfbuffer
[i
]);
140 if(cur_x
+ delta_x
> w
)
142 /* should be display a newline ? */
143 if(index
>= user_index
)
149 /* should we print character ? */
150 if(index
>= user_index
)
152 buf
[0] = logfbuffer
[i
];
153 lcd_putsxy(cur_x
, cur_y
, buf
);
160 /* did we fill the screen ? */
165 if(i
>= MAX_LOGF_SIZE
)
167 } while(i
!= logfindex
);
172 action
= get_action(CONTEXT_STD
, HZ
);
175 case ACTION_STD_NEXT
:
176 case ACTION_STD_NEXTREPEAT
:
179 case ACTION_STD_PREV
:
180 case ACTION_STD_PREVREPEAT
:
186 #ifdef HAVE_TOUCHSCREEN
187 case ACTION_TOUCHSCREEN
:
192 action
= action_get_touchscreen_press(&x
, &y
);
194 if(action
& BUTTON_REL
)
199 user_index
+= (prev_y
- y
) / delta_y
;
208 } while(action
!= ACTION_STD_CANCEL
);
212 #else /* HAVE_LCD_BITMAP */
213 bool logfdisplay(void)
216 /* TODO: implement a browser for charcell bitmaps */
219 #endif /* HAVE_LCD_BITMAP */
221 /* Store the logf log to logf.txt in the .rockbox directory. The order of the
222 * entries will be "reversed" so that the most recently logged entry is on the
228 /* nothing to print ? */
229 if(logfindex
== 0 && !logfwrap
)
230 /* nothing is logged just yet */
233 fd
= open(ROCKBOX_DIR
"/logf.txt", O_CREAT
|O_WRONLY
|O_TRUNC
);
243 if(logfbuffer
[i
]=='\0')
246 fdprintf(fd
, "%c", logfbuffer
[i
]);
249 if(i
>= MAX_LOGF_SIZE
)
251 } while(i
!= logfindex
);
258 #endif /* ROCKBOX_HAS_LOGF */