From 1363e74972deee56aaf23e120317dd5f26e5e434 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Thu, 22 Apr 2004 01:09:12 +0000 Subject: Some changes to make the stop watch work better on the player, like scrolling the lap times. Now it also handles the USB. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4547 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/stopwatch.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'apps/plugins') diff --git a/apps/plugins/stopwatch.c b/apps/plugins/stopwatch.c index c2f5a7940e..f4da7bfeaf 100644 --- a/apps/plugins/stopwatch.c +++ b/apps/plugins/stopwatch.c @@ -73,6 +73,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) int button; int lap; int done = false; + bool update_lap = true; TEST_PLUGIN_API(api); (void)parameter; @@ -131,6 +132,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { prev_total = 0; curr_lap = 0; + update_lap = true; } break; @@ -138,6 +140,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) case BUTTON_ON: lap_times[curr_lap%MAX_LAPS] = stopwatch; curr_lap++; + update_lap = true; break; /* UP (RIGHT/+) = Scroll Lap timer up */ @@ -147,7 +150,10 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) case BUTTON_RIGHT: #endif if (lap_scroll > 0) + { lap_scroll --; + update_lap = true; + } break; /* DOWN (LEFT/-) = Scroll Lap timer down */ @@ -160,8 +166,13 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) (lap_scroll < MAX_SCROLL) ) { lap_scroll ++; + update_lap = true; } break; + + case SYS_USB_CONNECTED: + rb->usb_screen(); + return PLUGIN_USB_CONNECTED; } if (counting) @@ -176,19 +187,23 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) ticks_to_string(stopwatch,0,32,buf); rb->lcd_puts(0, TIMER_Y, buf); - lap_start = MIN(curr_lap, lap_scroll); - lap_start = curr_lap - lap_scroll; - for (lap = lap_start; lap > lap_start - LAP_LINES; lap--) + if(update_lap) { - if (lap > 0) - { - ticks_to_string(lap_times[(lap-1)%MAX_LAPS],lap,32,buf); - rb->lcd_puts(0, LAP_Y + lap_start - lap, buf); - } - else + lap_start = curr_lap - lap_scroll; + for (lap = lap_start; lap > lap_start - LAP_LINES; lap--) { - rb->lcd_puts(0, LAP_Y + lap_start - lap, " "); + if (lap > 0) + { + ticks_to_string(lap_times[(lap-1)%MAX_LAPS],lap,32,buf); + rb->lcd_puts_scroll(0, LAP_Y + lap_start - lap, buf); + } + else + { + rb->lcd_puts(0, LAP_Y + lap_start - lap, + " "); + } } + update_lap = false; } #ifdef HAVE_LCD_BITMAP -- cgit v1.2.3