Fix merge conflict.

This commit is contained in:
Jean-François Milants 2021-02-14 14:19:30 +01:00
commit 5fdfb2112e
10 changed files with 80 additions and 7 deletions

View File

@ -21,6 +21,7 @@ RUN apt-get update -qq \
&& rm -rf /var/cache/apt/* /var/lib/apt/lists/*; && rm -rf /var/cache/apt/* /var/lib/apt/lists/*;
RUN pip3 install adafruit-nrfutil RUN pip3 install adafruit-nrfutil
RUN pip3 install -Iv cryptography==3.3
# build.sh knows how to compile # build.sh knows how to compile
COPY build.sh /opt/ COPY build.sh /opt/

View File

@ -36,10 +36,12 @@ set(SDK_SOURCE_FILES
# Base SDK # Base SDK
"${NRF5_SDK_PATH}/components/boards/boards.c" "${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.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_clock.c"
"${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_gpiote.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/soc/nrfx_atomic.c"
"${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_saadc.c" "${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_saadc.c"
"${NRF5_SDK_PATH}/components/libraries/timer/app_timer.h"
# FreeRTOS # FreeRTOS
${NRF5_SDK_PATH}/external/freertos/source/croutine.c ${NRF5_SDK_PATH}/external/freertos/source/croutine.c
@ -468,6 +470,7 @@ list(APPEND SOURCE_FILES
components/ble/ServiceDiscovery.cpp components/ble/ServiceDiscovery.cpp
components/ble/HeartRateService.cpp components/ble/HeartRateService.cpp
components/firmwarevalidator/FirmwareValidator.cpp components/firmwarevalidator/FirmwareValidator.cpp
components/motor/MotorController.cpp
drivers/Cst816s.cpp drivers/Cst816s.cpp
FreeRTOS/port.c FreeRTOS/port.c
FreeRTOS/port_cmsis_systick.c FreeRTOS/port_cmsis_systick.c
@ -577,6 +580,7 @@ set(INCLUDE_FILES
components/heartrate/Biquad.h components/heartrate/Biquad.h
components/heartrate/Ptagc.h components/heartrate/Ptagc.h
components/heartrate/HeartRateController.h components/heartrate/HeartRateController.h
components/motor/MotorController.h
) )
include_directories( include_directories(

View File

@ -71,6 +71,14 @@ bool NotificationManager::AreNewNotificationsAvailable() {
return newNotification; return newNotification;
} }
bool NotificationManager::IsVibrationEnabled() {
return vibrationEnabled;
}
void NotificationManager::ToggleVibrations() {
vibrationEnabled = !vibrationEnabled;
}
bool NotificationManager::ClearNewNotificationFlag() { bool NotificationManager::ClearNewNotificationFlag() {
return newNotification.exchange(false); return newNotification.exchange(false);
} }

View File

@ -28,6 +28,8 @@ namespace Pinetime {
Notification GetPrevious(Notification::Id id); Notification GetPrevious(Notification::Id id);
bool ClearNewNotificationFlag(); bool ClearNewNotificationFlag();
bool AreNewNotificationsAvailable(); bool AreNewNotificationsAvailable();
bool IsVibrationEnabled();
void ToggleVibrations();
static constexpr size_t MaximumMessageSize() { return MessageSize; }; static constexpr size_t MaximumMessageSize() { return MessageSize; };
size_t NbNotifications() const; size_t NbNotifications() const;
@ -40,6 +42,7 @@ namespace Pinetime {
uint8_t writeIndex = 0; uint8_t writeIndex = 0;
bool empty = true; bool empty = true;
std::atomic<bool> newNotification{false}; std::atomic<bool> newNotification{false};
bool vibrationEnabled = true;
}; };
} }
} }

View File

@ -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);
}

View File

@ -0,0 +1,19 @@
#pragma once
#include <cstdint>
#include "app_timer.h"
namespace Pinetime {
namespace Controllers {
static constexpr uint8_t pinMotor = 16;
class MotorController {
public:
void Init();
void SetDuration(uint8_t motorDuration);
private:
static void vibrate(void * p_context);
};
}
}

View File

@ -41,7 +41,6 @@ Notifications::Notifications(DisplayApp *app,
style_line.line.width = 3; style_line.line.width = 3;
style_line.line.rounded = 0; style_line.line.rounded = 0;
timeoutLine = lv_line_create(lv_scr_act(), nullptr); timeoutLine = lv_line_create(lv_scr_act(), nullptr);
lv_line_set_style(timeoutLine, LV_LINE_STYLE_MAIN, &style_line); lv_line_set_style(timeoutLine, LV_LINE_STYLE_MAIN, &style_line);
lv_line_set_points(timeoutLine, timeoutLinePoints, 2); lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
@ -119,6 +118,10 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
alertNotificationService)); alertNotificationService));
} }
return true; return true;
case Pinetime::Applications::TouchEvents::LongTap: {
notificationManager.ToggleVibrations();
return true;
}
default: default:
return false; return false;
} }
@ -135,7 +138,7 @@ namespace {
auto* item = static_cast<Notifications::NotificationItem *>(obj->user_data); auto* item = static_cast<Notifications::NotificationItem *>(obj->user_data);
item->OnAcceptIncomingCall(event); item->OnAcceptIncomingCall(event);
} }
static void MuteIncomingCallEventHandler(lv_obj_t *obj, lv_event_t event) { static void MuteIncomingCallEventHandler(lv_obj_t *obj, lv_event_t event) {
auto* item = static_cast<Notifications::NotificationItem *>(obj->user_data); auto* item = static_cast<Notifications::NotificationItem *>(obj->user_data);
item->OnMuteIncomingCall(event); item->OnMuteIncomingCall(event);
@ -247,7 +250,7 @@ Notifications::NotificationItem::NotificationItem(const char *title,
lv_obj_align(bt_reject, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, -20); lv_obj_align(bt_reject, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, -20);
label_reject = lv_label_create(bt_reject, nullptr); label_reject = lv_label_create(bt_reject, nullptr);
lv_label_set_text(label_reject, Symbols::phoneSlash); lv_label_set_text(label_reject, Symbols::phoneSlash);
bt_mute = lv_btn_create(container1, nullptr); bt_mute = lv_btn_create(container1, nullptr);
bt_mute->user_data = this; bt_mute->user_data = this;
lv_obj_set_event_cb(bt_mute, MuteIncomingCallEventHandler); lv_obj_set_event_cb(bt_mute, MuteIncomingCallEventHandler);

View File

@ -30,6 +30,7 @@
#include "components/battery/BatteryController.h" #include "components/battery/BatteryController.h"
#include "components/ble/BleController.h" #include "components/ble/BleController.h"
#include "components/ble/NotificationManager.h" #include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h"
#include "components/datetime/DateTimeController.h" #include "components/datetime/DateTimeController.h"
#include "displayapp/DisplayApp.h" #include "displayapp/DisplayApp.h"
#include "displayapp/LittleVgl.h" #include "displayapp/LittleVgl.h"
@ -98,6 +99,8 @@ void ble_manager_set_ble_disconnection_callback(void (*disconnection)());
static constexpr uint8_t pinTouchIrq = 28; static constexpr uint8_t pinTouchIrq = 28;
std::unique_ptr<Pinetime::System::SystemTask> systemTask; std::unique_ptr<Pinetime::System::SystemTask> systemTask;
Pinetime::Controllers::MotorController motorController;
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
if(pin == pinTouchIrq) { if(pin == pinTouchIrq) {
systemTask->OnTouchEvent(); systemTask->OnTouchEvent();
@ -239,7 +242,7 @@ int main(void) {
debounceTimer = xTimerCreate ("debounceTimer", 200, pdFALSE, (void *) 0, DebounceTimerCallback); debounceTimer = xTimerCreate ("debounceTimer", 200, pdFALSE, (void *) 0, DebounceTimerCallback);
systemTask.reset(new Pinetime::System::SystemTask(spi, lcd, spiNorFlash, twiMaster, touchPanel, lvgl, batteryController, bleController, systemTask.reset(new Pinetime::System::SystemTask(spi, lcd, spiNorFlash, twiMaster, touchPanel, lvgl, batteryController, bleController,
dateTimeController, heartRateSensor)); dateTimeController, motorController, heartRateSensor));
systemTask->Start(); systemTask->Start();
nimble_port_init(); nimble_port_init();

View File

@ -40,13 +40,14 @@ SystemTask::SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd,
Components::LittleVgl &lvgl, Components::LittleVgl &lvgl,
Controllers::Battery &batteryController, Controllers::Ble &bleController, Controllers::Battery &batteryController, Controllers::Ble &bleController,
Controllers::DateTime &dateTimeController, Controllers::DateTime &dateTimeController,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Drivers::Hrs3300& heartRateSensor) : Pinetime::Drivers::Hrs3300& heartRateSensor) :
spi{spi}, lcd{lcd}, spiNorFlash{spiNorFlash}, spi{spi}, lcd{lcd}, spiNorFlash{spiNorFlash},
twiMaster{twiMaster}, touchPanel{touchPanel}, lvgl{lvgl}, batteryController{batteryController}, twiMaster{twiMaster}, touchPanel{touchPanel}, lvgl{lvgl}, batteryController{batteryController},
heartRateController{*this}, heartRateController{*this},
bleController{bleController}, dateTimeController{dateTimeController}, bleController{bleController}, dateTimeController{dateTimeController},
watchdog{}, watchdogView{watchdog}, watchdog{}, watchdogView{watchdog},
heartRateSensor{heartRateSensor}, motorController{motorController}, heartRateSensor{heartRateSensor},
nimbleController(*this, bleController,dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController) { nimbleController(*this, bleController,dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController) {
systemTasksMsgQueue = xQueueCreate(10, 1); systemTasksMsgQueue = xQueueCreate(10, 1);
} }
@ -78,15 +79,17 @@ void SystemTask::Work() {
twiMaster.Init(); twiMaster.Init();
touchPanel.Init(); touchPanel.Init();
batteryController.Init(); batteryController.Init();
motorController.Init();
displayApp.reset(new Pinetime::Applications::DisplayApp(lcd, lvgl, touchPanel, batteryController, bleController, displayApp.reset(new Pinetime::Applications::DisplayApp(lcd, lvgl, touchPanel, batteryController, bleController,
dateTimeController, watchdogView, *this, notificationManager, heartRateController)); dateTimeController, watchdogView, *this, notificationManager,
heartRateController));
displayApp->Start(); displayApp->Start();
batteryController.Update(); batteryController.Update();
displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateBatteryLevel); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateBatteryLevel);
heartRateSensor.Init(); heartRateSensor.Init();
heartRateSensor.Disable(); heartRateSensor.Disable();
heartRateApp.reset(new Pinetime::Applications::HeartRateTask(heartRateSensor, heartRateController)); heartRateApp.reset(new Pinetime::Applications::HeartRateTask(heartRateSensor, heartRateController));
@ -158,6 +161,7 @@ void SystemTask::Work() {
break; break;
case Messages::OnNewNotification: case Messages::OnNewNotification:
if(isSleeping && !isWakingUp) GoToRunning(); if(isSleeping && !isWakingUp) GoToRunning();
if(notificationManager.IsVibrationEnabled()) motorController.SetDuration(35);
displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::NewNotification); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::NewNotification);
break; break;
case Messages::BleConnected: case Messages::BleConnected:

View File

@ -12,6 +12,7 @@
#include "components/battery/BatteryController.h" #include "components/battery/BatteryController.h"
#include "components/ble/NimbleController.h" #include "components/ble/NimbleController.h"
#include "components/ble/NotificationManager.h" #include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h"
#include "displayapp/DisplayApp.h" #include "displayapp/DisplayApp.h"
#include "drivers/Watchdog.h" #include "drivers/Watchdog.h"
@ -37,6 +38,7 @@ namespace Pinetime {
Components::LittleVgl &lvgl, Components::LittleVgl &lvgl,
Controllers::Battery &batteryController, Controllers::Ble &bleController, Controllers::Battery &batteryController, Controllers::Ble &bleController,
Controllers::DateTime &dateTimeController, Controllers::DateTime &dateTimeController,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Drivers::Hrs3300& heartRateSensor); Pinetime::Drivers::Hrs3300& heartRateSensor);
@ -73,6 +75,7 @@ namespace Pinetime {
Pinetime::Drivers::Watchdog watchdog; Pinetime::Drivers::Watchdog watchdog;
Pinetime::Drivers::WatchdogView watchdogView; Pinetime::Drivers::WatchdogView watchdogView;
Pinetime::Controllers::NotificationManager notificationManager; Pinetime::Controllers::NotificationManager notificationManager;
Pinetime::Controllers::MotorController& motorController;
Pinetime::Drivers::Hrs3300& heartRateSensor; Pinetime::Drivers::Hrs3300& heartRateSensor;
Pinetime::Controllers::NimbleController nimbleController; Pinetime::Controllers::NimbleController nimbleController;