Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,8 @@ add_definitions(-DNIMBLE_CFG_CONTROLLER)
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(-DFREERTOS)
add_definitions(-D__STACK_SIZE=8192)
add_definitions(-D__HEAP_SIZE=8192)
add_definitions(-D__STACK_SIZE=1024)
add_definitions(-D__HEAP_SIZE=4096)

# NOTE : Add the following defines to enable debug mode of the NRF SDK:
#add_definitions(-DDEBUG)
Expand Down
2 changes: 1 addition & 1 deletion src/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define configTICK_RATE_HZ 1024
#define configMAX_PRIORITIES (3)
#define configMINIMAL_STACK_SIZE (120)
#define configTOTAL_HEAP_SIZE (1024 * 16)
#define configTOTAL_HEAP_SIZE (1024 * 17)
#define configMAX_TASK_NAME_LEN (4)
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
Expand Down
2 changes: 1 addition & 1 deletion src/components/ble/AlertNotificationClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void AlertNotificationClient::OnNotification(ble_gap_event* event) {
notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
notificationManager.Push(std::move(notif));

systemTask.PushMessage(Pinetime::System::SystemTask::Messages::OnNewNotification);
systemTask.PushMessage(Pinetime::System::Messages::OnNewNotification);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/ble/AlertNotificationService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int AlertNotificationService::OnAlert(uint16_t conn_handle, uint16_t attr_handle
break;
}

auto event = Pinetime::System::SystemTask::Messages::OnNewNotification;
auto event = Pinetime::System::Messages::OnNewNotification;
notificationManager.Push(std::move(notif));
systemTask.PushMessage(event);
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/ble/DfuService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) {
bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Running);
bleController.FirmwareUpdateTotalBytes(0xffffffffu);
bleController.FirmwareUpdateCurrentBytes(0);
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleFirmwareUpdateStarted);
systemTask.PushMessage(Pinetime::System::Messages::BleFirmwareUpdateStarted);
return 0;
} else {
NRF_LOG_INFO("[DFU] -> Start DFU, mode %d not supported!", imageType);
Expand Down Expand Up @@ -279,7 +279,7 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) {
}
NRF_LOG_INFO("[DFU] -> Activate image and reset!");
bleController.StopFirmwareUpdate();
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleFirmwareUpdateFinished);
systemTask.PushMessage(Pinetime::System::Messages::BleFirmwareUpdateFinished);
Reset();
bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated);
return 0;
Expand All @@ -304,7 +304,7 @@ void DfuService::Reset() {
notificationManager.Reset();
bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error);
bleController.StopFirmwareUpdate();
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleFirmwareUpdateFinished);
systemTask.PushMessage(Pinetime::System::Messages::BleFirmwareUpdateFinished);
}

DfuService::NotificationManager::NotificationManager() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ble/ImmediateAlertService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int ImmediateAlertService::OnAlertLevelChanged(uint16_t connectionHandle, uint16
notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
notificationManager.Push(std::move(notif));

systemTask.PushMessage(Pinetime::System::SystemTask::Messages::OnNewNotification);
systemTask.PushMessage(Pinetime::System::Messages::OnNewNotification);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/ble/NimbleController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) {
bleController.Disconnect();
} else {
bleController.Connect();
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleConnected);
systemTask.PushMessage(Pinetime::System::Messages::BleConnected);
connectionHandle = event->connect.conn_handle;
// Service discovery is deffered via systemtask
}
Expand Down
10 changes: 6 additions & 4 deletions src/components/datetime/DateTimeController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

using namespace Pinetime::Controllers;

