Add minimum value of 0x40 to Threshold.

This commit is contained in:
JustMe-NL 2024-04-27 00:21:48 +02:00
parent d1f3a4592f
commit b5d7a51d0a
3 changed files with 5 additions and 4 deletions

View file

@ -19,7 +19,7 @@ void init_preferences_HAL(void) {
// from here // from here
currentScene = std::string(preferences.getString("currentScene").c_str()); currentScene = std::string(preferences.getString("currentScene").c_str());
currentGUIname = std::string(preferences.getString("currentGUIname").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()); // Serial.printf("Preferences restored: brightness %d, GUI %s, scene %s\r\n", get_backlightBrightness_HAL(), get_currentGUIname().c_str(), get_currentScene().c_str());
} else { } else {

View file

@ -36,6 +36,7 @@ char get_wakeupByIMUthreshold_HAL() {
} }
void set_wakeupByIMUthreshold_HAL(char awakeupByIMUthreshold) { void set_wakeupByIMUthreshold_HAL(char awakeupByIMUthreshold) {
if (awakeupByIMUthreshold > 0x7F) awakeupByIMUthreshold = 0x7F; if (awakeupByIMUthreshold > 0x7F) awakeupByIMUthreshold = 0x7F;
if (awakeupByIMUthreshold < 0x40) awakeupByIMUthreshold = 0x40;
wakeupByIMUthreshold = awakeupByIMUthreshold; wakeupByIMUthreshold = awakeupByIMUthreshold;
} }

View file

@ -25,8 +25,8 @@ static void bl_slider_event_cb(lv_event_t* e){
static void th_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); lv_obj_t* slider = lv_event_get_target(e);
int32_t slider_value = lv_slider_get_value(slider); int32_t slider_value = lv_slider_get_value(slider);
if (slider_value < 0) {slider_value = 0;} if (slider_value < 0x40) {slider_value = 0x40;}
if (slider_value > 127) {slider_value = 127;} if (slider_value > 0x7F) {slider_value = 0x7F;}
set_wakeupByIMUthreshold((char) slider_value); 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_label_set_text(menuLabel, "Wake up sensitivity");
lv_obj_align(menuLabel, LV_ALIGN_TOP_LEFT, 0, 94); lv_obj_align(menuLabel, LV_ALIGN_TOP_LEFT, 0, 94);
lv_obj_t *thslider = lv_slider_create(menuBox); 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_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_opa(thslider, LV_OPA_COVER, LV_PART_MAIN);
lv_obj_set_style_bg_color(thslider, lv_color_lighten(color_primary, 50), LV_PART_MAIN); lv_obj_set_style_bg_color(thslider, lv_color_lighten(color_primary, 50), LV_PART_MAIN);