Merge pull request #415 from JF002/move-heap-to-static

Move dynamically allocated variables to static variables.
This commit is contained in:
JF002 2021-06-12 11:02:06 +02:00 committed by GitHub
commit 0ce98c7ac7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 313 additions and 211 deletions

View File

@ -750,8 +750,8 @@ add_definitions(-DNIMBLE_CFG_CONTROLLER)
add_definitions(-DOS_CPUTIME_FREQ) add_definitions(-DOS_CPUTIME_FREQ)
add_definitions(-DNRF52 -DNRF52832 -DNRF52832_XXAA -DNRF52_PAN_74 -DNRF52_PAN_64 -DNRF52_PAN_12 -DNRF52_PAN_58 -DNRF52_PAN_54 -DNRF52_PAN_31 -DNRF52_PAN_51 -DNRF52_PAN_36 -DNRF52_PAN_15 -DNRF52_PAN_20 -DNRF52_PAN_55 -DBOARD_PCA10040) add_definitions(-DNRF52 -DNRF52832 -DNRF52832_XXAA -DNRF52_PAN_74 -DNRF52_PAN_64 -DNRF52_PAN_12 -DNRF52_PAN_58 -DNRF52_PAN_54 -DNRF52_PAN_31 -DNRF52_PAN_51 -DNRF52_PAN_36 -DNRF52_PAN_15 -DNRF52_PAN_20 -DNRF52_PAN_55 -DBOARD_PCA10040)
add_definitions(-DFREERTOS) add_definitions(-DFREERTOS)
add_definitions(-D__STACK_SIZE=8192) add_definitions(-D__STACK_SIZE=1024)
add_definitions(-D__HEAP_SIZE=8192) add_definitions(-D__HEAP_SIZE=4096)
# NOTE : Add the following defines to enable debug mode of the NRF SDK: # NOTE : Add the following defines to enable debug mode of the NRF SDK:
#add_definitions(-DDEBUG) #add_definitions(-DDEBUG)

View File

@ -62,7 +62,7 @@
#define configTICK_RATE_HZ 1024 #define configTICK_RATE_HZ 1024
#define configMAX_PRIORITIES (3) #define configMAX_PRIORITIES (3)
#define configMINIMAL_STACK_SIZE (120) #define configMINIMAL_STACK_SIZE (120)
#define configTOTAL_HEAP_SIZE (1024 * 16) #define configTOTAL_HEAP_SIZE (1024 * 17)
#define configMAX_TASK_NAME_LEN (4) #define configMAX_TASK_NAME_LEN (4)
#define configUSE_16_BIT_TICKS 0 #define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1 #define configIDLE_SHOULD_YIELD 1

View File

@ -159,7 +159,7 @@ void AlertNotificationClient::OnNotification(ble_gap_event* event) {
notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert; notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
notificationManager.Push(std::move(notif)); notificationManager.Push(std::move(notif));
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::OnNewNotification); systemTask.PushMessage(Pinetime::System::Messages::OnNewNotification);
} }
} }

View File

@ -79,7 +79,7 @@ int AlertNotificationService::OnAlert(uint16_t conn_handle, uint16_t attr_handle
break; break;
} }
auto event = Pinetime::System::SystemTask::Messages::OnNewNotification; auto event = Pinetime::System::Messages::OnNewNotification;
notificationManager.Push(std::move(notif)); notificationManager.Push(std::move(notif));
systemTask.PushMessage(event); systemTask.PushMessage(event);
} }

View File

@ -205,7 +205,7 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) {
bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Running); bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Running);
bleController.FirmwareUpdateTotalBytes(0xffffffffu); bleController.FirmwareUpdateTotalBytes(0xffffffffu);
bleController.FirmwareUpdateCurrentBytes(0); bleController.FirmwareUpdateCurrentBytes(0);
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleFirmwareUpdateStarted); systemTask.PushMessage(Pinetime::System::Messages::BleFirmwareUpdateStarted);
return 0; return 0;
} else { } else {
NRF_LOG_INFO("[DFU] -> Start DFU, mode %d not supported!", imageType); NRF_LOG_INFO("[DFU] -> Start DFU, mode %d not supported!", imageType);
@ -279,7 +279,7 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) {
} }
NRF_LOG_INFO("[DFU] -> Activate image and reset!"); NRF_LOG_INFO("[DFU] -> Activate image and reset!");
bleController.StopFirmwareUpdate(); bleController.StopFirmwareUpdate();
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleFirmwareUpdateFinished); systemTask.PushMessage(Pinetime::System::Messages::BleFirmwareUpdateFinished);
Reset(); Reset();
bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated); bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated);
return 0; return 0;
@ -304,7 +304,7 @@ void DfuService::Reset() {
notificationManager.Reset(); notificationManager.Reset();
bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error); bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error);
bleController.StopFirmwareUpdate(); bleController.StopFirmwareUpdate();
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleFirmwareUpdateFinished); systemTask.PushMessage(Pinetime::System::Messages::BleFirmwareUpdateFinished);
} }
DfuService::NotificationManager::NotificationManager() { DfuService::NotificationManager::NotificationManager() {

View File

@ -67,7 +67,7 @@ int ImmediateAlertService::OnAlertLevelChanged(uint16_t connectionHandle, uint16
notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert; notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
notificationManager.Push(std::move(notif)); notificationManager.Push(std::move(notif));
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::OnNewNotification); systemTask.PushMessage(Pinetime::System::Messages::OnNewNotification);
} }
} }

View File

@ -149,7 +149,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
bleController.Disconnect(); bleController.Disconnect();
} else { } else {
bleController.Connect(); bleController.Connect();
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleConnected); systemTask.PushMessage(Pinetime::System::Messages::BleConnected);
connectionHandle = event->connect.conn_handle; connectionHandle = event->connect.conn_handle;
// Service discovery is deffered via systemtask // Service discovery is deffered via systemtask
} }

View File