DateTime::DateTime(System::SystemTask& systemTask) : systemTask {systemTask} {
}

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) {
std::tm tm = {
Expand Down Expand Up @@ -70,7 +67,8 @@ void DateTime::UpdateTime(uint32_t systickCounter) {
// Notify new day to SystemTask
if (hour == 0 and not isMidnightAlreadyNotified) {
isMidnightAlreadyNotified = true;
systemTask.PushMessage(System::SystemTask::Messages::OnNewDay);
if(systemTask != nullptr)
systemTask->PushMessage(System::Messages::OnNewDay);
} else if (hour != 0) {
isMidnightAlreadyNotified = false;
}
Expand Down Expand Up @@ -104,6 +102,10 @@ const char* DateTime::DayOfWeekShortToStringLow() {
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::DaysStringShortLow[] = {"--", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
Expand Down
6 changes: 3 additions & 3 deletions src/components/datetime/DateTimeController.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ namespace Pinetime {
December
};

DateTime(System::SystemTask& systemTask);

void SetTime(uint16_t year,
uint8_t month,
uint8_t day,
Expand Down Expand Up @@ -75,8 +73,9 @@ namespace Pinetime {
return uptime;
}

void Register(System::SystemTask* systemTask);

private:
System::SystemTask& systemTask;
uint16_t year = 0;
Months month = Months::Unknown;
uint8_t day = 0;
Expand All @@ -90,6 +89,7 @@ namespace Pinetime {
std::chrono::seconds uptime {0};

bool isMidnightAlreadyNotified = false;
System::SystemTask* systemTask = nullptr;

static char const* DaysString[];
static char const* DaysStringShort[];
Expand Down
3 changes: 0 additions & 3 deletions src/components/heartrate/HeartRateController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

using namespace Pinetime::Controllers;

HeartRateController::HeartRateController(Pinetime::System::SystemTask& systemTask) : systemTask {systemTask} {
}

void HeartRateController::Update(HeartRateController::States newState, uint8_t heartRate) {
this->state = newState;
if (this->heartRate != heartRate) {
Expand Down
4 changes: 1 addition & 3 deletions src/components/heartrate/HeartRateController.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ namespace Pinetime {
public:
enum class States { Stopped, NotEnoughData, NoTouch, Running };

explicit HeartRateController(System::SystemTask& systemTask);

HeartRateController() = default;
void Start();
void Stop();
void Update(States newState, uint8_t heartRate);
Expand All @@ -32,7 +31,6 @@ namespace Pinetime {
void SetService(Pinetime::Controllers::HeartRateService* service);

private:
System::SystemTask& systemTask;
Applications::HeartRateTask* task = nullptr;
States state = States::Stopped;
uint8_t heartRate = 0;
Expand Down
11 changes: 2 additions & 9 deletions src/components/heartrate/Ppg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ namespace {
}
}

Ppg::Ppg(float spl)
: offset {spl},
hpf {0.87033078, -1.74066156, 0.87033078, -1.72377617, 0.75754694},
Ppg::Ppg()
: hpf {0.87033078, -1.74066156, 0.87033078, -1.72377617, 0.75754694},
agc {20, 0.971, 2},
lpf {0.11595249, 0.23190498, 0.11595249, -0.72168143, 0.18549138} {
}
Expand All @@ -67,13 +66,7 @@ float Ppg::HeartRate() {
dataIndex = 0;
return hr;
}

int cccount = 0;
float Ppg::ProcessHeartRate() {

if (cccount > 2)
asm("nop");
cccount++;
auto t0 = Trough(data.data(), dataIndex, 7, 48);
if (t0 < 0)
return 0;
Expand Down
3 changes: 1 addition & 2 deletions src/components/heartrate/Ppg.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ namespace Pinetime {
namespace Controllers {
class Ppg {
public:
explicit Ppg(float spl);

Ppg();
int8_t Preprocess(float spl);
float HeartRate();

Expand Down
29 changes: 17 additions & 12 deletions src/components/timer/TimerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ using namespace Pinetime::Controllers;

APP_TIMER_DEF(timerAppTimer);


TimerController::TimerController(System::SystemTask& systemTask) : systemTask{systemTask} {
namespace {
void TimerEnd(void* p_context) {
auto* controller = static_cast<Pinetime::Controllers::TimerController*> (p_context);
if(controller != nullptr)
controller->OnTimerEnd();
}
}


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) {
Expand Down Expand Up @@ -47,18 +50,20 @@ uint32_t TimerController::GetTimeRemaining() {
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() {
app_timer_stop(timerAppTimer);
timerRunning = false;
}

bool TimerController::IsRunning() {
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;
}
13 changes: 7 additions & 6 deletions src/components/timer/TimerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Pinetime {

class TimerController {
public:
TimerController(Pinetime::System::SystemTask& systemTask);
TimerController() = default;

void Init();

Expand All @@ -23,12 +23,13 @@ namespace Pinetime {
uint32_t GetTimeRemaining();

bool IsRunning();


void OnTimerEnd();

void Register(System::SystemTask* systemTask);

private:
System::SystemTask& systemTask;

static void timerEnd(void* p_context);

System::SystemTask* systemTask = nullptr;
TickType_t endTicks;
bool timerRunning = false;
};
Expand Down
Loading