From ebd213b1ee604727f6216ce244ebfa941bc592ea Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Wed, 30 Oct 2019 09:06:57 +0100 Subject: [PATCH] Optimizations for showing volume level. --- UI.hpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/UI.hpp b/UI.hpp index 2c51118..78f649c 100644 --- a/UI.hpp +++ b/UI.hpp @@ -565,7 +565,7 @@ void encoder_left_up(void) soften_volume.update(soften_volume.value() + (VOLUME_MAX - VOLUME_MIN) / VOLUME_ENC_STEPS, SOFTEN_VALUE_CHANGE_STEPS); else configuration.vol = VOLUME_MAX; - eeprom_write(); + UI_func_volume(0); } @@ -579,7 +579,7 @@ void encoder_left_down(void) soften_volume.update(tmp, SOFTEN_VALUE_CHANGE_STEPS); else configuration.vol = VOLUME_MIN; - eeprom_write(); + UI_func_volume(0); } @@ -1730,24 +1730,27 @@ void UI_func_volume(uint8_t param) Serial.println(F("UI_func_volume()")); #endif - menu_state = MENU_VOLUME; back_from_volume = 0; - // update LCD content - LCDML.DISP_clear(); - lcd.show(0, 0, 8, "Volume: "); - lcd.show(0, 9, 3, configuration.vol); + if (menu_state != MENU_VOLUME) + { + lcd.show(0, 0, LCD_cols, "Volume:"); + lcd.show(1, 0, LCD_cols, "[ ]"); + menu_state = MENU_VOLUME; + } + + lcd.setCursor(8, 0); + lcd_display_int(configuration.vol, 3, true, false, false); lcd.setCursor(1, 1); - for (uint8_t i = 0; i < LCD_cols; i++) + for (uint8_t i = 0; i < LCD_cols - 2; i++) { - if (i < int((LCD_cols - 2) * configuration.vol / 100.0)) + if (i < int(((LCD_cols - 2) * configuration.vol / 100.0) + 0.5)) lcd.print(F("*")); else lcd.print(F(" ")); } set_volume(configuration.vol, configuration.pan[0], configuration.mono); - lcd.show(1, 0, 1, "["); - lcd.show(1, 15, 1, "]"); + eeprom_write(); } void UI_function_not_enabled(void)