@ -5,9 +5,6 @@
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;
DateTime::DateTime(System::SystemTask& systemTask) : systemTask {systemTask} {
}
void DateTime::SetTime( void DateTime::SetTime(
uint16_t year, uint8_t month, uint8_t day, uint8_t dayOfWeek, uint8_t hour, uint8_t minute, uint8_t second, uint32_t systickCounter) { uint16_t year, uint8_t month, uint8_t day, uint8_t dayOfWeek, uint8_t hour, uint8_t minute, uint8_t second, uint32_t systickCounter) {
std::tm tm = { std::tm tm = {
@ -70,7 +67,8 @@ void DateTime::UpdateTime(uint32_t systickCounter) {
// Notify new day to SystemTask // Notify new day to SystemTask
if (hour == 0 and not isMidnightAlreadyNotified) { if (hour == 0 and not isMidnightAlreadyNotified) {
isMidnightAlreadyNotified = true; isMidnightAlreadyNotified = true;
systemTask.PushMessage(System::SystemTask::Messages::OnNewDay); if(systemTask != nullptr)
systemTask->PushMessage(System::Messages::OnNewDay);
} else if (hour != 0) { } else if (hour != 0) {
isMidnightAlreadyNotified = false; isMidnightAlreadyNotified = false;
} }
@ -104,6 +102,10 @@ const char* DateTime::DayOfWeekShortToStringLow() {
return DateTime::DaysStringShortLow[(uint8_t) dayOfWeek]; return DateTime::DaysStringShortLow[(uint8_t) dayOfWeek];
} }
void DateTime::Register(Pinetime::System::SystemTask* systemTask) {
this->systemTask = systemTask;
}
char const* DateTime::DaysStringLow[] = {"--", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; char const* DateTime::DaysStringLow[] = {"--", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
char const* DateTime::DaysStringShortLow[] = {"--", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; char const* DateTime::DaysStringShortLow[] = {"--", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};

View File

@ -27,8 +27,6 @@ namespace Pinetime {
December December
}; };
DateTime(System::SystemTask& systemTask);
void SetTime(uint16_t year, void SetTime(uint16_t year,
uint8_t month, uint8_t month,
uint8_t day, uint8_t day,
@ -75,8 +73,9 @@ namespace Pinetime {
return uptime; return uptime;
} }
void Register(System::SystemTask* systemTask);
private: private:
System::SystemTask& systemTask;
uint16_t year = 0; uint16_t year = 0;
Months month = Months::Unknown; Months month = Months::Unknown;
uint8_t day = 0; uint8_t day = 0;
@ -90,6 +89,7 @@ namespace Pinetime {
std::chrono::seconds uptime {0}; std::chrono::seconds uptime {0};
bool isMidnightAlreadyNotified = false; bool isMidnightAlreadyNotified = false;
System::SystemTask* systemTask = nullptr;
static char const* DaysString[]; static char const* DaysString[];
static char const* DaysStringShort[]; static char const* DaysStringShort[];

View File

@ -4,9 +4,6 @@
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;
HeartRateController::HeartRateController(Pinetime::System::SystemTask& systemTask) : systemTask {systemTask} {
}
void HeartRateController::Update(HeartRateController::States newState, uint8_t heartRate) { void HeartRateController::Update(HeartRateController::States newState, uint8_t heartRate) {
this->state = newState; this->state = newState;
if (this->heartRate != heartRate) { if (this->heartRate != heartRate) {

View File

@ -15,8 +15,7 @@ namespace Pinetime {
public: public:
enum class States { Stopped, NotEnoughData, NoTouch, Running }; enum class States { Stopped, NotEnoughData, NoTouch, Running };
explicit HeartRateController(System::SystemTask& systemTask); HeartRateController() = default;
void Start(); void Start();
void Stop(); void Stop();
void Update(States newState, uint8_t heartRate); void Update(States newState, uint8_t heartRate);
@ -32,7 +31,6 @@ namespace Pinetime {
void SetService(Pinetime::Controllers::HeartRateService* service); void SetService(Pinetime::Controllers::HeartRateService* service);
private: private:
System::SystemTask& systemTask;
Applications::HeartRateTask* task = nullptr; Applications::HeartRateTask* task = nullptr;
States state = States::Stopped; States state = States::Stopped;
uint8_t heartRate = 0; uint8_t heartRate = 0;

View File

@ -38,9 +38,8 @@ namespace {
} }
} }
Ppg::Ppg(float spl) Ppg::Ppg()
: offset {spl}, : hpf {0.87033078, -1.74066156, 0.87033078, -1.72377617, 0.75754694},
hpf {0.87033078, -1.74066156, 0.87033078, -1.72377617, 0.75754694},
agc {20, 0.971, 2}, agc {20, 0.971, 2},
lpf {0.11595249, 0.23190498, 0.11595249, -0.72168143, 0.18549138} { lpf {0.11595249, 0.23190498, 0.11595249, -0.72168143, 0.18549138} {
} }
@ -67,13 +66,7 @@ float Ppg::HeartRate() {
dataIndex = 0; dataIndex = 0;
return hr; return hr;
} }
int cccount = 0;
float Ppg::ProcessHeartRate() { float Ppg::ProcessHeartRate() {
if (cccount > 2)
asm("nop");
cccount++;
auto t0 = Trough(data.data(), dataIndex, 7, 48); auto t0 = Trough(data.data(), dataIndex, 7, 48);
if (t0 < 0) if (t0 < 0)
return 0; return 0;

View File

@ -8,8 +8,7 @@ namespace Pinetime {
namespace Controllers { namespace Controllers {
class Ppg { class Ppg {
public: public:
explicit Ppg(float spl); Ppg();
int8_t Preprocess(float spl); int8_t Preprocess(float spl);
float HeartRate(); float HeartRate();

View File

@ -12,14 +12,17 @@ using namespace Pinetime::Controllers;
APP_TIMER_DEF(timerAppTimer); APP_TIMER_DEF(timerAppTimer);
namespace {
TimerController::TimerController(System::SystemTask& systemTask) : systemTask{systemTask} { void TimerEnd(void* p_context) {
auto* controller = static_cast<Pinetime::Controllers::TimerController*> (p_context);
if(controller != nullptr)
controller->OnTimerEnd();
}
} }
void TimerController::Init() { void TimerController::Init() {
app_timer_create(&timerAppTimer, APP_TIMER_MODE_SINGLE_SHOT, timerEnd); app_timer_create(&timerAppTimer, APP_TIMER_MODE_SINGLE_SHOT, TimerEnd);
} }
void TimerController::StartTimer(uint32_t duration) { void TimerController::StartTimer(uint32_t duration) {
@ -47,13 +50,6 @@ uint32_t TimerController::GetTimeRemaining() {
return (static_cast<TickType_t>(deltaTicks) / static_cast<TickType_t>(configTICK_RATE_HZ)) * 1000; return (static_cast<TickType_t>(deltaTicks) / static_cast<TickType_t>(configTICK_RATE_HZ)) * 1000;
} }
void TimerController::timerEnd(void* p_context) {
auto* controller = static_cast<Controllers::TimerController*> (p_context);
controller->timerRunning = false;
controller->systemTask.PushMessage(System::SystemTask::Messages::OnTimerDone);
}
void TimerController::StopTimer() { void TimerController::StopTimer() {
app_timer_stop(timerAppTimer); app_timer_stop(timerAppTimer);
timerRunning = false; timerRunning = false;
@ -62,3 +58,12 @@ void TimerController::StopTimer() {
bool TimerController::IsRunning() { bool TimerController::IsRunning() {
return timerRunning; return timerRunning;
} }
void TimerController::OnTimerEnd() {
timerRunning = false;
if(systemTask != nullptr)
systemTask->PushMessage(System::Messages::OnTimerDone);
}
void TimerController::Register(Pinetime::System::SystemTask* systemTask) {
this->systemTask = systemTask;
}

View File

@ -12,7 +12,7 @@ namespace Pinetime {
class TimerController { class TimerController {
public: public:
TimerController(Pinetime::System::SystemTask& systemTask); TimerController() = default;
void Init(); void Init();
@ -24,11 +24,12 @@ namespace Pinetime {
bool IsRunning(); bool IsRunning();
void OnTimerEnd();
void Register(System::SystemTask* systemTask);
private: private:
System::SystemTask& systemTask; System::SystemTask* systemTask = nullptr;
static void timerEnd(void* p_context);
TickType_t endTicks; TickType_t endTicks;
bool timerRunning = false; bool timerRunning = false;
}; };

View File

@ -32,6 +32,7 @@
#include "drivers/St7789.h" #include "drivers/St7789.h"
#include "drivers/Watchdog.h" #include "drivers/Watchdog.h"
#include "systemtask/SystemTask.h" #include "systemtask/SystemTask.h"
#include "systemtask/Messages.h"
#include "displayapp/screens/settings/QuickSettings.h" #include "displayapp/screens/settings/QuickSettings.h"
#include "displayapp/screens/settings/Settings.h" #include "displayapp/screens/settings/Settings.h"
@ -44,6 +45,12 @@
using namespace Pinetime::Applications; using namespace Pinetime::Applications;
using namespace Pinetime::Applications::Display; using namespace Pinetime::Applications::Display;
namespace {
static inline bool in_isr(void) {
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
}
}
DisplayApp::DisplayApp(Drivers::St7789& lcd, DisplayApp::DisplayApp(Drivers::St7789& lcd,
Components::LittleVgl& lvgl, Components::LittleVgl& lvgl,
Drivers::Cst816S& touchPanel, Drivers::Cst816S& touchPanel,
@ -51,7 +58,6 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Controllers::Ble& bleController, Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController, Controllers::DateTime& dateTimeController,
Drivers::WatchdogView& watchdog, Drivers::WatchdogView& watchdog,
System::SystemTask& systemTask,
Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::HeartRateController& heartRateController, Pinetime::Controllers::HeartRateController& heartRateController,
Controllers::Settings& settingsController, Controllers::Settings& settingsController,
@ -65,19 +71,20 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
bleController {bleController}, bleController {bleController},
dateTimeController {dateTimeController}, dateTimeController {dateTimeController},
watchdog {watchdog}, watchdog {watchdog},
systemTask {systemTask},
notificationManager {notificationManager}, notificationManager {notificationManager},
heartRateController {heartRateController}, heartRateController {heartRateController},
settingsController {settingsController}, settingsController {settingsController},
motorController {motorController}, motorController {motorController},
motionController {motionController}, motionController {motionController},
timerController {timerController} { timerController {timerController} {
msgQueue = xQueueCreate(queueSize, itemSize);
// Start clock when smartwatch boots
LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None);
} }
void DisplayApp::Start() { void DisplayApp::Start() {
msgQueue = xQueueCreate(queueSize, itemSize);
// Start clock when smartwatch boots
LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None);
if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) { if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) {
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
} }
@ -130,7 +137,7 @@ void DisplayApp::Refresh() {
vTaskDelay(100); vTaskDelay(100);
} }
lcd.DisplayOff(); lcd.DisplayOff();
systemTask.PushMessage(System::SystemTask::Messages::OnDisplayTaskSleeping); PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping);
state = States::Idle; state = States::Idle;
break; break;
case Messages::GoToRunning: case Messages::GoToRunning:
@ -139,7 +146,7 @@ void DisplayApp::Refresh() {
state = States::Running; state = States::Running;
break; break;
case Messages::UpdateTimeOut: case Messages::UpdateTimeOut:
systemTask.PushMessage(System::SystemTask::Messages::UpdateTimeOut); PushMessageToSystemTask(System::Messages::UpdateTimeOut);
break; break;
case Messages::UpdateBleConnection: case Messages::UpdateBleConnection:
// clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected : // clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected :
@ -176,7 +183,7 @@ void DisplayApp::Refresh() {
LoadApp(Apps::QuickSettings, DisplayApp::FullRefreshDirections::RightAnim); LoadApp(Apps::QuickSettings, DisplayApp::FullRefreshDirections::RightAnim);
break; break;
case TouchEvents::DoubleTap: case TouchEvents::DoubleTap:
systemTask.PushMessage(System::SystemTask::Messages::GoToSleep); PushMessageToSystemTask(System::Messages::GoToSleep);
break; break;
default: default:
break; break;
@ -188,7 +195,7 @@ void DisplayApp::Refresh() {
} break; } break;
case Messages::ButtonPushed: case Messages::ButtonPushed:
if (currentApp == Apps::Clock) { if (currentApp == Apps::Clock) {
systemTask.PushMessage(System::SystemTask::Messages::GoToSleep); PushMessageToSystemTask(System::Messages::GoToSleep);
} else { } else {
if (!currentScreen->OnButtonPushed()) { if (!currentScreen->OnButtonPushed()) {
LoadApp(returnToApp, returnDirection); LoadApp(returnToApp, returnDirection);
@ -206,6 +213,11 @@ void DisplayApp::Refresh() {
} }
} }
if(nextApp != Apps::None) {
LoadApp(nextApp, nextDirection);
nextApp = Apps::None;
}
if (state != States::Idle && touchMode == TouchModes::Polling) { if (state != States::Idle && touchMode == TouchModes::Polling) {
auto info = touchPanel.GetTouchInfo(); auto info = touchPanel.GetTouchInfo();
if (info.action == 2) { // 2 = contact if (info.action == 2) { // 2 = contact
@ -224,7 +236,8 @@ void DisplayApp::RunningState() {
} }
void DisplayApp::StartApp(Apps app, DisplayApp::FullRefreshDirections direction) { void DisplayApp::StartApp(Apps app, DisplayApp::FullRefreshDirections direction) {
LoadApp(app, direction); nextApp = app;
nextDirection = direction;
} }
void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent) { void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent) {
@ -267,12 +280,12 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
case Apps::Notifications: case Apps::Notifications:
currentScreen = std::make_unique<Screens::Notifications>( currentScreen = std::make_unique<Screens::Notifications>(
this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Normal); this, notificationManager, systemTask->nimble().alertService(), Screens::Notifications::Modes::Normal);
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp); ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
break; break;
case Apps::NotificationsPreview: case Apps::NotificationsPreview:
currentScreen = std::make_unique<Screens::Notifications>( currentScreen = std::make_unique<Screens::Notifications>(
this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Preview); this, notificationManager, systemTask->nimble().alertService(), Screens::Notifications::Modes::Preview);
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp); ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
break; break;
case Apps::Timer: case Apps::Timer:
@ -321,7 +334,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
// //
case Apps::FlashLight: case Apps::FlashLight:
currentScreen = std::make_unique<Screens::FlashLight>(this, systemTask, brightnessController); currentScreen = std::make_unique<Screens::FlashLight>(this, *systemTask, brightnessController);
ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None); ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None);
break; break;
case Apps::StopWatch: case Apps::StopWatch:
@ -337,13 +350,13 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
currentScreen = std::make_unique<Screens::Paddle>(this, lvgl); currentScreen = std::make_unique<Screens::Paddle>(this, lvgl);
break; break;
case Apps::Music: case Apps::Music:
currentScreen = std::make_unique<Screens::Music>(this, systemTask.nimble().music()); currentScreen = std::make_unique<Screens::Music>(this, systemTask->nimble().music());
break; break;
case Apps::Navigation: case Apps::Navigation:
currentScreen = std::make_unique<Screens::Navigation>(this, systemTask.nimble().navigation()); currentScreen = std::make_unique<Screens::Navigation>(this, systemTask->nimble().navigation());
break; break;
case Apps::HeartRate: case Apps::HeartRate:
currentScreen = std::make_unique<Screens::HeartRate>(this, heartRateController, systemTask); currentScreen = std::make_unique<Screens::HeartRate>(this, heartRateController, *systemTask);
break; break;
case Apps::Motion: case Apps::Motion:
currentScreen = std::make_unique<Screens::Motion>(this, motionController); currentScreen = std::make_unique<Screens::Motion>(this, motionController);
@ -359,12 +372,15 @@ void DisplayApp::IdleState() {
} }
void DisplayApp::PushMessage(Messages msg) { void DisplayApp::PushMessage(Messages msg) {
BaseType_t xHigherPriorityTaskWoken; if(in_isr()) {
xHigherPriorityTaskWoken = pdFALSE; BaseType_t xHigherPriorityTaskWoken;
xQueueSendFromISR(msgQueue, &msg, &xHigherPriorityTaskWoken); xHigherPriorityTaskWoken = pdFALSE;
if (xHigherPriorityTaskWoken) { xQueueSendFromISR(msgQueue, &msg, &xHigherPriorityTaskWoken);
/* Actual macro used here is port specific. */ if (xHigherPriorityTaskWoken) {
// TODO : should I do something here? portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
} else {
xQueueSend(msgQueue, &msg, portMAX_DELAY);
} }
} }
@ -425,3 +441,12 @@ void DisplayApp::SetFullRefresh(DisplayApp::FullRefreshDirections direction) {
void DisplayApp::SetTouchMode(DisplayApp::TouchModes mode) { void DisplayApp::SetTouchMode(DisplayApp::TouchModes mode) {
touchMode = mode; touchMode = mode;
} }
void DisplayApp::PushMessageToSystemTask(Pinetime::System::Messages message) {
if(systemTask != nullptr)
systemTask->PushMessage(message);
}
void DisplayApp::Register(Pinetime::System::SystemTask* systemTask) {
this->systemTask = systemTask;
}

View File

@ -4,6 +4,7 @@
#include <queue.h> #include <queue.h>
#include <task.h> #include <task.h>
#include <memory> #include <memory>
#include <systemtask/Messages.h>
#include "Apps.h" #include "Apps.h"
#include "LittleVgl.h" #include "LittleVgl.h"
#include "TouchEvents.h" #include "TouchEvents.h"
@ -49,7 +50,6 @@ namespace Pinetime {
Controllers::Ble& bleController, Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController, Controllers::DateTime& dateTimeController,
Drivers::WatchdogView& watchdog, Drivers::WatchdogView& watchdog,
System::SystemTask& systemTask,
Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::HeartRateController& heartRateController, Pinetime::Controllers::HeartRateController& heartRateController,
Controllers::Settings& settingsController, Controllers::Settings& settingsController,
@ -64,6 +64,8 @@ namespace Pinetime {
void SetFullRefresh(FullRefreshDirections direction); void SetFullRefresh(FullRefreshDirections direction);
void SetTouchMode(TouchModes mode); void SetTouchMode(TouchModes mode);
void Register(Pinetime::System::SystemTask* systemTask);
private: private:
Pinetime::Drivers::St7789& lcd; Pinetime::Drivers::St7789& lcd;
Pinetime::Components::LittleVgl& lvgl; Pinetime::Components::LittleVgl& lvgl;
@ -72,7 +74,7 @@ namespace Pinetime {
Pinetime::Controllers::Ble& bleController; Pinetime::Controllers::Ble& bleController;
Pinetime::Controllers::DateTime& dateTimeController; Pinetime::Controllers::DateTime& dateTimeController;
Pinetime::Drivers::WatchdogView& watchdog; Pinetime::Drivers::WatchdogView& watchdog;
Pinetime::System::SystemTask& systemTask; Pinetime::System::SystemTask* systemTask = nullptr;
Pinetime::Controllers::NotificationManager& notificationManager; Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::HeartRateController& heartRateController; Pinetime::Controllers::HeartRateController& heartRateController;
Pinetime::Controllers::Settings& settingsController; Pinetime::Controllers::Settings& settingsController;
@ -108,6 +110,10 @@ namespace Pinetime {
void Refresh(); void Refresh();
void ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent); void ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent);
void LoadApp(Apps app, DisplayApp::FullRefreshDirections direction); void LoadApp(Apps app, DisplayApp::FullRefreshDirections direction);
void PushMessageToSystemTask(Pinetime::System::Messages message);
Apps nextApp = Apps::None;
DisplayApp::FullRefreshDirections nextDirection;
}; };
} }
} }

View File

@ -14,7 +14,6 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Controllers::Ble& bleController, Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController, Controllers::DateTime& dateTimeController,
Drivers::WatchdogView& watchdog, Drivers::WatchdogView& watchdog,
System::SystemTask& systemTask,
Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::HeartRateController& heartRateController, Pinetime::Controllers::HeartRateController& heartRateController,
Controllers::Settings& settingsController, Controllers::Settings& settingsController,
@ -22,10 +21,11 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Pinetime::Controllers::MotionController& motionController, Pinetime::Controllers::MotionController& motionController,
Pinetime::Controllers::TimerController& timerController) Pinetime::Controllers::TimerController& timerController)
: lcd {lcd}, bleController {bleController} { : lcd {lcd}, bleController {bleController} {
msgQueue = xQueueCreate(queueSize, itemSize);
} }
void DisplayApp::Start() { void DisplayApp::Start() {
msgQueue = xQueueCreate(queueSize, itemSize);
if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 512, this, 0, &taskHandle)) if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 512, this, 0, &taskHandle))
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
} }
@ -114,3 +114,7 @@ void DisplayApp::PushMessage(Display::Messages msg) {
// TODO : should I do something here? // TODO : should I do something here?
} }
} }
void DisplayApp::Register(Pinetime::System::SystemTask* systemTask) {
}

View File

@ -39,7 +39,6 @@ namespace Pinetime {
Controllers::Ble& bleController, Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController, Controllers::DateTime& dateTimeController,
Drivers::WatchdogView& watchdog, Drivers::WatchdogView& watchdog,
System::SystemTask& systemTask,
Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::HeartRateController& heartRateController, Pinetime::Controllers::HeartRateController& heartRateController,
Controllers::Settings& settingsController, Controllers::Settings& settingsController,
@ -48,6 +47,7 @@ namespace Pinetime {
Pinetime::Controllers::TimerController& timerController); Pinetime::Controllers::TimerController& timerController);
void Start(); void Start();
void PushMessage(Pinetime::Applications::Display::Messages msg); void PushMessage(Pinetime::Applications::Display::Messages msg);
void Register(Pinetime::System::SystemTask* systemTask);
private: private:
TaskHandle_t taskHandle; TaskHandle_t taskHandle;

View File

@ -23,6 +23,10 @@ bool touchpad_read(lv_indev_drv_t* indev_drv, lv_indev_data_t* data) {
LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel) LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel)
: lcd {lcd}, touchPanel {touchPanel}, previousClick {0, 0} { : lcd {lcd}, touchPanel {touchPanel}, previousClick {0, 0} {
}
void LittleVgl::Init() {
lv_init(); lv_init();
InitTheme(); InitTheme();
InitDisplay(); InitDisplay();

View File

@ -19,6 +19,8 @@ namespace Pinetime {
LittleVgl(LittleVgl&&) = delete; LittleVgl(LittleVgl&&) = delete;
LittleVgl& operator=(LittleVgl&&) = delete; LittleVgl& operator=(LittleVgl&&) = delete;
void Init();
void FlushDisplay(const lv_area_t* area, lv_color_t* color_p); void FlushDisplay(const lv_area_t* area, lv_color_t* color_p);
bool GetTouchPadInfo(lv_indev_data_t* ptr); bool GetTouchPadInfo(lv_indev_data_t* ptr);
void SetFullRefresh(FullRefreshDirections direction); void SetFullRefresh(FullRefreshDirections direction);

View File

@ -39,14 +39,14 @@ FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app,
backgroundAction->user_data = this; backgroundAction->user_data = this;
lv_obj_set_event_cb(backgroundAction, event_handler); lv_obj_set_event_cb(backgroundAction, event_handler);
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::DisableSleeping); systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
} }
FlashLight::~FlashLight() { FlashLight::~FlashLight() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
brightness.Restore(); brightness.Restore();
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::EnableSleeping); systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
} }
void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t event) { void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t event) {

View File

@ -63,12 +63,12 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app,
label_startStop = lv_label_create(btn_startStop, nullptr); label_startStop = lv_label_create(btn_startStop, nullptr);
UpdateStartStopButton(isHrRunning); UpdateStartStopButton(isHrRunning);
if (isHrRunning) if (isHrRunning)
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::DisableSleeping); systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
} }
HeartRate::~HeartRate() { HeartRate::~HeartRate() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::EnableSleeping); systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
} }
bool HeartRate::Refresh() { bool HeartRate::Refresh() {
@ -95,12 +95,12 @@ void HeartRate::OnStartStopEvent(lv_event_t event) {
if (heartRateController.State() == Controllers::HeartRateController::States::Stopped) { if (heartRateController.State() == Controllers::HeartRateController::States::Stopped) {
heartRateController.Start(); heartRateController.Start();
UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped); UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped);
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::DisableSleeping); systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
} else { } else {
heartRateController.Stop(); heartRateController.Stop();
UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped); UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped);
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::EnableSleeping); systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
} }
} }

