Skip to content

Commit 6d74820

Browse files
committed
Add averaging to wake threshold. Makes it take more then just a "flick" to turn on
1 parent 3ebf002 commit 6d74820

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/components/motion/MotionController.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ bool MotionController::Should_ShakeWake(uint16_t thresh) {
5050
auto diff = xTaskGetTickCount() - lastShakeTime;
5151
lastShakeTime = xTaskGetTickCount();
5252
int32_t speed = std::abs(y + z - lastYForShake - lastZForShake) / diff * 10;
53-
if (speed > thresh) {
53+
//(.2 * speed) + ((1 - .2) * accumulatedspeed);
54+
//implemented without floats as .25Alpha
55+
accumulatedspeed = (speed/4) + ((accumulatedspeed/4)*3);
56+
if (accumulatedspeed > thresh) {
5457
wake = true;
5558
}
5659
lastXForShake = x;

src/components/motion/MotionController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ namespace Pinetime {
6565
int16_t lastXForShake = 0;
6666
int16_t lastYForShake = 0;
6767
int16_t lastZForShake = 0;
68+
int32_t accumulatedspeed = 0;
6869
uint32_t lastShakeTime = 0;
6970
};
7071
}

src/components/settings/Settings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ namespace Pinetime {
173173
private:
174174
Pinetime::Controllers::FS& fs;
175175

176-
static constexpr uint32_t settingsVersion = 0x0004;
176+
static constexpr uint32_t settingsVersion = 0x0003;
177177
struct SettingsData {
178178
uint32_t version = settingsVersion;
179179
uint32_t stepsGoal = 10000;
@@ -187,7 +187,7 @@ namespace Pinetime {
187187
PineTimeStyle PTS;
188188

189189
std::bitset<4> wakeUpMode {0};
190-
uint16_t shakeWakeThreshold = 300;
190+
uint16_t shakeWakeThreshold = 150;
191191
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
192192
};
193193

0 commit comments

Comments
 (0)