diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-10-26 08:27:32 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-10-26 08:28:34 -0400 |
commit | 5d5f8169b53fc989b456b0f0d7940bcf9415cbeb (patch) | |
tree | 40299286529cfca1728b9d38b915b6c3062ba717 /apps | |
parent | 845e5a4f0382a8af758e0477ba504711946c6843 (diff) | |
download | rockbox-5d5f8169b53fc989b456b0f0d7940bcf9415cbeb.tar.gz rockbox-5d5f8169b53fc989b456b0f0d7940bcf9415cbeb.zip |
statusbar: Respect 'numdecimals' when displaying the volume setting
eg with numdecimals=1, a value of "-300" actually means "-30.0" So
divide it down appropriately, and only display the whole integer
portion.
Change-Id: I62927d2e64b224f3c11640b9bb9e84d60dbde34b
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gui/statusbar.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c index a43828b268..cf70b7bb39 100644 --- a/apps/gui/statusbar.c +++ b/apps/gui/statusbar.c | |||
@@ -166,7 +166,7 @@ static void gui_statusbar_init(struct gui_statusbar * bar) | |||
166 | memset((void*)&(bar->lastinfo), 0, sizeof(struct status_info)); | 166 | memset((void*)&(bar->lastinfo), 0, sizeof(struct status_info)); |
167 | #if CONFIG_RTC | 167 | #if CONFIG_RTC |
168 | bar->last_tm_min = 0; | 168 | bar->last_tm_min = 0; |
169 | #endif | 169 | #endif |
170 | } | 170 | } |
171 | 171 | ||
172 | #define GET_RECT(vp, vals,display) do { \ | 172 | #define GET_RECT(vp, vals,display) do { \ |
@@ -215,7 +215,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw, struct vi | |||
215 | { | 215 | { |
216 | #endif /* CONFIG_CHARGING < CHARGING_MONITOR */ | 216 | #endif /* CONFIG_CHARGING < CHARGING_MONITOR */ |
217 | /* animate in (max.) 4 steps, starting near the current charge level */ | 217 | /* animate in (max.) 4 steps, starting near the current charge level */ |
218 | if (TIME_AFTER(current_tick, bar->battery_icon_switch_tick)) | 218 | if (TIME_AFTER(current_tick, bar->battery_icon_switch_tick)) |
219 | { | 219 | { |
220 | if (++bar->info.batt_charge_step > 3) | 220 | if (++bar->info.batt_charge_step > 3) |
221 | bar->info.batt_charge_step = bar->info.battlevel / 34; | 221 | bar->info.batt_charge_step = bar->info.battlevel / 34; |
@@ -273,7 +273,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw, struct vi | |||
273 | display->set_drawmode(DRMODE_SOLID); | 273 | display->set_drawmode(DRMODE_SOLID); |
274 | 274 | ||
275 | if (bar->info.battery_state) | 275 | if (bar->info.battery_state) |
276 | gui_statusbar_icon_battery(display, bar->info.battlevel, | 276 | gui_statusbar_icon_battery(display, bar->info.battlevel, |
277 | bar->info.batt_charge_step); | 277 | bar->info.batt_charge_step); |
278 | #ifdef HAVE_USB_POWER | 278 | #ifdef HAVE_USB_POWER |
279 | if (bar->info.usb_inserted) | 279 | if (bar->info.usb_inserted) |
@@ -300,7 +300,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw, struct vi | |||
300 | #endif | 300 | #endif |
301 | bar->redraw_volume = gui_statusbar_icon_volume(bar, bar->info.volume); | 301 | bar->redraw_volume = gui_statusbar_icon_volume(bar, bar->info.volume); |
302 | gui_statusbar_icon_play_state(display, current_playmode() + Icon_Play); | 302 | gui_statusbar_icon_play_state(display, current_playmode() + Icon_Play); |
303 | 303 | ||
304 | #ifdef HAVE_RECORDING | 304 | #ifdef HAVE_RECORDING |
305 | /* If in recording screen, replace repeat mode, volume | 305 | /* If in recording screen, replace repeat mode, volume |
306 | and shuffle icons with recording info */ | 306 | and shuffle icons with recording info */ |
@@ -352,7 +352,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw, struct vi | |||
352 | /* | 352 | /* |
353 | * Print battery icon to status bar | 353 | * Print battery icon to status bar |
354 | */ | 354 | */ |
355 | static void gui_statusbar_icon_battery(struct screen * display, int percent, | 355 | static void gui_statusbar_icon_battery(struct screen * display, int percent, |
356 | int batt_charge_step) | 356 | int batt_charge_step) |
357 | { | 357 | { |
358 | int fill, endfill; | 358 | int fill, endfill; |
@@ -376,7 +376,7 @@ static void gui_statusbar_icon_battery(struct screen * display, int percent, | |||
376 | fill = endfill = (percent * (STATUSBAR_BATTERY_WIDTH-3) + 50) / 100; | 376 | fill = endfill = (percent * (STATUSBAR_BATTERY_WIDTH-3) + 50) / 100; |
377 | } | 377 | } |
378 | 378 | ||
379 | #if CONFIG_CHARGING == CHARGING_MONITOR && !defined(SIMULATOR) | 379 | #if CONFIG_CHARGING == CHARGING_MONITOR && !defined(SIMULATOR) |
380 | /* Certain charge controlled targets */ | 380 | /* Certain charge controlled targets */ |
381 | /* show graphical animation when charging instead of numbers */ | 381 | /* show graphical animation when charging instead of numbers */ |
382 | if ((global_settings.battery_display) && | 382 | if ((global_settings.battery_display) && |
@@ -439,9 +439,10 @@ static bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume) | |||
439 | unsigned int width, height; | 439 | unsigned int width, height; |
440 | bool needs_redraw = false; | 440 | bool needs_redraw = false; |
441 | int type = global_settings.volume_type; | 441 | int type = global_settings.volume_type; |
442 | struct screen * display=bar->display; | 442 | struct screen * display=bar->display; |
443 | const int minvol = sound_min(SOUND_VOLUME); | 443 | const int minvol = sound_min(SOUND_VOLUME); |
444 | const int maxvol = sound_max(SOUND_VOLUME); | 444 | const int maxvol = sound_max(SOUND_VOLUME); |
445 | const int num_decimals = sound_numdecimals(SOUND_VOLUME); | ||
445 | 446 | ||
446 | if (volume < minvol) | 447 | if (volume < minvol) |
447 | volume = minvol; | 448 | volume = minvol; |
@@ -469,6 +470,8 @@ static bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume) | |||
469 | /* display volume level numerical? */ | 470 | /* display volume level numerical? */ |
470 | if (type) | 471 | if (type) |
471 | { | 472 | { |
473 | if (num_decimals) | ||
474 | volume /= 10 * num_decimals; | ||
472 | display->setfont(FONT_SYSFIXED); | 475 | display->setfont(FONT_SYSFIXED); |
473 | snprintf(buffer, sizeof(buffer), "%2d", volume); | 476 | snprintf(buffer, sizeof(buffer), "%2d", volume); |
474 | display->getstringsize(buffer, &width, &height); | 477 | display->getstringsize(buffer, &width, &height); |
@@ -614,7 +617,7 @@ static int write_bitmap_number(struct screen * display, int value, | |||
614 | */ | 617 | */ |
615 | static void gui_statusbar_write_format_info(struct screen * display) | 618 | static void gui_statusbar_write_format_info(struct screen * display) |
616 | { | 619 | { |
617 | /* Can't fit info for sw codec targets in statusbar using FONT_SYSFIXED | 620 | /* Can't fit info for sw codec targets in statusbar using FONT_SYSFIXED |
618 | so must use icons */ | 621 | so must use icons */ |
619 | int rec_format = global_settings.rec_format; | 622 | int rec_format = global_settings.rec_format; |
620 | unsigned bitrk = 0; /* compiler warns about unitialized use !! */ | 623 | unsigned bitrk = 0; /* compiler warns about unitialized use !! */ |
@@ -682,7 +685,7 @@ static void gui_statusbar_write_samplerate_info(struct screen * display) | |||
682 | STATUSBAR_RECFREQ_X_POS, STATUSBAR_Y_POS); | 685 | STATUSBAR_RECFREQ_X_POS, STATUSBAR_Y_POS); |
683 | 686 | ||
684 | /* write the 'k' */ | 687 | /* write the 'k' */ |
685 | display->mono_bitmap(bitmap_glyphs_4x8[Glyph_4x8_k], xpos, | 688 | display->mono_bitmap(bitmap_glyphs_4x8[Glyph_4x8_k], xpos, |
686 | STATUSBAR_Y_POS, BM_GLYPH_WIDTH, | 689 | STATUSBAR_Y_POS, BM_GLYPH_WIDTH, |
687 | STATUSBAR_HEIGHT); | 690 | STATUSBAR_HEIGHT); |
688 | } | 691 | } |