View File

@ -15,12 +15,17 @@ namespace Pinetime {
public: public:
ScreenList(DisplayApp* app, ScreenList(DisplayApp* app,
uint8_t initScreen, uint8_t initScreen,
std::array<std::function<std::unique_ptr<Screen>()>, N>&& screens, const std::array<std::function<std::unique_ptr<Screen>()>, N>&& screens,
ScreenListModes mode) ScreenListModes mode)
: Screen(app), initScreen {initScreen}, screens {std::move(screens)}, mode {mode}, current {this->screens[initScreen]()} { : Screen(app), initScreen {initScreen}, screens {std::move(screens)}, mode {mode}, screenIndex{initScreen}, current {this->screens[initScreen]()} {
screenIndex = initScreen;
} }
ScreenList(const ScreenList&) = delete;
ScreenList& operator=(const ScreenList&) = delete;
ScreenList(ScreenList&&) = delete;
ScreenList& operator=(ScreenList&&) = delete;
~ScreenList() override { ~ScreenList() override {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
@ -97,7 +102,7 @@ namespace Pinetime {
private: private:
uint8_t initScreen = 0; uint8_t initScreen = 0;
std::array<std::function<std::unique_ptr<Screen>()>, N> screens; const std::array<std::function<std::unique_ptr<Screen>()>, N> screens;
ScreenListModes mode = ScreenListModes::UpDown; ScreenListModes mode = ScreenListModes::UpDown;
uint8_t screenIndex = 0; uint8_t screenIndex = 0;

View File

@ -81,7 +81,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
__TIME__); __TIME__);
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::unique_ptr<Screen>(new Screens::Label(0, 5, app, label)); return std::make_unique<Screens::Label>(0, 5, app, label);
} }
std::unique_ptr<Screen> SystemInfo::CreateScreen2() { std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
@ -161,7 +161,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
brightnessController.ToString(), brightnessController.ToString(),
resetReason); resetReason);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::unique_ptr<Screen>(new Screens::Label(1, 4, app, label)); return std::make_unique<Screens::Label>(1, 4, app, label);
} }
std::unique_ptr<Screen> SystemInfo::CreateScreen3() { std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
@ -195,7 +195,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
(int) mon.free_biggest_size, (int) mon.free_biggest_size,
0); 0);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::unique_ptr<Screen>(new Screens::Label(2, 5, app, label)); return std::make_unique<Screens::Label>(2, 5, app, label);
} }
bool sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) { bool sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
@ -229,7 +229,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
lv_table_set_cell_value(infoTask, i + 1, 2, std::to_string(tasksStatus[i].usStackHighWaterMark).c_str()); lv_table_set_cell_value(infoTask, i + 1, 2, std::to_string(tasksStatus[i].usStackHighWaterMark).c_str());
} }
} }
return std::unique_ptr<Screen>(new Screens::Label(3, 5, app, infoTask)); return std::make_unique<Screens::Label>(3, 5, app, infoTask);
} }
std::unique_ptr<Screen> SystemInfo::CreateScreen5() { std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
@ -245,5 +245,5 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
"#FFFF00 JF002/InfiniTime#"); "#FFFF00 JF002/InfiniTime#");
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::unique_ptr<Screen>(new Screens::Label(4, 5, app, label)); return std::make_unique<Screens::Label>(4, 5, app, label);
} }

