diff options
| author | JF002 <JF002@users.noreply.github.com> | 2021-02-14 14:26:49 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-14 14:26:49 +0100 |
| commit | 0ad10a381772f97cb227fba9e1121a833c5bd026 (patch) | |
| tree | 6883f02d33cc22f539c73728bcd732cd5254c8c7 /src/components/motor/MotorController.cpp | |
| parent | 6c03c970056c2aee833bfd195dcd9ca28520d37b (diff) | |
| parent | 97a1c4b3d7be04ddb24fea096add41b44629a5f9 (diff) | |
Merge branch 'develop' into Hrs3300_SetGain_remove_warnings
Diffstat (limited to 'src/components/motor/MotorController.cpp')
| -rw-r--r-- | src/components/motor/MotorController.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/components/motor/MotorController.cpp b/src/components/motor/MotorController.cpp new file mode 100644 index 00000000..7f53fbf7 --- /dev/null +++ b/src/components/motor/MotorController.cpp @@ -0,0 +1,25 @@ +#include "MotorController.h" +#include <hal/nrf_gpio.h> +#include "systemtask/SystemTask.h" +#include "app_timer.h" + +APP_TIMER_DEF(vibTimer); + +using namespace Pinetime::Controllers; + +void MotorController::Init() { + nrf_gpio_cfg_output(pinMotor); + nrf_gpio_pin_set(pinMotor); + app_timer_init(); + app_timer_create(&vibTimer, APP_TIMER_MODE_SINGLE_SHOT, vibrate); +} + +void MotorController::SetDuration(uint8_t motorDuration) { + nrf_gpio_pin_clear(pinMotor); + /* Start timer for motorDuration miliseconds and timer triggers vibrate() when it finishes*/ + app_timer_start(vibTimer, APP_TIMER_TICKS(motorDuration), NULL); +} + +void MotorController::vibrate(void * p_context) { + nrf_gpio_pin_set(pinMotor); +}
\ No newline at end of file |
