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

@@ -5,17 +5,19 @@
#include <hal/nrf_rtc.h>
#include <BLE/BleManager.h>
#include <softdevice/common/nrf_sdh_freertos.h>
#include <Components/Ble/NotificationManager.h>
#include "SystemTask.h"
#include "../main.h"
using namespace Pinetime::System;
SystemTask::SystemTask(Pinetime::Drivers::SpiMaster &spi, Pinetime::Drivers::St7789 &lcd,
Pinetime::Drivers::Cst816S &touchPanel, Pinetime::Components::LittleVgl &lvgl,
Pinetime::Controllers::Battery &batteryController, Pinetime::Controllers::Ble &bleController,
Pinetime::Controllers::DateTime& dateTimeController) :
SystemTask::SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd, Drivers::Cst816S &touchPanel,
Components::LittleVgl &lvgl,
Controllers::Battery &batteryController, Controllers::Ble &bleController,
Controllers::DateTime &dateTimeController,
Pinetime::Controllers::NotificationManager& notificationManager) :
spi{spi}, lcd{lcd}, touchPanel{touchPanel}, lvgl{lvgl}, batteryController{batteryController},
bleController{bleController}, dateTimeController{dateTimeController},
watchdog{}, watchdogView{watchdog}{
watchdog{}, watchdogView{watchdog}, notificationManager{notificationManager} {
systemTaksMsgQueue = xQueueCreate(10, 1);
}
@@ -44,7 +46,8 @@ void SystemTask::Work() {
touchPanel.Init();
batteryController.Init();
displayApp.reset(new Pinetime::Applications::DisplayApp(lcd, lvgl, touchPanel, batteryController, bleController, dateTimeController, watchdogView, *this));
displayApp.reset(new Pinetime::Applications::DisplayApp(lcd, lvgl, touchPanel, batteryController, bleController,
dateTimeController, watchdogView, *this, notificationManager));
displayApp->Start();
batteryController.Update();

View File

@@ -16,13 +16,11 @@ namespace Pinetime {
enum class Messages {GoToSleep, GoToRunning, OnNewTime, OnNewNotification
};
SystemTask(Pinetime::Drivers::SpiMaster& spi,
Pinetime::Drivers::St7789& lcd,
Pinetime::Drivers::Cst816S& touchPanel,
Pinetime::Components::LittleVgl& lvgl,
Pinetime::Controllers::Battery& batteryController,
Pinetime::Controllers::Ble& bleController,
Pinetime::Controllers::DateTime& dateTimeController);
SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd, Drivers::Cst816S &touchPanel,
Components::LittleVgl &lvgl,
Controllers::Battery &batteryController, Controllers::Ble &bleController,
Controllers::DateTime &dateTimeController,
Pinetime::Controllers::NotificationManager& manager);
void Start();
@@ -45,6 +43,7 @@ namespace Pinetime {
bool isSleeping = false;
Pinetime::Drivers::Watchdog watchdog;
Pinetime::Drivers::WatchdogView watchdogView;
Pinetime::Controllers::NotificationManager& notificationManager;
static constexpr uint8_t pinSpiSck = 2;