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.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/components/motor/MotorController.cpp b/src/components/motor/MotorController.cpp
index 6eff2ee..547d87b 100644
--- a/src/components/motor/MotorController.cpp
+++ b/src/components/motor/MotorController.cpp
@@ -14,30 +14,25 @@ void MotorController::Init() {
nrf_gpio_pin_set(PinMap::Motor);
shortVibTimer = xTimerCreate("shortVibTm", 1, pdFALSE, nullptr, StopMotor);
- longVibTimer = xTimerCreate("longVibTm", APP_TIMER_TICKS(1000), pdTRUE, this, Ring);
+ longVibTimer = xTimerCreate("longVibTm", 1, pdTRUE, this, Ring);
}
void MotorController::Ring(TimerHandle_t xTimer) {
auto motorController = static_cast<MotorController*>(pvTimerGetTimerID(xTimer));
-
+ xTimerChangePeriod(motorController->longVibTimer, APP_TIMER_TICKS(1000), 0);
motorController->RunForDuration(50);
}
void MotorController::RunForDuration(uint8_t motorDuration) {
- nrf_gpio_pin_clear(PinMap::Motor);
if (xTimerChangePeriod(shortVibTimer, APP_TIMER_TICKS(motorDuration), 0) == pdPASS
&& xTimerStart(shortVibTimer, 0) == pdPASS) {
- return;
+ nrf_gpio_pin_clear(PinMap::Motor);
}
- nrf_gpio_pin_set(PinMap::Motor);
}
void MotorController::StartRinging() {
- if (xTimerChangePeriod(longVibTimer, APP_TIMER_TICKS(1000), 0) == pdPASS
- && xTimerStart(longVibTimer, 0) == pdPASS) {
- return;
- }
- Ring(this);
+ xTimerChangePeriod(longVibTimer, 1, 0);
+ xTimerStart(longVibTimer, 0);
}
void MotorController::StopRinging() {