From f993311830df3ebe1d6ff4022aa3019a55f9bbd7 Mon Sep 17 00:00:00 2001 From: Finlay Davidson Date: Sun, 5 Mar 2023 14:53:49 +0100 Subject: [PATCH] shakewake: Fix names according to style guide --- src/components/motion/MotionController.cpp | 12 ++++-------- src/components/motion/MotionController.h | 12 ++++++++---- .../screens/settings/SettingShakeThreshold.cpp | 8 ++++---- src/systemtask/SystemTask.cpp | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp index 8ba46814..29b30e36 100644 --- a/src/components/motion/MotionController.cpp +++ b/src/components/motion/MotionController.cpp @@ -43,17 +43,17 @@ bool MotionController::Should_RaiseWake(bool isSleeping) { return false; } -bool MotionController::Should_ShakeWake(uint16_t thresh) { +bool MotionController::ShouldShakeWake(uint16_t thresh) { bool wake = false; auto diff = xTaskGetTickCount() - lastShakeTime; lastShakeTime = xTaskGetTickCount(); /* Currently Polling at 10hz, If this ever goes faster scalar and EMA might need adjusting */ int32_t speed = std::abs(z + (y / 2) + (x / 4) - lastYForShake - lastZForShake) / diff * 100; - //(.2 * speed) + ((1 - .2) * accumulatedspeed); + //(.2 * speed) + ((1 - .2) * accumulatedSpeed); // implemented without floats as .25Alpha - accumulatedspeed = (speed / 5) + ((accumulatedspeed / 5) * 4); + accumulatedSpeed = (speed / 5) + ((accumulatedSpeed / 5) * 4); - if (accumulatedspeed > thresh) { + if (accumulatedSpeed > thresh) { wake = true; } lastXForShake = x / 4; @@ -62,10 +62,6 @@ bool MotionController::Should_ShakeWake(uint16_t thresh) { return wake; } -int32_t MotionController::currentShakeSpeed() { - return accumulatedspeed; -} - void MotionController::IsSensorOk(bool isOk) { isSensorOk = isOk; } diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h index 857bd45a..9006b2a6 100644 --- a/src/components/motion/MotionController.h +++ b/src/components/motion/MotionController.h @@ -40,9 +40,13 @@ namespace Pinetime { return currentTripSteps; } - bool Should_ShakeWake(uint16_t thresh); + bool ShouldShakeWake(uint16_t thresh); bool Should_RaiseWake(bool isSleeping); - int32_t currentShakeSpeed(); + + int32_t CurrentShakeSpeed() const { + return accumulatedSpeed; + } + void IsSensorOk(bool isOk); bool IsSensorOk() const { @@ -70,8 +74,8 @@ namespace Pinetime { int16_t lastXForShake = 0; int16_t lastYForShake = 0; int16_t lastZForShake = 0; - int32_t accumulatedspeed = 0; + int32_t accumulatedSpeed = 0; uint32_t lastShakeTime = 0; }; } -} \ No newline at end of file +} diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.cpp b/src/displayapp/screens/settings/SettingShakeThreshold.cpp index f4b6f959..be67cc95 100644 --- a/src/displayapp/screens/settings/SettingShakeThreshold.cpp +++ b/src/displayapp/screens/settings/SettingShakeThreshold.cpp @@ -96,16 +96,16 @@ void SettingShakeThreshold::Refresh() { } if (calibrating == 2) { - if ((motionController.currentShakeSpeed() - 300) > lv_arc_get_value(positionArc)) { - lv_arc_set_value(positionArc, (int16_t) motionController.currentShakeSpeed() - 300); + if ((motionController.CurrentShakeSpeed() - 300) > lv_arc_get_value(positionArc)) { + lv_arc_set_value(positionArc, (int16_t) motionController.CurrentShakeSpeed() - 300); } if (xTaskGetTickCount() - vCalTime > pdMS_TO_TICKS(7500)) { lv_btn_set_state(calButton, LV_STATE_DEFAULT); lv_event_send(calButton, LV_EVENT_VALUE_CHANGED, nullptr); } } - if (motionController.currentShakeSpeed() - 300 > lv_arc_get_value(animArc)) { - lv_arc_set_value(animArc, (uint16_t) motionController.currentShakeSpeed() - 300); + if (motionController.CurrentShakeSpeed() - 300 > lv_arc_get_value(animArc)) { + lv_arc_set_value(animArc, (uint16_t) motionController.CurrentShakeSpeed() - 300); vDecay = xTaskGetTickCount(); } else if ((xTaskGetTickCount() - vDecay) > pdMS_TO_TICKS(1500)) { lv_arc_set_value(animArc, lv_arc_get_value(animArc) - 25); diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 07a85f5a..b81e7669 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -470,7 +470,7 @@ void SystemTask::UpdateMotion() { if ((settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist) && motionController.Should_RaiseWake(state == SystemTaskState::Sleeping)) || (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake) && - motionController.Should_ShakeWake(settingsController.GetShakeThreshold()))) { + motionController.ShouldShakeWake(settingsController.GetShakeThreshold()))) { GoToRunning(); } }