summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Keller <geekboy1011@gmail.com>2021-09-27 03:30:49 +0000
committerTim Keller <geekboy1011@gmail.com>2022-01-04 01:59:01 +0000
commit6d748206983ca1ae7c929fba58d62ddfdb365650 (patch)
treeeb156d81507e897a8648df49fbd7b00da4e87e0d
parent3ebf002f9db75513d036c0eaa0863e75882b3a40 (diff)
Add averaging to wake threshold. Makes it take more then just a "flick" to turn on
-rw-r--r--src/components/motion/MotionController.cpp5
-rw-r--r--src/components/motion/MotionController.h1
-rw-r--r--src/components/settings/Settings.h4
3 files changed, 7 insertions, 3 deletions
diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp
index 615ad26c..4843f304 100644
--- a/src/components/motion/MotionController.cpp
+++ b/src/components/motion/MotionController.cpp
@@ -50,7 +50,10 @@ bool MotionController::Should_ShakeWake(uint16_t thresh) {
auto diff = xTaskGetTickCount() - lastShakeTime;
lastShakeTime = xTaskGetTickCount();
int32_t speed = std::abs(y + z - lastYForShake - lastZForShake) / diff * 10;
- if (speed > thresh) {
+ //(.2 * speed) + ((1 - .2) * accumulatedspeed);
+ //implemented without floats as .25Alpha
+ accumulatedspeed = (speed/4) + ((accumulatedspeed/4)*3);
+ if (accumulatedspeed > thresh) {
wake = true;
}
lastXForShake = x;
diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h
index 28f7d3a7..aee9e63f 100644
--- a/src/components/motion/MotionController.h
+++ b/src/components/motion/MotionController.h
@@ -65,6 +65,7 @@ namespace Pinetime {
int16_t lastXForShake = 0;
int16_t lastYForShake = 0;
int16_t lastZForShake = 0;
+ int32_t accumulatedspeed = 0;
uint32_t lastShakeTime = 0;
};
}
diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h
index a4145738..5c3d2f4d 100644
--- a/src/components/settings/Settings.h
+++ b/src/components/settings/Settings.h
@@ -173,7 +173,7 @@ namespace Pinetime {
private:
Pinetime::Controllers::FS& fs;
- static constexpr uint32_t settingsVersion = 0x0004;
+ static constexpr uint32_t settingsVersion = 0x0003;
struct SettingsData {
uint32_t version = settingsVersion;
uint32_t stepsGoal = 10000;
@@ -187,7 +187,7 @@ namespace Pinetime {
PineTimeStyle PTS;
std::bitset<4> wakeUpMode {0};
- uint16_t shakeWakeThreshold = 300;
+ uint16_t shakeWakeThreshold = 150;
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
};