View File

@ -7,12 +7,12 @@ using namespace Pinetime::Applications::Screens;
namespace { namespace {
static void ButtonEventHandler(lv_obj_t* obj, lv_event_t event) { static void ButtonEventHandler(lv_obj_t* obj, lv_event_t event) {
QuickSettings* screen = static_cast<QuickSettings*>(obj->user_data); auto* screen = static_cast<QuickSettings*>(obj->user_data);
screen->OnButtonEvent(obj, event); screen->OnButtonEvent(obj, event);
} }
static void lv_update_task(struct _lv_task_t* task) { static void lv_update_task(struct _lv_task_t* task) {
auto user_data = static_cast<QuickSettings*>(task->user_data); auto* user_data = static_cast<QuickSettings*>(task->user_data);
user_data->UpdateScreen(); user_data->UpdateScreen();
} }
} }

View File

@ -46,7 +46,7 @@ std::unique_ptr<Screen> Settings::CreateScreen1() {
{Symbols::clock, "Watch face", Apps::SettingWatchFace}, {Symbols::clock, "Watch face", Apps::SettingWatchFace},
}}; }};
return std::unique_ptr<Screen>(new Screens::List(0, 2, app, settingsController, applications)); return std::make_unique<Screens::List>(0, 2, app, settingsController, applications);
} }
std::unique_ptr<Screen> Settings::CreateScreen2() { std::unique_ptr<Screen> Settings::CreateScreen2() {
@ -58,5 +58,5 @@ std::unique_ptr<Screen> Settings::CreateScreen2() {
{Symbols::list, "About", Apps::SysInfo}, {Symbols::list, "About", Apps::SysInfo},
}}; }};
return std::unique_ptr<Screen>(new Screens::List(1, 2, app, settingsController, applications)); return std::make_unique<Screens::List>(1, 2, app, settingsController, applications);
} }

