From 2993ae69b5cfd95ddab595fcce9cc7637477d6a5 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Wed, 7 Dec 2005 23:07:07 +0000 Subject: Simplified and uniform volume handling: * Volume setting in dB on all targets, within the 'natural' range defined by the respective DAC (limited to -100..+12 dB for archos Recorders and Ondios in order to avoid 4 chars being displayed in the status bar). 0 dB means line level on all targets. * No more artificial volume limiting for Iriver and Player, settings always represent true values. Removed the various sound scaling options. * Bumped config version so save your settings. Also make sure to adjust the volume after loading a .cfg, then save the .cfg again, otherwise the volume will be out of range (a flaw in the .cfg loader). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8197 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/statusbar.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'apps/gui/statusbar.c') 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; void gui_statusbar_init(struct gui_statusbar * bar) { - bar->last_volume = -1; /* -1 means "first update ever" */ + bar->last_volume = -1000; /* -1000 means "first update ever" */ bar->battery_icon_switch_tick = 0; #ifdef HAVE_CHARGING bar->battery_charge_step = 0; @@ -117,6 +117,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) #endif /* CONFIG_RTC */ #ifdef HAVE_LCD_CHARCELLS + int vol; (void)force_redraw; /* players always "redraw" */ #endif /* HAVE_LCD_CHARCELLS */ @@ -277,12 +278,14 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) display->icon(ICON_BATTERY_2, bar->info.battlevel > 50); display->icon(ICON_BATTERY_3, bar->info.battlevel > 75); + vol = 100 * (bar->info.volume - sound_min(SOUND_VOLUME)) + / (sound_max(SOUND_VOLUME) - sound_min(SOUND_VOLUME)); display->icon(ICON_VOLUME, true); - display->icon(ICON_VOLUME_1, bar->info.volume > 10); - display->icon(ICON_VOLUME_2, bar->info.volume > 30); - display->icon(ICON_VOLUME_3, bar->info.volume > 50); - display->icon(ICON_VOLUME_4, bar->info.volume > 70); - display->icon(ICON_VOLUME_5, bar->info.volume > 90); + display->icon(ICON_VOLUME_1, vol > 10); + display->icon(ICON_VOLUME_2, vol > 30); + display->icon(ICON_VOLUME_3, vol > 50); + display->icon(ICON_VOLUME_4, vol > 70); + display->icon(ICON_VOLUME_5, vol > 90); display->icon(ICON_PLAY, current_playmode() == STATUS_PLAY); display->icon(ICON_PAUSE, current_playmode() == STATUS_PAUSE); @@ -356,31 +359,31 @@ void gui_statusbar_icon_battery(struct screen * display, int percent) /* * Print volume gauge to status bar */ -bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent) +bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume) { int i; - int volume; int vol; char buffer[4]; unsigned int width, height; bool needs_redraw = false; int type = global_settings.volume_type; - struct screen * display=bar->display; + struct screen * display=bar->display; + int minvol = sound_min(SOUND_VOLUME); + int maxvol = sound_max(SOUND_VOLUME); - volume = percent; - if (volume < 0) - volume = 0; - if (volume > 100) - volume = 100; + if (volume < minvol) + volume = minvol; + if (volume > maxvol) + volume = maxvol; - if (volume == 0) { + if (volume == minvol) { display->mono_bitmap(bitmap_icons_7x8[Icon_Mute], STATUSBAR_VOLUME_X_POS + STATUSBAR_VOLUME_WIDTH / 2 - 4, STATUSBAR_Y_POS, 7, STATUSBAR_HEIGHT); } else { /* We want to redraw the icon later on */ - if (bar->last_volume != volume && bar->last_volume >= 0) { + if (bar->last_volume != volume && bar->last_volume >= minvol) { bar->volume_icon_switch_tick = current_tick + HZ; } @@ -395,7 +398,7 @@ bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent) if (type) { display->setfont(FONT_SYSFIXED); - snprintf(buffer, sizeof(buffer), "%2d", percent); + snprintf(buffer, sizeof(buffer), "%2d", volume); display->getstringsize(buffer, &width, &height); if (height <= STATUSBAR_HEIGHT) { @@ -406,7 +409,7 @@ bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent) display->setfont(FONT_UI); } else { /* display volume bar */ - vol = volume * 14 / 100; + vol = (volume - minvol) * 14 / (maxvol - minvol); for(i=0; i < vol; i++) { display->vline(STATUSBAR_VOLUME_X_POS + i, STATUSBAR_Y_POS + 6 - i / 2, -- cgit v1.2.3