summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Keller <geekboy1011@gmail.com>2021-09-28 04:21:47 +0000
committerTim Keller <geekboy1011@gmail.com>2022-01-04 02:00:02 +0000
commitf780ac999a069b3539f5419b9e07a624ae018030 (patch)
tree58c0fcec0a348255dc40f7d5c4e257d0ea13ab08
parentd2510d7926227df36ff0dcb9fe1b5ea9d586596c (diff)
Actually save the threshold
Prevent a few crashes due to an LV task being active when it shouldnt be.
-rw-r--r--src/components/settings/Settings.h6
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.cpp23
-rw-r--r--src/displayapp/screens/settings/Settings.cpp2
3 files changed, 23 insertions, 8 deletions
diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h
index e623f3a5..12ac85b5 100644
--- a/src/components/settings/Settings.h
+++ b/src/components/settings/Settings.h
@@ -115,7 +115,11 @@ namespace Pinetime {
};
void SetShakeThreshold(uint16_t thresh){
- settings.shakeWakeThreshold = thresh;
+ if(settings.shakeWakeThreshold != thresh){
+ settings.shakeWakeThreshold = thresh;
+ settingsChanged = true;
+ }
+
}
int16_t GetShakeThreshold() const{
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.cpp b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
index 19afa24f..dc0812a7 100644
--- a/src/displayapp/screens/settings/SettingShakeThreshold.cpp
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
@@ -24,13 +24,14 @@ SettingShakeThreshold::SettingShakeThreshold(DisplayApp* app,
systemTask {systemTask} {
lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text_static(title, "Shake Threshold");
+ lv_label_set_text_static(title, "Wake Sensitivity");
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0);
+ taskCount = 0;
positionArc = lv_arc_create(lv_scr_act(), nullptr);
- // Why do this?
+
positionArc->user_data = this;
lv_obj_set_event_cb(positionArc, event_handler);
@@ -59,6 +60,8 @@ SettingShakeThreshold::SettingShakeThreshold(DisplayApp* app,
}
SettingShakeThreshold::~SettingShakeThreshold() {
+ settingsController.SetShakeThreshold(lv_arc_get_value(positionArc));
+ lv_task_del(refreshTask);
lv_obj_clean(lv_scr_act());
settingsController.SaveSettings();
}
@@ -69,8 +72,9 @@ void SettingShakeThreshold::Refresh() {
if((motionController.currentShakeSpeed()-200) > lv_arc_get_value(positionArc)){
lv_arc_set_value(positionArc,(int16_t)motionController.currentShakeSpeed()-200);
}
- if(taskCount >= 100){
+ if(taskCount >= 50){
lv_label_set_text(calLabel, "Calibrate");
+ taskCount=0;
lv_task_del(refreshTask);
}
@@ -80,11 +84,18 @@ void SettingShakeThreshold::UpdateSelected(lv_obj_t* object, lv_event_t event) {
switch (event) {
case LV_EVENT_PRESSED: {
- taskCount = 0;
- refreshTask = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
- lv_label_set_text(calLabel, "Shake!!!");
+ if(taskCount == 0){
+ refreshTask = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
+ lv_label_set_text(calLabel, "Shake!!!");
+ }else{
+
+ lv_task_del(refreshTask);
+ taskCount=0;
+ lv_label_set_text(calLabel, "Calibrate");
+ }
break;
}
+
case LV_EVENT_VALUE_CHANGED: {
if (object == positionArc) {
settingsController.SetShakeThreshold(lv_arc_get_value(positionArc));
diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp
index cf78ad13..0f77456a 100644
--- a/src/displayapp/screens/settings/Settings.cpp
+++ b/src/displayapp/screens/settings/Settings.cpp
@@ -66,7 +66,7 @@ std::unique_ptr<Screen> Settings::CreateScreen3() {
{Symbols::none, "None", Apps::None}
}};
if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake)) {
- applications[1] = {Symbols::list, "Shake Threshold", Apps::SettingShakeThreshold};
+ applications[1] = {Symbols::list, "Wake Sense", Apps::SettingShakeThreshold};
}
return std::make_unique<Screens::List>(2, 3, app, settingsController, applications);
} \ No newline at end of file