View File

@ -16,7 +16,6 @@ namespace Pinetime {
bool Refresh() override; bool Refresh() override;
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
private: private:

View File

@ -103,8 +103,6 @@ Bma421::Values Bma421::Process() {
uint8_t activity = 0; uint8_t activity = 0;
bma423_activity_output(&activity, &bma); bma423_activity_output(&activity, &bma);
NRF_LOG_INFO("MOTION : %d - %d/%d/%d", steps, data.x, data.y, data.z);
// X and Y axis are swapped because of the way the sensor is mounted in the PineTime // X and Y axis are swapped because of the way the sensor is mounted in the PineTime
return {steps, data.y, data.x, data.z}; return {steps, data.y, data.x, data.z};
} }

View File

@ -7,11 +7,14 @@
using namespace Pinetime::Drivers; using namespace Pinetime::Drivers;
SpiMaster::SpiMaster(const SpiMaster::SpiModule spi, const SpiMaster::Parameters& params) : spi {spi}, params {params} { SpiMaster::SpiMaster(const SpiMaster::SpiModule spi, const SpiMaster::Parameters& params) : spi {spi}, params {params} {
mutex = xSemaphoreCreateBinary();
ASSERT(mutex != NULL);
} }
bool SpiMaster::Init() { bool SpiMaster::Init() {
if(mutex == nullptr) {
mutex = xSemaphoreCreateBinary();
ASSERT(mutex != nullptr);
}
/* Configure GPIO pins used for pselsck, pselmosi, pselmiso and pselss for SPI0 */ /* Configure GPIO pins used for pselsck, pselmosi, pselmiso and pselss for SPI0 */
nrf_gpio_pin_set(params.pinSCK); nrf_gpio_pin_set(params.pinSCK);
nrf_gpio_cfg_output(params.pinSCK); nrf_gpio_cfg_output(params.pinSCK);
@ -132,17 +135,17 @@ void SpiMaster::OnEndEvent() {
spiBaseAddress->TASKS_START = 1; spiBaseAddress->TASKS_START = 1;
} else { } else {
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
if (taskToNotify != nullptr) { if (taskToNotify != nullptr) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
vTaskNotifyGiveFromISR(taskToNotify, &xHigherPriorityTaskWoken); vTaskNotifyGiveFromISR(taskToNotify, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken); portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
} }
nrf_gpio_pin_set(this->pinCsn); nrf_gpio_pin_set(this->pinCsn);
currentBufferAddr = 0; currentBufferAddr = 0;
BaseType_t xHigherPriorityTaskWoken = pdFALSE; BaseType_t xHigherPriorityTaskWoken2 = pdFALSE;
xSemaphoreGiveFromISR(mutex, &xHigherPriorityTaskWoken); xSemaphoreGiveFromISR(mutex, &xHigherPriorityTaskWoken2);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken); portYIELD_FROM_ISR(xHigherPriorityTaskWoken | xHigherPriorityTaskWoken2);
} }
} }

View File

@ -10,7 +10,6 @@ namespace Pinetime {
namespace Drivers { namespace Drivers {
class SpiMaster { class SpiMaster {
public: public:
;
enum class SpiModule : uint8_t { SPI0, SPI1 }; enum class SpiModule : uint8_t { SPI0, SPI1 };
enum class BitOrder : uint8_t { Msb_Lsb, Lsb_Msb }; enum class BitOrder : uint8_t { Msb_Lsb, Lsb_Msb };
enum class Modes : uint8_t { Mode0, Mode1, Mode2, Mode3 }; enum class Modes : uint8_t { Mode0, Mode1, Mode2, Mode3 };
@ -60,7 +59,7 @@ namespace Pinetime {
volatile uint32_t currentBufferAddr = 0; volatile uint32_t currentBufferAddr = 0;
volatile size_t currentBufferSize = 0; volatile size_t currentBufferSize = 0;
volatile TaskHandle_t taskToNotify; volatile TaskHandle_t taskToNotify;
SemaphoreHandle_t mutex; SemaphoreHandle_t mutex = nullptr;
}; };
} }
} }

