diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-04-16 05:19:28 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-04-16 05:20:22 (GMT) |
| commit | 1d48a97f09104e6b26159622d1631c781498e6f3 (patch) | |
| tree | d3ce694b3e79549d7c2bccb975b308273410f536 /src/components/motor | |
| parent | c92fdb2e8cec3c581124c5efcfb5297ac4cfdcb5 (diff) | |
replace pdMS_TO_TICKS with APP_TIMER_TICKS; more tweaks
Diffstat (limited to 'src/components/motor')
| -rw-r--r-- | src/components/motor/MotorController.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/components/motor/MotorController.cpp b/src/components/motor/MotorController.cpp index a02c037..5ff549e 100644 --- a/src/components/motor/MotorController.cpp +++ b/src/components/motor/MotorController.cpp @@ -14,7 +14,7 @@ void MotorController::Init() { nrf_gpio_pin_set(PinMap::Motor); shortVibTimer = xTimerCreate("shortVibTm", 1, pdFALSE, nullptr, StopMotor); - longVibTimer = xTimerCreate("longVibTm", pdMS_TO_TICKS(1000), pdTRUE, this, Ring); + longVibTimer = xTimerCreate("longVibTm", APP_TIMER_TICKS(1000), pdTRUE, this, Ring); } void MotorController::Ring(TimerHandle_t xTimer) { @@ -24,11 +24,11 @@ void MotorController::Ring(TimerHandle_t xTimer) { void MotorController::RunForDuration(uint8_t motorDuration) { nrf_gpio_pin_clear(PinMap::Motor); - if (xTimerChangePeriod(shortVibTimer, pdMS_TO_TICKS(motorDuration), 0) == pdPASS + if (xTimerChangePeriod(shortVibTimer, APP_TIMER_TICKS(motorDuration), 0) == pdPASS && xTimerStart(shortVibTimer, 0) == pdPASS) { return; } - if (xTimerChangePeriodFromISR(shortVibTimer, pdMS_TO_TICKS(motorDuration), NULL) == pdPASS + if (xTimerChangePeriodFromISR(shortVibTimer, APP_TIMER_TICKS(motorDuration), NULL) == pdPASS && xTimerStartFromISR(shortVibTimer, NULL) == pdPASS) { return; } @@ -36,8 +36,11 @@ void MotorController::RunForDuration(uint8_t motorDuration) { } void MotorController::StartRinging() { + if (xTimerChangePeriod(longVibTimer, APP_TIMER_TICKS(1000), 0) == pdPASS + && xTimerStart(longVibTimer, 0) == pdPASS) { + return; + } Ring(this); - xTimerStart(longVibTimer, 0); } void MotorController::StopRinging() { |
