summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/gwps-common.c7
-rw-r--r--apps/gui/statusbar.c39
-rw-r--r--apps/gui/statusbar.h2
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,
569 case 'v': /* volume */ 569 case 'v': /* volume */
570 *flags |= WPS_REFRESH_DYNAMIC; 570 *flags |= WPS_REFRESH_DYNAMIC;
571 snprintf(buf, buf_size, "%d", global_settings.volume); 571 snprintf(buf, buf_size, "%d", global_settings.volume);
572 *intval = global_settings.volume / 10 + 1; 572 *intval = 10 * (global_settings.volume
573 - sound_min(SOUND_VOLUME))
574 / (sound_max(SOUND_VOLUME)
575 - sound_min(SOUND_VOLUME)) + 1;
573 return buf; 576 return buf;
574 577
575 } 578 }
@@ -1892,7 +1895,7 @@ bool update_onvol_change(struct gui_wps * gwps)
1892 gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC); 1895 gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC);
1893 1896
1894#ifdef HAVE_LCD_CHARCELLS 1897#ifdef HAVE_LCD_CHARCELLS
1895 gui_splash(gwps->display,0, false, "Vol: %d %% ", 1898 gui_splash(gwps->display,0, false, "Vol: %d dB ",
1896 sound_val2phys(SOUND_VOLUME, global_settings.volume)); 1899 sound_val2phys(SOUND_VOLUME, global_settings.volume));
1897 return true; 1900 return true;
1898#endif 1901#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;
102 102
103void gui_statusbar_init(struct gui_statusbar * bar) 103void 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 */
359bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent) 362bool 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,
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);
102extern void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw); 102extern void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw);
103 103
104void gui_statusbar_icon_battery(struct screen * display, int percent); 104void gui_statusbar_icon_battery(struct screen * display, int percent);
105bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent); 105bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume);
106void gui_statusbar_icon_play_state(struct screen * display, int state); 106void gui_statusbar_icon_play_state(struct screen * display, int state);
107void gui_statusbar_icon_play_mode(struct screen * display, int mode); 107void gui_statusbar_icon_play_mode(struct screen * display, int mode);
108void gui_statusbar_icon_shuffle(struct screen * display); 108void gui_statusbar_icon_shuffle(struct screen * display);