diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-04-09 16:47:37 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-04-09 16:49:44 (GMT) |
| commit | 42d0d1ad338c55ca44f7f4cbb880c40e293b0d5c (patch) | |
| tree | d580a2d098d2a96f565d48ac1fcd90e59d34b5eb /src/components | |
| parent | 4d9c76afdacddb1f766c74789f49f3dc96aead9a (diff) | |
Integrate FintasticMan's RaiseWake and LowerToSleep mods
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/motion/MotionController.cpp | 28 | ||||
| -rw-r--r-- | src/components/motion/MotionController.h | 15 | ||||
| -rw-r--r-- | src/components/settings/Settings.h | 6 |
3 files changed, 21 insertions, 28 deletions
diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp index 7dd3212..c57d8aa 100644 --- a/src/components/motion/MotionController.cpp +++ b/src/components/motion/MotionController.cpp @@ -11,6 +11,7 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps) service->OnNewMotionValues(x, y, z); } + lastY = this->y; this->x = x; this->y = y; this->z = z; @@ -21,27 +22,8 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps) } } -bool MotionController::Should_RaiseWake(bool isSleeping) { - if ((x + 335) <= 670 && z < 0) { - if (not isSleeping) { - if (y <= 0) { - return false; - } else { - lastYForWakeUp = 0; - return false; - } - } - - if (y >= 0) { - lastYForWakeUp = 0; - return false; - } - if (y + 230 < lastYForWakeUp) { - lastYForWakeUp = y; - return true; - } - } - return false; +bool MotionController::ShouldRaiseWake() const { + return x >= -384 && x <= 384 && z <= 0 && y <= -160 && y <= lastY - 160; } bool MotionController::Should_ShakeWake(uint16_t thresh) { @@ -66,6 +48,10 @@ int32_t MotionController::currentShakeSpeed() { return accumulatedspeed; } +bool MotionController::ShouldLowerSleep() const { + return y >= 512 && y >= lastY + 192; +} + void MotionController::IsSensorOk(bool isOk) { isSensorOk = isOk; } diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h index f80b11b..297db59 100644 --- a/src/components/motion/MotionController.h +++ b/src/components/motion/MotionController.h @@ -25,6 +25,9 @@ namespace Pinetime { int16_t Z() const { return z; } + int16_t LastY() const { + return lastY; + } uint32_t NbSteps() const { return nbSteps; } @@ -36,9 +39,10 @@ namespace Pinetime { return currentTripSteps; } + bool ShouldRaiseWake() const; bool Should_ShakeWake(uint16_t thresh); - bool Should_RaiseWake(bool isSleeping); int32_t currentShakeSpeed(); + bool ShouldLowerSleep() const; void IsSensorOk(bool isOk); bool IsSensorOk() const { return isSensorOk; @@ -54,9 +58,10 @@ namespace Pinetime { private: uint32_t nbSteps; uint32_t currentTripSteps = 0; - int16_t x; - int16_t y; - int16_t z; + int16_t x = 0; + int16_t y = 0; + int16_t z = 0; + int16_t lastY = 0; int16_t lastYForWakeUp = 0; bool isSensorOk = false; DeviceTypes deviceType = DeviceTypes::Unknown; @@ -69,4 +74,4 @@ namespace Pinetime { uint32_t lastShakeTime = 0; }; } -}
\ No newline at end of file +} diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 44a1a85..34e1af4 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -16,6 +16,7 @@ namespace Pinetime { DoubleTap = 1, RaiseWrist = 2, Shake = 3, + LowerWrist = 4 }; enum class Colors : uint8_t { White, @@ -172,7 +173,7 @@ namespace Pinetime { } }; - std::bitset<4> getWakeUpModes() const { + std::bitset<5> getWakeUpModes() const { return settings.wakeUpMode; } @@ -227,8 +228,9 @@ namespace Pinetime { PineTimeStyle PTS; - std::bitset<4> wakeUpMode {0}; + std::bitset<5> wakeUpMode {0}; uint16_t shakeWakeThreshold = 150; + Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium; }; |
