Encapsulate Notification management in NotificationManager. It implement a static array of notifications to avoid dynamic allocation.

This commit is contained in:
JF
2020-03-28 19:05:28 +01:00
parent 68240704c7
commit baca0fc3e5
13 changed files with 105 additions and 116 deletions

View File

@@ -16,6 +16,7 @@
#include <drivers/SpiMaster.h>
#include <DisplayApp/LittleVgl.h>
#include <SystemTask/SystemTask.h>
#include <Components/Ble/NotificationManager.h>
#if NRF_LOG_ENABLED
#include "Logging/NrfLogger.h"
@@ -55,6 +56,8 @@ void ble_manager_set_ble_disconnection_callback(void (*disconnection)());
static constexpr uint8_t pinTouchIrq = 28;
std::unique_ptr<Pinetime::System::SystemTask> systemTask;
Pinetime::Controllers::NotificationManager notificationManager;
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
if(pin == pinTouchIrq) {
systemTask->OnTouchEvent();
@@ -86,7 +89,7 @@ void OnBleDisconnection() {
}
void OnNewNotification(const char* message, uint8_t size) {
bleController.PushNotification(message, size);
notificationManager.Push(Pinetime::Controllers::NotificationManager::Categories::SimpleAlert, message, size);
systemTask->PushMessage(Pinetime::System::SystemTask::Messages::OnNewNotification);
}
@@ -128,7 +131,8 @@ int main(void) {
debounceTimer = xTimerCreate ("debounceTimer", 200, pdFALSE, (void *) 0, DebounceTimerCallback);
systemTask.reset(new Pinetime::System::SystemTask(spi, lcd, touchPanel, lvgl, batteryController, bleController, dateTimeController));
systemTask.reset(new Pinetime::System::SystemTask(spi, lcd, touchPanel, lvgl, batteryController, bleController,
dateTimeController, notificationManager));
systemTask->Start();
ble_manager_init();