diff options
Diffstat (limited to 'apps/gui/statusbar.c')
-rw-r--r-- | apps/gui/statusbar.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c index fda54a610e..56d1647d9b 100644 --- a/apps/gui/statusbar.c +++ b/apps/gui/statusbar.c | |||
@@ -102,7 +102,7 @@ struct gui_syncstatusbar statusbars; | |||
102 | 102 | ||
103 | void gui_statusbar_init(struct gui_statusbar * bar) | 103 | void gui_statusbar_init(struct gui_statusbar * bar) |
104 | { | 104 | { |
105 | bar->last_volume = -1; /* -1 means "first update ever" */ | 105 | bar->last_volume = -1000; /* -1000 means "first update ever" */ |
106 | bar->battery_icon_switch_tick = 0; | 106 | bar->battery_icon_switch_tick = 0; |
107 | #ifdef HAVE_CHARGING | 107 | #ifdef HAVE_CHARGING |
108 | bar->battery_charge_step = 0; | 108 | bar->battery_charge_step = 0; |
@@ -117,6 +117,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) | |||
117 | #endif /* CONFIG_RTC */ | 117 | #endif /* CONFIG_RTC */ |
118 | 118 | ||
119 | #ifdef HAVE_LCD_CHARCELLS | 119 | #ifdef HAVE_LCD_CHARCELLS |
120 | int vol; | ||
120 | (void)force_redraw; /* players always "redraw" */ | 121 | (void)force_redraw; /* players always "redraw" */ |
121 | #endif /* HAVE_LCD_CHARCELLS */ | 122 | #endif /* HAVE_LCD_CHARCELLS */ |
122 | 123 | ||
@@ -277,12 +278,14 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) | |||
277 | display->icon(ICON_BATTERY_2, bar->info.battlevel > 50); | 278 | display->icon(ICON_BATTERY_2, bar->info.battlevel > 50); |
278 | display->icon(ICON_BATTERY_3, bar->info.battlevel > 75); | 279 | display->icon(ICON_BATTERY_3, bar->info.battlevel > 75); |
279 | 280 | ||
281 | vol = 100 * (bar->info.volume - sound_min(SOUND_VOLUME)) | ||
282 | / (sound_max(SOUND_VOLUME) - sound_min(SOUND_VOLUME)); | ||
280 | display->icon(ICON_VOLUME, true); | 283 | display->icon(ICON_VOLUME, true); |
281 | display->icon(ICON_VOLUME_1, bar->info.volume > 10); | 284 | display->icon(ICON_VOLUME_1, vol > 10); |
282 | display->icon(ICON_VOLUME_2, bar->info.volume > 30); | 285 | display->icon(ICON_VOLUME_2, vol > 30); |
283 | display->icon(ICON_VOLUME_3, bar->info.volume > 50); | 286 | display->icon(ICON_VOLUME_3, vol > 50); |
284 | display->icon(ICON_VOLUME_4, bar->info.volume > 70); | 287 | display->icon(ICON_VOLUME_4, vol > 70); |
285 | display->icon(ICON_VOLUME_5, bar->info.volume > 90); | 288 | display->icon(ICON_VOLUME_5, vol > 90); |
286 | 289 | ||
287 | display->icon(ICON_PLAY, current_playmode() == STATUS_PLAY); | 290 | display->icon(ICON_PLAY, current_playmode() == STATUS_PLAY); |
288 | display->icon(ICON_PAUSE, current_playmode() == STATUS_PAUSE); | 291 | display->icon(ICON_PAUSE, current_playmode() == STATUS_PAUSE); |
@@ -356,31 +359,31 @@ void gui_statusbar_icon_battery(struct screen * display, int percent) | |||
356 | /* | 359 | /* |
357 | * Print volume gauge to status bar | 360 | * Print volume gauge to status bar |
358 | */ | 361 | */ |
359 | bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent) | 362 | bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume) |
360 | { | 363 | { |
361 | int i; | 364 | int i; |
362 | int volume; | ||
363 | int vol; | 365 | int vol; |
364 | char buffer[4]; | 366 | char buffer[4]; |
365 | unsigned int width, height; | 367 | unsigned int width, height; |
366 | bool needs_redraw = false; | 368 | bool needs_redraw = false; |
367 | int type = global_settings.volume_type; | 369 | int type = global_settings.volume_type; |
368 | struct screen * display=bar->display; | 370 | struct screen * display=bar->display; |
371 | int minvol = sound_min(SOUND_VOLUME); | ||
372 | int maxvol = sound_max(SOUND_VOLUME); | ||
369 | 373 | ||
370 | volume = percent; | 374 | if (volume < minvol) |
371 | if (volume < 0) | 375 | volume = minvol; |
372 | volume = 0; | 376 | if (volume > maxvol) |
373 | if (volume > 100) | 377 | volume = maxvol; |
374 | volume = 100; | ||
375 | 378 | ||
376 | if (volume == 0) { | 379 | if (volume == minvol) { |
377 | display->mono_bitmap(bitmap_icons_7x8[Icon_Mute], | 380 | display->mono_bitmap(bitmap_icons_7x8[Icon_Mute], |
378 | STATUSBAR_VOLUME_X_POS + STATUSBAR_VOLUME_WIDTH / 2 - 4, | 381 | STATUSBAR_VOLUME_X_POS + STATUSBAR_VOLUME_WIDTH / 2 - 4, |
379 | STATUSBAR_Y_POS, 7, STATUSBAR_HEIGHT); | 382 | STATUSBAR_Y_POS, 7, STATUSBAR_HEIGHT); |
380 | } | 383 | } |
381 | else { | 384 | else { |
382 | /* We want to redraw the icon later on */ | 385 | /* We want to redraw the icon later on */ |
383 | if (bar->last_volume != volume && bar->last_volume >= 0) { | 386 | if (bar->last_volume != volume && bar->last_volume >= minvol) { |
384 | bar->volume_icon_switch_tick = current_tick + HZ; | 387 | bar->volume_icon_switch_tick = current_tick + HZ; |
385 | } | 388 | } |
386 | 389 | ||
@@ -395,7 +398,7 @@ bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent) | |||
395 | if (type) | 398 | if (type) |
396 | { | 399 | { |
397 | display->setfont(FONT_SYSFIXED); | 400 | display->setfont(FONT_SYSFIXED); |
398 | snprintf(buffer, sizeof(buffer), "%2d", percent); | 401 | snprintf(buffer, sizeof(buffer), "%2d", volume); |
399 | display->getstringsize(buffer, &width, &height); | 402 | display->getstringsize(buffer, &width, &height); |
400 | if (height <= STATUSBAR_HEIGHT) | 403 | if (height <= STATUSBAR_HEIGHT) |
401 | { | 404 | { |
@@ -406,7 +409,7 @@ bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent) | |||
406 | display->setfont(FONT_UI); | 409 | display->setfont(FONT_UI); |
407 | } else { | 410 | } else { |
408 | /* display volume bar */ | 411 | /* display volume bar */ |
409 | vol = volume * 14 / 100; | 412 | vol = (volume - minvol) * 14 / (maxvol - minvol); |
410 | for(i=0; i < vol; i++) { | 413 | for(i=0; i < vol; i++) { |
411 | display->vline(STATUSBAR_VOLUME_X_POS + i, | 414 | display->vline(STATUSBAR_VOLUME_X_POS + i, |
412 | STATUSBAR_Y_POS + 6 - i / 2, | 415 | STATUSBAR_Y_POS + 6 - i / 2, |