From b5d7a51d0afdca4114d9bff68c0abc8d93625c21 Mon Sep 17 00:00:00 2001 From: JustMe-NL Date: Sat, 27 Apr 2024 00:21:48 +0200 Subject: [PATCH] Add minimum value of 0x40 to Threshold. --- Platformio/hardware/ESP32/preferencesStorage_hal_esp32.cpp | 2 +- Platformio/hardware/ESP32/sleep_hal_esp32.cpp | 1 + Platformio/src/guis/gui_settings.cpp | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Platformio/hardware/ESP32/preferencesStorage_hal_esp32.cpp b/Platformio/hardware/ESP32/preferencesStorage_hal_esp32.cpp index 025ecf8..0adcb95 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")); + set_wakeupByIMUthreshold_HAL(preferences.getUChar("threshold", 0x45)); // 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 b445e90..4f9c877 100644 --- a/Platformio/hardware/ESP32/sleep_hal_esp32.cpp +++ b/Platformio/hardware/ESP32/sleep_hal_esp32.cpp @@ -36,6 +36,7 @@ char get_wakeupByIMUthreshold_HAL() { } void set_wakeupByIMUthreshold_HAL(char awakeupByIMUthreshold) { if (awakeupByIMUthreshold > 0x7F) awakeupByIMUthreshold = 0x7F; + if (awakeupByIMUthreshold < 0x40) awakeupByIMUthreshold = 0x40; wakeupByIMUthreshold = awakeupByIMUthreshold; } diff --git a/Platformio/src/guis/gui_settings.cpp b/Platformio/src/guis/gui_settings.cpp index 89711e4..4541059 100644 --- a/Platformio/src/guis/gui_settings.cpp +++ b/Platformio/src/guis/gui_settings.cpp @@ -25,8 +25,8 @@ static void bl_slider_event_cb(lv_event_t* e){ static void th_slider_event_cb(lv_event_t* e){ lv_obj_t* slider = lv_event_get_target(e); int32_t slider_value = lv_slider_get_value(slider); - if (slider_value < 0) {slider_value = 0;} - if (slider_value > 127) {slider_value = 127;} + if (slider_value < 0x40) {slider_value = 0x40;} + if (slider_value > 0x7F) {slider_value = 0x7F;} set_wakeupByIMUthreshold((char) slider_value); } @@ -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, 0, 127); + lv_slider_set_range(thslider, 0x40, 0x7F); 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);