aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/motion
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/motion')
-rw-r--r--src/components/motion/MotionController.cpp14
-rw-r--r--src/components/motion/MotionController.h1
2 files changed, 15 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:
diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h
index 1ad032b8..0aa7823e 100644
--- a/src/components/motion/MotionController.h
+++ b/src/components/motion/MotionController.h
@@ -46,6 +46,7 @@ namespace Pinetime {
bool ShouldShakeWake(uint16_t thresh);
bool ShouldRaiseWake() const;
+ bool ShouldLowerSleep() const;
int32_t CurrentShakeSpeed() const {
return accumulatedSpeed;