From caa4235c751e0a1bdc81a4aac33ca3a9d0cf08a3 Mon Sep 17 00:00:00 2001 From: JustMe-NL Date: Sat, 27 Apr 2024 13:46:36 +0200 Subject: [PATCH] Fix reverse threshold values Sliders only support ranges from min to max but the slider visual and the setting to the IMU are reversed. At the IMU we therefore store 0x7F, which is the maximum possible value, minus the slider value: 0x7F-0x3A = 0x45. So if the minimum IMU value is practically 0x40, the maximum slider value shuld be 0x3F. We use a non signed variable so we only need to do a sanitycheck on the maximum slider value of 0x3F. --- Platformio/hardware/ESP32/preferencesStorage_hal_esp32.cpp | 2 +- Platformio/hardware/ESP32/sleep_hal_esp32.cpp | 3 +-- Platformio/src/guis/gui_settings.cpp | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Platformio/hardware/ESP32/preferencesStorage_hal_esp32.cpp b/Platformio/hardware/ESP32/preferencesStorage_hal_esp32.cpp index 0adcb95..42ebe18 100644 --- a/Platformio/hardware/ESP32/preferencesStorage_hal_esp32.cpp +++ b/Platformio/hardware/ESP32/preferencesStorage_hal_esp32.cpp @@ -19,7 +19,7 @@ void init_preferences_HAL(void) { // from here currentScene = std::string(preferences.getString("currentScene").c_str()); currentGUIname = std::string(preferences.getString("currentGUIname").c_str()); - set_wakeupByIMUthreshold_HAL(preferences.getUChar("threshold", 0x45)); + set_wakeupByIMUthreshold_HAL(preferences.getUChar("threshold", 0x3A)); // Serial.printf("Preferences restored: brightness %d, GUI %s, scene %s\r\n", get_backlightBrightness_HAL(), get_currentGUIname().c_str(), get_currentScene().c_str()); } else { diff --git a/Platformio/hardware/ESP32/sleep_hal_esp32.cpp b/Platformio/hardware/ESP32/sleep_hal_esp32.cpp index 4f9c877..0dc8050 100644 --- a/Platformio/hardware/ESP32/sleep_hal_esp32.cpp +++ b/Platformio/hardware/ESP32/sleep_hal_esp32.cpp @@ -35,8 +35,7 @@ char get_wakeupByIMUthreshold_HAL() { return wakeupByIMUthreshold; } void set_wakeupByIMUthreshold_HAL(char awakeupByIMUthreshold) { - if (awakeupByIMUthreshold > 0x7F) awakeupByIMUthreshold = 0x7F; - if (awakeupByIMUthreshold < 0x40) awakeupByIMUthreshold = 0x40; + if (awakeupByIMUthreshold > 0x3F) awakeupByIMUthreshold = 0x3F; wakeupByIMUthreshold = awakeupByIMUthreshold; } diff --git a/Platformio/src/guis/gui_settings.cpp b/Platformio/src/guis/gui_settings.cpp index 4541059..8ca3e17 100644 --- a/Platformio/src/guis/gui_settings.cpp +++ b/Platformio/src/guis/gui_settings.cpp @@ -148,7 +148,7 @@ void create_tab_content_settings(lv_obj_t* tab) { lv_label_set_text(menuLabel, "Wake up sensitivity"); lv_obj_align(menuLabel, LV_ALIGN_TOP_LEFT, 0, 94); lv_obj_t *thslider = lv_slider_create(menuBox); - lv_slider_set_range(thslider, 0x40, 0x7F); + lv_slider_set_range(thslider, 0, 0x3F); lv_obj_set_style_bg_color(thslider, lv_color_white(), LV_PART_KNOB); lv_obj_set_style_bg_opa(thslider, LV_OPA_COVER, LV_PART_MAIN); lv_obj_set_style_bg_color(thslider, lv_color_lighten(color_primary, 50), LV_PART_MAIN);