View File

@ -9,10 +9,12 @@ using namespace Pinetime::Drivers;
// TODO use DMA/IRQ // TODO use DMA/IRQ
TwiMaster::TwiMaster(const Modules module, const Parameters& params) : module {module}, params {params} { TwiMaster::TwiMaster(const Modules module, const Parameters& params) : module {module}, params {params} {
mutex = xSemaphoreCreateBinary();
} }
void TwiMaster::Init() { void TwiMaster::Init() {
if(mutex == nullptr)
mutex = xSemaphoreCreateBinary();
NRF_GPIO->PIN_CNF[params.pinScl] = NRF_GPIO->PIN_CNF[params.pinScl] =
((uint32_t) GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t) GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | ((uint32_t) GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t) GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
((uint32_t) GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t) GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) | ((uint32_t) GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t) GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |

View File

@ -31,7 +31,7 @@ namespace Pinetime {
ErrorCodes Write(uint8_t deviceAddress, const uint8_t* data, size_t size, bool stop); ErrorCodes Write(uint8_t deviceAddress, const uint8_t* data, size_t size, bool stop);
void FixHwFreezed(); void FixHwFreezed();
NRF_TWIM_Type* twiBaseAddress; NRF_TWIM_Type* twiBaseAddress;
SemaphoreHandle_t mutex; SemaphoreHandle_t mutex = nullptr;
const Modules module; const Modules module;
const Parameters params; const Parameters params;
static constexpr uint8_t maxDataSize {16}; static constexpr uint8_t maxDataSize {16};

View File

@ -6,12 +6,13 @@
using namespace Pinetime::Applications; using namespace Pinetime::Applications;
HeartRateTask::HeartRateTask(Drivers::Hrs3300& heartRateSensor, Controllers::HeartRateController& controller) HeartRateTask::HeartRateTask(Drivers::Hrs3300& heartRateSensor, Controllers::HeartRateController& controller)
: heartRateSensor {heartRateSensor}, controller {controller}, ppg {static_cast<float>(heartRateSensor.ReadHrs())} { : heartRateSensor {heartRateSensor}, controller {controller}, ppg{} {
messageQueue = xQueueCreate(10, 1);
controller.SetHeartRateTask(this);
} }
void HeartRateTask::Start() { void HeartRateTask::Start() {
messageQueue = xQueueCreate(10, 1);
controller.SetHeartRateTask(this);
if (pdPASS != xTaskCreate(HeartRateTask::Process, "Heartrate", 500, this, 0, &taskHandle)) if (pdPASS != xTaskCreate(HeartRateTask::Process, "Heartrate", 500, this, 0, &taskHandle))
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
} }

View File

@ -33,7 +33,7 @@
#include "components/ble/NotificationManager.h" #include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h" #include "components/motor/MotorController.h"
#include "components/datetime/DateTimeController.h" #include "components/datetime/DateTimeController.h"
#include "components/settings/Settings.h" #include "components/heartrate/HeartRateController.h"
#include "drivers/Spi.h" #include "drivers/Spi.h"
#include "drivers/SpiMaster.h" #include "drivers/SpiMaster.h"
#include "drivers/SpiNorFlash.h" #include "drivers/SpiNorFlash.h"
@ -50,8 +50,6 @@ Pinetime::Logging::NrfLogger logger;
Pinetime::Logging::DummyLogger logger; Pinetime::Logging::DummyLogger logger;
#endif #endif
#include <memory>
static constexpr uint8_t pinSpiSck = 2; static constexpr uint8_t pinSpiSck = 2;
static constexpr uint8_t pinSpiMosi = 3; static constexpr uint8_t pinSpiMosi = 3;
static constexpr uint8_t pinSpiMiso = 4; static constexpr uint8_t pinSpiMiso = 4;
@ -108,15 +106,59 @@ void ble_manager_set_ble_connection_callback(void (*connection)());
void ble_manager_set_ble_disconnection_callback(void (*disconnection)()); void ble_manager_set_ble_disconnection_callback(void (*disconnection)());
static constexpr uint8_t pinTouchIrq = 28; static constexpr uint8_t pinTouchIrq = 28;
static constexpr uint8_t pinPowerPresentIrq = 19; static constexpr uint8_t pinPowerPresentIrq = 19;
std::unique_ptr<Pinetime::System::SystemTask> systemTask;
Pinetime::Controllers::Settings settingsController {spiNorFlash}; Pinetime::Controllers::Settings settingsController {spiNorFlash};
Pinetime::Controllers::MotorController motorController {settingsController}; Pinetime::Controllers::MotorController motorController {settingsController};
Pinetime::Controllers::HeartRateController heartRateController;
Pinetime::Applications::HeartRateTask heartRateApp(heartRateSensor, heartRateController);
Pinetime::Controllers::DateTime dateTimeController;
Pinetime::Drivers::Watchdog watchdog;
Pinetime::Drivers::WatchdogView watchdogView(watchdog);
Pinetime::Controllers::NotificationManager notificationManager;
Pinetime::Controllers::MotionController motionController;
Pinetime::Controllers::TimerController timerController;
Pinetime::Applications::DisplayApp displayApp(lcd,
lvgl,
touchPanel,
batteryController,
bleController,
dateTimeController,
watchdogView,
notificationManager,
heartRateController,
settingsController,
motorController,
motionController,
timerController);
Pinetime::System::SystemTask systemTask(spi,
lcd,
spiNorFlash,
twiMaster,
touchPanel,
lvgl,
batteryController,
bleController,
dateTimeController,
timerController,
watchdog,
notificationManager,
motorController,
heartRateSensor,
motionController,
motionSensor,
settingsController,
heartRateController,
displayApp,
heartRateApp);
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();
return; return;
} }
@ -141,12 +183,12 @@ void vApplicationIdleHook(void) {
void DebounceTimerChargeCallback(TimerHandle_t xTimer) { void DebounceTimerChargeCallback(TimerHandle_t xTimer) {
xTimerStop(xTimer, 0); xTimerStop(xTimer, 0);
systemTask->PushMessage(Pinetime::System::SystemTask::Messages::OnChargingEvent); systemTask.PushMessage(Pinetime::System::Messages::OnChargingEvent);
} }
void DebounceTimerCallback(TimerHandle_t xTimer) { void DebounceTimerCallback(TimerHandle_t xTimer) {
xTimerStop(xTimer, 0); xTimerStop(xTimer, 0);
systemTask->OnButtonPushed(); systemTask.OnButtonPushed();
} }
void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void) { void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void) {
@ -264,19 +306,9 @@ int main(void) {
debounceTimer = xTimerCreate("debounceTimer", 200, pdFALSE, (void*) 0, DebounceTimerCallback); debounceTimer = xTimerCreate("debounceTimer", 200, pdFALSE, (void*) 0, DebounceTimerCallback);
debounceChargeTimer = xTimerCreate("debounceTimerCharge", 200, pdFALSE, (void*) 0, DebounceTimerChargeCallback); debounceChargeTimer = xTimerCreate("debounceTimerCharge", 200, pdFALSE, (void*) 0, DebounceTimerChargeCallback);
systemTask = std::make_unique<Pinetime::System::SystemTask>(spi, lvgl.Init();
lcd,
spiNorFlash, systemTask.Start();
twiMaster,
touchPanel,
lvgl,
batteryController,
bleController,
motorController,
heartRateSensor,
motionSensor,
settingsController);
systemTask->Start();
nimble_port_init(); nimble_port_init();
vTaskStartScheduler(); vTaskStartScheduler();

26
src/systemtask/Messages.h Normal file
View File

@ -0,0 +1,26 @@
#pragma once
namespace Pinetime {
namespace System {
enum class Messages {
GoToSleep,
GoToRunning,
TouchWakeUp,
OnNewTime,
OnNewNotification,
OnTimerDone,
OnNewCall,
BleConnected,
UpdateTimeOut,
BleFirmwareUpdateStarted,
BleFirmwareUpdateFinished,
OnTouchEvent,
OnButtonEvent,
OnDisplayTaskSleeping,
EnableSleeping,
DisableSleeping,
OnNewDay,
OnChargingEvent
};
}
}

View File

@ -27,6 +27,12 @@
using namespace Pinetime::System; using namespace Pinetime::System;
namespace {
static inline bool in_isr(void) {
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
}
}
void IdleTimerCallback(TimerHandle_t xTimer) { void IdleTimerCallback(TimerHandle_t xTimer) {
NRF_LOG_INFO("IdleTimerCallback"); NRF_LOG_INFO("IdleTimerCallback");
@ -42,10 +48,18 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi,
Components::LittleVgl& lvgl, Components::LittleVgl& lvgl,
Controllers::Battery& batteryController, Controllers::Battery& batteryController,
Controllers::Ble& bleController, Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController,
Controllers::TimerController& timerController,
Drivers::Watchdog& watchdog,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::MotorController& motorController, Pinetime::Controllers::MotorController& motorController,
Pinetime::Drivers::Hrs3300& heartRateSensor, Pinetime::Drivers::Hrs3300& heartRateSensor,
Pinetime::Controllers::MotionController& motionController,
Pinetime::Drivers::Bma421& motionSensor, Pinetime::Drivers::Bma421& motionSensor,
Controllers::Settings& settingsController) Controllers::Settings& settingsController,
Pinetime::Controllers::HeartRateController& heartRateController,
Pinetime::Applications::DisplayApp& displayApp,
Pinetime::Applications::HeartRateTask& heartRateApp)
: spi {spi}, : spi {spi},
lcd {lcd}, lcd {lcd},
spiNorFlash {spiNorFlash}, spiNorFlash {spiNorFlash},
@ -53,21 +67,25 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi,
touchPanel {touchPanel}, touchPanel {touchPanel},
lvgl {lvgl}, lvgl {lvgl},
batteryController {batteryController}, batteryController {batteryController},
heartRateController {*this},
bleController {bleController}, bleController {bleController},
dateTimeController {*this}, dateTimeController {dateTimeController},
timerController {*this}, timerController {timerController},
watchdog {}, watchdog {watchdog},
watchdogView {watchdog}, notificationManager{notificationManager},
motorController {motorController}, motorController {motorController},
heartRateSensor {heartRateSensor}, heartRateSensor {heartRateSensor},
motionSensor {motionSensor}, motionSensor {motionSensor},
settingsController {settingsController}, settingsController {settingsController},
nimbleController(*this, bleController, dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController) { heartRateController{heartRateController},
systemTasksMsgQueue = xQueueCreate(10, 1); nimbleController(*this, bleController, dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController),
motionController{motionController},
displayApp{displayApp},
heartRateApp(heartRateApp) {
} }
void SystemTask::Start() { void SystemTask::Start() {
systemTasksMsgQueue = xQueueCreate(10, 1);
if (pdPASS != xTaskCreate(SystemTask::Process, "MAIN", 350, this, 0, &taskHandle)) if (pdPASS != xTaskCreate(SystemTask::Process, "MAIN", 350, this, 0, &taskHandle))
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
} }
@ -96,9 +114,11 @@ void SystemTask::Work() {
twiMaster.Init(); twiMaster.Init();
touchPanel.Init(); touchPanel.Init();
dateTimeController.Register(this);
batteryController.Init(); batteryController.Init();
motorController.Init(); motorController.Init();
motionSensor.SoftReset(); motionSensor.SoftReset();
timerController.Register(this);
timerController.Init(); timerController.Init();
// Reset the TWI device because the motion sensor chip most probably crashed it... // Reset the TWI device because the motion sensor chip most probably crashed it...
@ -108,28 +128,14 @@ void SystemTask::Work() {
motionSensor.Init(); motionSensor.Init();
settingsController.Init(); settingsController.Init();
displayApp = std::make_unique<Pinetime::Applications::DisplayApp>(lcd, displayApp.Register(this);
lvgl, displayApp.Start();
touchPanel,
batteryController,
bleController,
dateTimeController,
watchdogView,
*this,
notificationManager,
heartRateController,
settingsController,
motorController,
motionController,
timerController);
displayApp->Start();
displayApp->PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel); displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel);
heartRateSensor.Init(); heartRateSensor.Init();
heartRateSensor.Disable(); heartRateSensor.Disable();
heartRateApp = std::make_unique<Pinetime::Applications::HeartRateTask>(heartRateSensor, heartRateController); heartRateApp.Start();
heartRateApp->Start();
nrf_gpio_cfg_sense_input(pinButton, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_High); nrf_gpio_cfg_sense_input(pinButton, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_High);
nrf_gpio_cfg_output(15); nrf_gpio_cfg_output(15);
@ -208,9 +214,9 @@ void SystemTask::Work() {
spiNorFlash.Wakeup(); spiNorFlash.Wakeup();
lcd.Wakeup(); lcd.Wakeup();
displayApp->PushMessage(Pinetime::Applications::Display::Messages::GoToRunning); displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToRunning);
displayApp->PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel); displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel);
heartRateApp->PushMessage(Pinetime::Applications::HeartRateTask::Messages::WakeUp); heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::WakeUp);
isSleeping = false; isSleeping = false;
isWakingUp = false; isWakingUp = false;
@ -230,26 +236,26 @@ void SystemTask::Work() {
isGoingToSleep = true; isGoingToSleep = true;
NRF_LOG_INFO("[systemtask] Going to sleep"); NRF_LOG_INFO("[systemtask] Going to sleep");
xTimerStop(idleTimer, 0); xTimerStop(idleTimer, 0);
displayApp->PushMessage(Pinetime::Applications::Display::Messages::GoToSleep); displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToSleep);
heartRateApp->PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep); heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep);
break; break;
case Messages::OnNewTime: case Messages::OnNewTime:
ReloadIdleTimer(); ReloadIdleTimer();
displayApp->PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime); displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime);
break; break;
case Messages::OnNewNotification: case Messages::OnNewNotification:
if (isSleeping && !isWakingUp) { if (isSleeping && !isWakingUp) {
GoToRunning(); GoToRunning();
} }
motorController.SetDuration(35); motorController.SetDuration(35);
displayApp->PushMessage(Pinetime::Applications::Display::Messages::NewNotification); displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
break; break;
case Messages::OnTimerDone: case Messages::OnTimerDone:
if (isSleeping && !isWakingUp) { if (isSleeping && !isWakingUp) {
GoToRunning(); GoToRunning();
} }
motorController.SetDuration(35); motorController.SetDuration(35);
displayApp->PushMessage(Pinetime::Applications::Display::Messages::TimerDone); displayApp.PushMessage(Pinetime::Applications::Display::Messages::TimerDone);
break; break;
case Messages::BleConnected: case Messages::BleConnected:
ReloadIdleTimer(); ReloadIdleTimer();
@ -260,7 +266,7 @@ void SystemTask::Work() {
doNotGoToSleep = true; doNotGoToSleep = true;
if (isSleeping && !isWakingUp) if (isSleeping && !isWakingUp)
GoToRunning(); GoToRunning();
displayApp->PushMessage(Pinetime::Applications::Display::Messages::BleFirmwareUpdateStarted); displayApp.PushMessage(Pinetime::Applications::Display::Messages::BleFirmwareUpdateStarted);
break; break;
case Messages::BleFirmwareUpdateFinished: case Messages::BleFirmwareUpdateFinished:
doNotGoToSleep = false; doNotGoToSleep = false;
@ -359,7 +365,7 @@ void SystemTask::OnButtonPushed() {
if (!isSleeping) { if (!isSleeping) {
NRF_LOG_INFO("[systemtask] Button pushed"); NRF_LOG_INFO("[systemtask] Button pushed");
PushMessage(Messages::OnButtonEvent); PushMessage(Messages::OnButtonEvent);
displayApp->PushMessage(Pinetime::Applications::Display::Messages::ButtonPushed); displayApp.PushMessage(Pinetime::Applications::Display::Messages::ButtonPushed);
} else { } else {
if (!isWakingUp) { if (!isWakingUp) {
NRF_LOG_INFO("[systemtask] Button pushed, waking up"); NRF_LOG_INFO("[systemtask] Button pushed, waking up");
@ -380,7 +386,7 @@ void SystemTask::OnTouchEvent() {
return; return;
if (!isSleeping) { if (!isSleeping) {
PushMessage(Messages::OnTouchEvent); PushMessage(Messages::OnTouchEvent);
displayApp->PushMessage(Pinetime::Applications::Display::Messages::TouchEvent); displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
} else if (!isWakingUp) { } else if (!isWakingUp) {
if (settingsController.getWakeUpMode() == Pinetime::Controllers::Settings::WakeUpMode::None or if (settingsController.getWakeUpMode() == Pinetime::Controllers::Settings::WakeUpMode::None or
settingsController.getWakeUpMode() == Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist) settingsController.getWakeUpMode() == Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist)
@ -389,16 +395,22 @@ void SystemTask::OnTouchEvent() {
} }
} }
void SystemTask::PushMessage(SystemTask::Messages msg) { void SystemTask::PushMessage(System::Messages msg) {
if (msg == Messages::GoToSleep) { if (msg == Messages::GoToSleep) {
isGoingToSleep = true; isGoingToSleep = true;
} }
BaseType_t xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE; if(in_isr()) {
xQueueSendFromISR(systemTasksMsgQueue, &msg, &xHigherPriorityTaskWoken); BaseType_t xHigherPriorityTaskWoken;
if (xHigherPriorityTaskWoken) { xHigherPriorityTaskWoken = pdFALSE;
/* Actual macro used here is port specific. */ xQueueSendFromISR(systemTasksMsgQueue, &msg, &xHigherPriorityTaskWoken);
// TODO: should I do something here? if (xHigherPriorityTaskWoken) {
/* Actual macro used here is port specific. */
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
} else {
xQueueSend(systemTasksMsgQueue, &msg, portMAX_DELAY);
} }
} }

View File

@ -6,7 +6,6 @@
#include <task.h> #include <task.h>
#include <timers.h> #include <timers.h>
#include <heartratetask/HeartRateTask.h> #include <heartratetask/HeartRateTask.h>
#include <components/heartrate/HeartRateController.h>
#include <components/settings/Settings.h> #include <components/settings/Settings.h>
#include <drivers/Bma421.h> #include <drivers/Bma421.h>
#include <components/motion/MotionController.h> #include <components/motion/MotionController.h>
@ -27,6 +26,7 @@
#endif #endif
#include "drivers/Watchdog.h" #include "drivers/Watchdog.h"
#include "Messages.h"
namespace Pinetime { namespace Pinetime {
namespace Drivers { namespace Drivers {
@ -40,27 +40,6 @@ namespace Pinetime {
namespace System { namespace System {
class SystemTask { class SystemTask {
public: public:
enum class Messages {
GoToSleep,
GoToRunning,
TouchWakeUp,
OnNewTime,
OnNewNotification,
OnTimerDone,
OnNewCall,
BleConnected,
UpdateTimeOut,
BleFirmwareUpdateStarted,
BleFirmwareUpdateFinished,
OnTouchEvent,
OnButtonEvent,
OnDisplayTaskSleeping,
EnableSleeping,
DisableSleeping,
OnNewDay,
OnChargingEvent
};
SystemTask(Drivers::SpiMaster& spi, SystemTask(Drivers::SpiMaster& spi,
Drivers::St7789& lcd, Drivers::St7789& lcd,
Pinetime::Drivers::SpiNorFlash& spiNorFlash, Pinetime::Drivers::SpiNorFlash& spiNorFlash,
@ -69,10 +48,18 @@ namespace Pinetime {
Components::LittleVgl& lvgl, Components::LittleVgl& lvgl,
Controllers::Battery& batteryController, Controllers::Battery& batteryController,
Controllers::Ble& bleController, Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController,
Controllers::TimerController& timerController,
Drivers::Watchdog& watchdog,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::MotorController& motorController, Pinetime::Controllers::MotorController& motorController,
Pinetime::Drivers::Hrs3300& heartRateSensor, Pinetime::Drivers::Hrs3300& heartRateSensor,
Pinetime::Controllers::MotionController& motionController,
Pinetime::Drivers::Bma421& motionSensor, Pinetime::Drivers::Bma421& motionSensor,
Controllers::Settings& settingsController); Controllers::Settings& settingsController,
Pinetime::Controllers::HeartRateController& heartRateController,
Pinetime::Applications::DisplayApp& displayApp,
Pinetime::Applications::HeartRateTask& heartRateApp);
void Start(); void Start();
void PushMessage(Messages msg); void PushMessage(Messages msg);
@ -96,27 +83,29 @@ namespace Pinetime {
Pinetime::Drivers::Cst816S& touchPanel; Pinetime::Drivers::Cst816S& touchPanel;
Pinetime::Components::LittleVgl& lvgl; Pinetime::Components::LittleVgl& lvgl;
Pinetime::Controllers::Battery& batteryController; Pinetime::Controllers::Battery& batteryController;
std::unique_ptr<Pinetime::Applications::DisplayApp> displayApp;
Pinetime::Controllers::HeartRateController heartRateController;
std::unique_ptr<Pinetime::Applications::HeartRateTask> heartRateApp;
Pinetime::Controllers::Ble& bleController; Pinetime::Controllers::Ble& bleController;
Pinetime::Controllers::DateTime dateTimeController; Pinetime::Controllers::DateTime& dateTimeController;
Pinetime::Controllers::TimerController timerController; Pinetime::Controllers::TimerController& timerController;
QueueHandle_t systemTasksMsgQueue; QueueHandle_t systemTasksMsgQueue;
std::atomic<bool> isSleeping {false}; std::atomic<bool> isSleeping {false};
std::atomic<bool> isGoingToSleep {false}; std::atomic<bool> isGoingToSleep {false};
std::atomic<bool> isWakingUp {false}; std::atomic<bool> isWakingUp {false};
Pinetime::Drivers::Watchdog watchdog; Pinetime::Drivers::Watchdog& watchdog;
Pinetime::Drivers::WatchdogView watchdogView; Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::NotificationManager notificationManager;
Pinetime::Controllers::MotorController& motorController; Pinetime::Controllers::MotorController& motorController;
Pinetime::Drivers::Hrs3300& heartRateSensor; Pinetime::Drivers::Hrs3300& heartRateSensor;
Pinetime::Drivers::Bma421& motionSensor; Pinetime::Drivers::Bma421& motionSensor;
Pinetime::Controllers::Settings& settingsController; Pinetime::Controllers::Settings& settingsController;
Pinetime::Controllers::HeartRateController& heartRateController;
Pinetime::Controllers::NimbleController nimbleController; Pinetime::Controllers::NimbleController nimbleController;
Controllers::BrightnessController brightnessController; Controllers::BrightnessController brightnessController;
Pinetime::Controllers::MotionController motionController; Pinetime::Controllers::MotionController& motionController;
Pinetime::Applications::DisplayApp& displayApp;
Pinetime::Applications::HeartRateTask& heartRateApp;
static constexpr uint8_t pinSpiSck = 2; static constexpr uint8_t pinSpiSck = 2;
static constexpr uint8_t pinSpiMosi = 3; static constexpr uint8_t pinSpiMosi = 3;