From 5d5f8169b53fc989b456b0f0d7940bcf9415cbeb Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Mon, 26 Oct 2020 08:27:32 -0400 Subject: 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 --- apps/gui/statusbar.c | 21 ++++++++++++--------- 1 file 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) memset((void*)&(bar->lastinfo), 0, sizeof(struct status_info)); #if CONFIG_RTC bar->last_tm_min = 0; -#endif +#endif } #define GET_RECT(vp, vals,display) do { \ @@ -215,7 +215,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw, struct vi { #endif /* CONFIG_CHARGING < CHARGING_MONITOR */ /* animate in (max.) 4 steps, starting near the current charge level */ - if (TIME_AFTER(current_tick, bar->battery_icon_switch_tick)) + if (TIME_AFTER(current_tick, bar->battery_icon_switch_tick)) { if (++bar->info.batt_charge_step > 3) 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 display->set_drawmode(DRMODE_SOLID); if (bar->info.battery_state) - gui_statusbar_icon_battery(display, bar->info.battlevel, + gui_statusbar_icon_battery(display, bar->info.battlevel, bar->info.batt_charge_step); #ifdef HAVE_USB_POWER if (bar->info.usb_inserted) @@ -300,7 +300,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw, struct vi #endif bar->redraw_volume = gui_statusbar_icon_volume(bar, bar->info.volume); gui_statusbar_icon_play_state(display, current_playmode() + Icon_Play); - + #ifdef HAVE_RECORDING /* If in recording screen, replace repeat mode, volume and shuffle icons with recording info */ @@ -352,7 +352,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw, struct vi /* * Print battery icon to status bar */ -static void gui_statusbar_icon_battery(struct screen * display, int percent, +static void gui_statusbar_icon_battery(struct screen * display, int percent, int batt_charge_step) { int fill, endfill; @@ -376,7 +376,7 @@ static void gui_statusbar_icon_battery(struct screen * display, int percent, fill = endfill = (percent * (STATUSBAR_BATTERY_WIDTH-3) + 50) / 100; } -#if CONFIG_CHARGING == CHARGING_MONITOR && !defined(SIMULATOR) +#if CONFIG_CHARGING == CHARGING_MONITOR && !defined(SIMULATOR) /* Certain charge controlled targets */ /* show graphical animation when charging instead of numbers */ if ((global_settings.battery_display) && @@ -439,9 +439,10 @@ static bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume) unsigned int width, height; bool needs_redraw = false; int type = global_settings.volume_type; - struct screen * display=bar->display; + struct screen * display=bar->display; const int minvol = sound_min(SOUND_VOLUME); const int maxvol = sound_max(SOUND_VOLUME); + const int num_decimals = sound_numdecimals(SOUND_VOLUME); if (volume < minvol) volume = minvol; @@ -469,6 +470,8 @@ static bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume) /* display volume level numerical? */ if (type) { + if (num_decimals) + volume /= 10 * num_decimals; display->setfont(FONT_SYSFIXED); snprintf(buffer, sizeof(buffer), "%2d", volume); display->getstringsize(buffer, &width, &height); @@ -614,7 +617,7 @@ static int write_bitmap_number(struct screen * display, int value, */ static void gui_statusbar_write_format_info(struct screen * display) { - /* Can't fit info for sw codec targets in statusbar using FONT_SYSFIXED + /* Can't fit info for sw codec targets in statusbar using FONT_SYSFIXED so must use icons */ int rec_format = global_settings.rec_format; unsigned bitrk = 0; /* compiler warns about unitialized use !! */ @@ -682,7 +685,7 @@ static void gui_statusbar_write_samplerate_info(struct screen * display) STATUSBAR_RECFREQ_X_POS, STATUSBAR_Y_POS); /* write the 'k' */ - display->mono_bitmap(bitmap_glyphs_4x8[Glyph_4x8_k], xpos, + display->mono_bitmap(bitmap_glyphs_4x8[Glyph_4x8_k], xpos, STATUSBAR_Y_POS, BM_GLYPH_WIDTH, STATUSBAR_HEIGHT); } -- cgit v1.2.3