diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-08-30 00:39:31 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-08-30 00:39:31 +0000 |
commit | b847a7b296328a08eef4c74492dbd0056dff1318 (patch) | |
tree | 9ca1c5e311ace2dc9ae42229367065c6d0176040 /apps | |
parent | 924b5313ac2fe15d13b662ff762094ffb6f4ab5d (diff) | |
download | rockbox-b847a7b296328a08eef4c74492dbd0056dff1318.tar.gz rockbox-b847a7b296328a08eef4c74492dbd0056dff1318.zip |
Added status_draw() to set_playmode().
Moved rtc reading from icons.c code to status.c
Added boundary checks for time display values.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2066 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/recorder/icons.c | 28 | ||||
-rw-r--r-- | apps/recorder/icons.h | 2 | ||||
-rw-r--r-- | apps/status.c | 12 |
3 files changed, 26 insertions, 16 deletions
diff --git a/apps/recorder/icons.c b/apps/recorder/icons.c index d1ee11dbed..3f6518903f 100644 --- a/apps/recorder/icons.c +++ b/apps/recorder/icons.c | |||
@@ -290,23 +290,33 @@ void statusbar_icon_lock(void) | |||
290 | /* | 290 | /* |
291 | * Print time to status bar | 291 | * Print time to status bar |
292 | */ | 292 | */ |
293 | void statusbar_time(void) | 293 | void statusbar_time(int minutes) |
294 | { | 294 | { |
295 | int hour,minute; | ||
296 | unsigned char buffer[6]; | 295 | unsigned char buffer[6]; |
297 | unsigned int width, height; | 296 | unsigned int width, height; |
298 | #if defined(LOADABLE_FONTS) | 297 | #if defined(LOADABLE_FONTS) |
299 | unsigned char *font; | 298 | unsigned char *font; |
300 | #endif | 299 | #endif |
301 | 300 | ||
302 | hour = rtc_read(0x03); | 301 | int hour = minutes / 60; |
303 | minute = rtc_read(0x02); | 302 | int minute = minutes % 60; |
303 | |||
304 | if ( hour >= 0 && | ||
305 | hour <= 23 && | ||
306 | minute >= 0 && | ||
307 | minute <= 59 ) | ||
308 | { | ||
309 | snprintf(buffer, sizeof(buffer), "%d%d:%d%d", | ||
310 | (hour & 0x30) >> 4, | ||
311 | hour & 0x0f, | ||
312 | (minute & 0xf0) >> 4, | ||
313 | minute & 0x0f); | ||
314 | } | ||
315 | else | ||
316 | { | ||
317 | strncpy(buffer, "--:--", sizeof buffer); | ||
318 | } | ||
304 | 319 | ||
305 | snprintf(buffer, sizeof(buffer), "%d%d:%d%d", | ||
306 | (hour & 0x30) >> 4, | ||
307 | hour & 0x0f, | ||
308 | (minute & 0xf0) >> 4, | ||
309 | minute & 0x0f); | ||
310 | #if defined(LCD_PROPFONTS) | 320 | #if defined(LCD_PROPFONTS) |
311 | lcd_getstringsize(buffer, 0, &width, &height); | 321 | lcd_getstringsize(buffer, 0, &width, &height); |
312 | #elif defined(LOADABLE_FONTS) | 322 | #elif defined(LOADABLE_FONTS) |
diff --git a/apps/recorder/icons.h b/apps/recorder/icons.h index ff6a011b98..cebff7ca2c 100644 --- a/apps/recorder/icons.h +++ b/apps/recorder/icons.h | |||
@@ -86,6 +86,6 @@ extern void statusbar_icon_play_mode(int mode); | |||
86 | extern void statusbar_icon_shuffle(void); | 86 | extern void statusbar_icon_shuffle(void); |
87 | extern void statusbar_icon_lock(void); | 87 | extern void statusbar_icon_lock(void); |
88 | #ifdef HAVE_RTC | 88 | #ifdef HAVE_RTC |
89 | extern void statusbar_time(void); | 89 | extern void statusbar_time(int minutes); |
90 | #endif | 90 | #endif |
91 | #endif /* End HAVE_LCD_BITMAP */ | 91 | #endif /* End HAVE_LCD_BITMAP */ |
diff --git a/apps/status.c b/apps/status.c index c777a9e8ab..38a732a814 100644 --- a/apps/status.c +++ b/apps/status.c | |||
@@ -48,6 +48,7 @@ void status_init(void) | |||
48 | void status_set_playmode(enum playmode mode) | 48 | void status_set_playmode(enum playmode mode) |
49 | { | 49 | { |
50 | current_mode = mode; | 50 | current_mode = mode; |
51 | status_draw(); | ||
51 | } | 52 | } |
52 | 53 | ||
53 | #ifdef HAVE_LCD_BITMAP | 54 | #ifdef HAVE_LCD_BITMAP |
@@ -63,10 +64,10 @@ bool statusbar(bool state) | |||
63 | 64 | ||
64 | void status_draw(void) | 65 | void status_draw(void) |
65 | { | 66 | { |
66 | #if defined(HAVE_LCD_CHARCELLS) | ||
67 | int battlevel = battery_level(); | 67 | int battlevel = battery_level(); |
68 | int volume = mpeg_val2phys(SOUND_VOLUME, global_settings.volume); | 68 | int volume = mpeg_val2phys(SOUND_VOLUME, global_settings.volume); |
69 | 69 | ||
70 | #if defined(HAVE_LCD_CHARCELLS) | ||
70 | lcd_icon(ICON_BATTERY, true); | 71 | lcd_icon(ICON_BATTERY, true); |
71 | if(battlevel > 25) | 72 | if(battlevel > 25) |
72 | lcd_icon(ICON_BATTERY_1, true); | 73 | lcd_icon(ICON_BATTERY_1, true); |
@@ -126,9 +127,6 @@ void status_draw(void) | |||
126 | } | 127 | } |
127 | #endif | 128 | #endif |
128 | #ifdef HAVE_LCD_BITMAP | 129 | #ifdef HAVE_LCD_BITMAP |
129 | int battlevel = battery_level(); | ||
130 | int volume = mpeg_val2phys(SOUND_VOLUME, global_settings.volume); | ||
131 | |||
132 | if(global_settings.statusbar && statusbar_enabled) { | 130 | if(global_settings.statusbar && statusbar_enabled) { |
133 | statusbar_wipe(); | 131 | statusbar_wipe(); |
134 | #ifdef HAVE_CHARGE_CTRL | 132 | #ifdef HAVE_CHARGE_CTRL |
@@ -155,7 +153,8 @@ void status_draw(void) | |||
155 | } | 153 | } |
156 | } | 154 | } |
157 | 155 | ||
158 | if(battery_state) statusbar_icon_battery(battlevel, plug_state); | 156 | if (battery_state) |
157 | statusbar_icon_battery(battlevel, plug_state); | ||
159 | #else | 158 | #else |
160 | statusbar_icon_battery(battlevel, false); | 159 | statusbar_icon_battery(battlevel, false); |
161 | #endif | 160 | #endif |
@@ -170,8 +169,9 @@ void status_draw(void) | |||
170 | if (keys_locked) | 169 | if (keys_locked) |
171 | statusbar_icon_lock(); | 170 | statusbar_icon_lock(); |
172 | #ifdef HAVE_RTC | 171 | #ifdef HAVE_RTC |
173 | statusbar_time(); | 172 | statusbar_time( rtc_read(3)*60 + rtc_read(2) ); |
174 | #endif | 173 | #endif |
174 | |||
175 | #ifdef SIMULATOR | 175 | #ifdef SIMULATOR |
176 | lcd_update(); | 176 | lcd_update(); |
177 | #else | 177 | #else |