diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-12-07 23:07:07 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-12-07 23:07:07 +0000 |
commit | 2993ae69b5cfd95ddab595fcce9cc7637477d6a5 (patch) | |
tree | 1a9ba25c51db3d7313621da6dcf5bb4192cfea9d /apps/gui | |
parent | ec32c08a357bde454c11a41375230461509f2fe2 (diff) |
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
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/gwps-common.c | 7 | ||||
-rw-r--r-- | apps/gui/statusbar.c | 39 | ||||
-rw-r--r-- | apps/gui/statusbar.h | 2 |
3 files changed, 27 insertions, 21 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 7590f493e8..307036eda4 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -569,7 +569,10 @@ static char* get_tag(struct wps_data* wps_data, case 'v': /* volume */ *flags |= WPS_REFRESH_DYNAMIC; snprintf(buf, buf_size, "%d", global_settings.volume); - *intval = global_settings.volume / 10 + 1; + *intval = 10 * (global_settings.volume + - sound_min(SOUND_VOLUME)) + / (sound_max(SOUND_VOLUME) + - sound_min(SOUND_VOLUME)) + 1; return buf; } @@ -1892,7 +1895,7 @@ bool update_onvol_change(struct gui_wps * gwps) gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC); #ifdef HAVE_LCD_CHARCELLS - gui_splash(gwps->display,0, false, "Vol: %d %% ", + gui_splash(gwps->display,0, false, "Vol: %d dB ", sound_val2phys(SOUND_VOLUME, global_settings.volume)); return true; #endif 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, diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h index 6b8e49a838..650b49d63b 100644 --- a/apps/gui/statusbar.h +++ b/apps/gui/statusbar.h @@ -102,7 +102,7 @@ extern void gui_statusbar_init(struct gui_statusbar * bar); extern void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw); void gui_statusbar_icon_battery(struct screen * display, int percent); -bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent); +bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume); void gui_statusbar_icon_play_state(struct screen * display, int state); void gui_statusbar_icon_play_mode(struct screen * display, int mode); void gui_statusbar_icon_shuffle(struct screen * display); |