diff options
| author | FintasticMan <finlay.neon.kid@gmail.com> | 2023-08-27 18:15:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-27 18:15:21 +0200 |
| commit | 0f9f606b78ffbb93b1365156d8492bbf4ee4995d (patch) | |
| tree | 263f41ae22015f70fcf93eaea1f2f4cfddff4e70 /src/components/motion/MotionController.cpp | |
| parent | 2b1eae7f597ea6c210b4c15a73ab5ba116fc5d2a (diff) | |
lowersleep: Implement Lower to Sleep functionality (#827)
Diffstat (limited to 'src/components/motion/MotionController.cpp')
| -rw-r--r-- | src/components/motion/MotionController.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp index feb9ead0..d28378d5 100644 --- a/src/components/motion/MotionController.cpp +++ b/src/components/motion/MotionController.cpp @@ -115,6 +115,20 @@ bool MotionController::ShouldShakeWake(uint16_t thresh) { return accumulatedSpeed > thresh; } +bool MotionController::ShouldLowerSleep() const { + if (stats.yMean < 724 || DegreesRolled(stats.yMean, stats.zMean, stats.prevYMean, stats.prevZMean) < 30) { + return false; + } + + for (uint8_t i = AccelStats::numHistory + 1; i < yHistory.Size(); i++) { + if (yHistory[i] < 265) { + return false; + } + } + + return true; +} + void MotionController::Init(Pinetime::Drivers::Bma421::DeviceTypes types) { switch (types) { case Drivers::Bma421::DeviceTypes::BMA421: |
