diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2007-04-26 13:52:53 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2007-04-26 13:52:53 +0000 |
commit | ed8b3bb74b5d1d75d9e05ce060579f19248a97f7 (patch) | |
tree | c6b011232895c545fc9cf9b1096a95417da0bce8 /apps | |
parent | 50798120310938cd61d19fdb943a3c654f846a9f (diff) | |
download | rockbox-ed8b3bb74b5d1d75d9e05ce060579f19248a97f7.tar.gz rockbox-ed8b3bb74b5d1d75d9e05ce060579f19248a97f7.zip |
Accept FS#7080 by Mauricio Peccorini with some minor changes by me:
- show more info in the stopwatch screen, and use the whole display for lap times
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13271 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/stopwatch.c | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/apps/plugins/stopwatch.c b/apps/plugins/stopwatch.c index 3d60b7e3a3..6d4c4d6ac7 100644 --- a/apps/plugins/stopwatch.c +++ b/apps/plugins/stopwatch.c | |||
@@ -22,16 +22,13 @@ | |||
22 | PLUGIN_HEADER | 22 | PLUGIN_HEADER |
23 | 23 | ||
24 | #ifdef HAVE_LCD_BITMAP | 24 | #ifdef HAVE_LCD_BITMAP |
25 | #define LAP_LINES 6 | ||
26 | #define TIMER_Y 1 | 25 | #define TIMER_Y 1 |
27 | #else | 26 | #else |
28 | #define LAP_LINES 1 | ||
29 | #define TIMER_Y 0 | 27 | #define TIMER_Y 0 |
30 | #endif | 28 | #endif |
31 | 29 | ||
32 | #define LAP_Y TIMER_Y+1 | 30 | #define LAP_Y TIMER_Y+1 |
33 | #define MAX_LAPS 10 | 31 | #define MAX_LAPS 64 |
34 | #define MAX_SCROLL (MAX_LAPS - LAP_LINES) | ||
35 | 32 | ||
36 | /* variable button definitions */ | 33 | /* variable button definitions */ |
37 | #if CONFIG_KEYPAD == RECORDER_PAD | 34 | #if CONFIG_KEYPAD == RECORDER_PAD |
@@ -148,9 +145,30 @@ static void ticks_to_string(int ticks,int lap,int buflen, char * buf) | |||
148 | } | 145 | } |
149 | else | 146 | else |
150 | { | 147 | { |
151 | rb->snprintf(buf, buflen, | 148 | |
152 | "%2d %2d:%02d:%02d.%02d", | 149 | if (lap > 1) |
153 | lap, hours, minutes, seconds, cs); | 150 | { |
151 | int last_ticks, last_hours, last_minutes, last_seconds, last_cs; | ||
152 | last_ticks = lap_times[(lap-1)%MAX_LAPS] - lap_times[(lap-2)%MAX_LAPS]; | ||
153 | last_hours = last_ticks / (HZ * 3600); | ||
154 | last_ticks -= (HZ * last_hours * 3600); | ||
155 | last_minutes = last_ticks / (HZ * 60); | ||
156 | last_ticks -= (HZ * last_minutes * 60); | ||
157 | last_seconds = last_ticks / HZ; | ||
158 | last_ticks -= (HZ * last_seconds); | ||
159 | last_cs = last_ticks; | ||
160 | |||
161 | rb->snprintf(buf, buflen, | ||
162 | "%2d %2d:%02d:%02d.%02d [%2d:%02d:%02d.%02d]", | ||
163 | lap, hours, minutes, seconds, cs, last_hours, | ||
164 | last_minutes, last_seconds, last_cs); | ||
165 | } | ||
166 | else | ||
167 | { | ||
168 | rb->snprintf(buf, buflen, | ||
169 | "%2d %2d:%02d:%02d.%02d", | ||
170 | lap, hours, minutes, seconds, cs); | ||
171 | } | ||
154 | } | 172 | } |
155 | } | 173 | } |
156 | 174 | ||
@@ -161,16 +179,21 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
161 | int lap; | 179 | int lap; |
162 | int done = false; | 180 | int done = false; |
163 | bool update_lap = true; | 181 | bool update_lap = true; |
182 | int lines, h; | ||
164 | 183 | ||
165 | (void)parameter; | 184 | (void)parameter; |
166 | rb = api; | 185 | rb = api; |
167 | 186 | ||
168 | #ifdef HAVE_LCD_BITMAP | 187 | #ifdef HAVE_LCD_BITMAP |
169 | rb->lcd_setfont(FONT_UI); | 188 | rb->lcd_setfont(FONT_UI); |
189 | rb->lcd_getstringsize("M", NULL, &h); | ||
190 | lines = (LCD_HEIGHT / h) - (LAP_Y); | ||
191 | #else | ||
192 | lines = 1; | ||
170 | #endif | 193 | #endif |
171 | 194 | ||
172 | rb->lcd_clear_display(); | 195 | rb->lcd_clear_display(); |
173 | 196 | ||
174 | while (!done) | 197 | while (!done) |
175 | { | 198 | { |
176 | if (counting) | 199 | if (counting) |
@@ -188,7 +211,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
188 | if(update_lap) | 211 | if(update_lap) |
189 | { | 212 | { |
190 | lap_start = curr_lap - lap_scroll; | 213 | lap_start = curr_lap - lap_scroll; |
191 | for (lap = lap_start; lap > lap_start - LAP_LINES; lap--) | 214 | for (lap = lap_start; lap > lap_start - lines; lap--) |
192 | { | 215 | { |
193 | if (lap > 0) | 216 | if (lap > 0) |
194 | { | 217 | { |
@@ -272,8 +295,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
272 | 295 | ||
273 | /* Scroll Lap timer down */ | 296 | /* Scroll Lap timer down */ |
274 | case STOPWATCH_SCROLL_DOWN: | 297 | case STOPWATCH_SCROLL_DOWN: |
275 | if ((lap_scroll < curr_lap - LAP_LINES) && | 298 | if ((lap_scroll < curr_lap - lines) && |
276 | (lap_scroll < MAX_SCROLL) ) | 299 | (lap_scroll < (MAX_LAPS - lines)) ) |
277 | { | 300 | { |
278 | lap_scroll ++; | 301 | lap_scroll ++; |
279 | update_lap = true; | 302 | update_lap = true; |