summaryrefslogtreecommitdiff
path: root/src/components/motor/MotorController.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/motor/MotorController.cpp')
-rw-r--r--src/components/motor/MotorController.cpp11
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() {