aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/motor/MotorController.cpp
diff options
context:
space:
mode:
authorJF002 <JF002@users.noreply.github.com>2021-02-14 14:26:49 +0100
committerGitHub <noreply@github.com>2021-02-14 14:26:49 +0100
commit0ad10a381772f97cb227fba9e1121a833c5bd026 (patch)
tree6883f02d33cc22f539c73728bcd732cd5254c8c7 /src/components/motor/MotorController.cpp
parent6c03c970056c2aee833bfd195dcd9ca28520d37b (diff)
parent97a1c4b3d7be04ddb24fea096add41b44629a5f9 (diff)
Merge branch 'develop' into Hrs3300_SetGain_remove_warnings
Diffstat (limited to 'src/components/motor/MotorController.cpp')
-rw-r--r--src/components/motor/MotorController.cpp25
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