summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/components/motor/MotorController.cpp39
-rw-r--r--src/components/motor/MotorController.h20
-rw-r--r--src/displayapp/screens/Notifications.cpp4
-rw-r--r--src/displayapp/screens/Notifications.h2
5 files changed, 69 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5955d393..1a8887e2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -36,10 +36,12 @@ set(SDK_SOURCE_FILES
# Base SDK
"${NRF5_SDK_PATH}/components/boards/boards.c"
"${NRF5_SDK_PATH}/integration/nrfx/legacy/nrf_drv_clock.c"
+ "${NRF5_SDK_PATH}/integration/nrfx/legacy/nrf_drv_clock.h"
"${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_clock.c"
"${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_gpiote.c"
"${NRF5_SDK_PATH}/modules/nrfx/soc/nrfx_atomic.c"
"${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_saadc.c"
+ "${NRF5_SDK_PATH}/components/libraries/timer/app_timer.h"
# FreeRTOS
${NRF5_SDK_PATH}/external/freertos/source/croutine.c
@@ -469,6 +471,7 @@ list(APPEND SOURCE_FILES
components/ble/ServiceDiscovery.cpp
components/ble/HeartRateService.cpp
components/firmwarevalidator/FirmwareValidator.cpp
+ components/motor/MotorController.cpp
drivers/Cst816s.cpp
FreeRTOS/port.c
FreeRTOS/port_cmsis_systick.c
@@ -579,6 +582,7 @@ set(INCLUDE_FILES
components/heartrate/Biquad.h
components/heartrate/Ptagc.h
components/heartrate/HeartRateController.h
+ components/motor/MotorController.h
)
include_directories(
diff --git a/src/components/motor/MotorController.cpp b/src/components/motor/MotorController.cpp
new file mode 100644
index 00000000..738e6d33
--- /dev/null
+++ b/src/components/motor/MotorController.cpp
@@ -0,0 +1,39 @@
+#include "MotorController.h"
+#include <hal/nrf_gpio.h>
+#include "systemtask/SystemTask.h"
+#include "app_timer.h"
+#include "nrf_drv_clock.h"
+
+
+using namespace Pinetime::Controllers;
+
+static void lfclk_request(void) //get the low freq. clock
+{
+ nrf_drv_clock_init();
+ nrf_drv_clock_lfclk_request(NULL);
+}
+
+void vibrateTimer(void * p_context)
+{
+ nrf_gpio_pin_set(pinMotor);
+}
+
+static void create_timers()
+{
+ //create timer, single shot, re-armable
+ app_timer_create(&vibTimer, APP_TIMER_MODE_SINGLE_SHOT, vibrateTimer);
+}
+
+void MotorController::Init() {
+ nrf_gpio_cfg_output(pinMotor); // set the motor pin as an output
+ nrf_gpio_pin_set(pinMotor);
+ lfclk_request(); //get lfclock ready
+ app_timer_init(); //start app timers to make calls
+ create_timers();
+}
+
+void MotorController::SetDuration(uint8_t motorDuration) {
+ nrf_gpio_pin_clear(pinMotor);
+ //start timer for motorDuration miliseconds
+ app_timer_start(vibTimer, APP_TIMER_TICKS(motorDuration), NULL); //timers trigger at end of duration?
+} \ No newline at end of file
diff --git a/src/components/motor/MotorController.h b/src/components/motor/MotorController.h
new file mode 100644
index 00000000..01fe9304
--- /dev/null
+++ b/src/components/motor/MotorController.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include <cstdint>
+
+namespace Pinetime {
+ namespace Controllers {
+ static constexpr uint8_t pinMotor = 16;
+
+ class MotorController {
+ public:
+ void Init();
+ void SetDuration(uint8_t motorDuration);
+
+ APP_TIMER_DEF(vibTimer);
+
+ private:
+
+ };
+ }
+} \ No newline at end of file
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index 51a601c4..cfcecec2 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -7,6 +7,9 @@ Notifications::Notifications(DisplayApp *app, Pinetime::Controllers::Notificatio
Screen(app), notificationManager{notificationManager}, mode{mode} {
notificationManager.ClearNewNotificationFlag();
auto notification = notificationManager.GetLastNotification();
+
+ motorController.Init(); //start the vibration timer setups
+
if(notification.valid) {
currentId = notification.id;
currentItem.reset(new NotificationItem("\nNotification", notification.message.data(), notification.index, notificationManager.NbNotifications(), mode));
@@ -22,6 +25,7 @@ Notifications::Notifications(DisplayApp *app, Pinetime::Controllers::Notificatio
style_line.line.width = 3;
style_line.line.rounded = 0;
+ motorController.SetDuration(35);
timeoutLine = lv_line_create(lv_scr_act(), nullptr);
lv_line_set_style(timeoutLine, LV_LINE_STYLE_MAIN, &style_line);
diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h
index f5c6a860..345ad15a 100644
--- a/src/displayapp/screens/Notifications.h
+++ b/src/displayapp/screens/Notifications.h
@@ -5,6 +5,7 @@
#include <memory>
#include "Screen.h"
#include "components/ble/NotificationManager.h"
+#include "components/motor/MotorController.h"
namespace Pinetime {
namespace Applications {
@@ -45,6 +46,7 @@ namespace Pinetime {
const char* text;
};
Pinetime::Controllers::NotificationManager& notificationManager;
+ Pinetime::Controllers::MotorController motorController;
Modes mode = Modes::Normal;
std::unique_ptr<NotificationItem> currentItem;
Controllers::NotificationManager::Notification::Id currentId;