diff options
author | JF <jf@codingfield.com> | 2020-04-05 18:59:15 +0200 |
---|---|---|
committer | Gitea <gitea@fake.local> | 2020-04-05 18:59:15 +0200 |
commit | 6e1bd118c5ecc53016548072501591b329500870 (patch) | |
tree | 8447f6b7bbff0f423e9cf5d15ed709c630bed25e /src/main.cpp | |
parent | 7e9a7e4d5fa0f55b43180600d499f1d0ce6aded1 (diff) | |
parent | d5c2a58914fdeac4ef69382269b81d529e6d7c90 (diff) |
Merge branch 'ble-notifications' of JF/PineTime into develop
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 25a8a6c9..106d19eb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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(); @@ -85,6 +88,11 @@ void OnBleDisconnection() { bleController.Disconnect(); } +void OnNewNotification(const char* message, uint8_t size) { + notificationManager.Push(Pinetime::Controllers::NotificationManager::Categories::SimpleAlert, message, size); + systemTask->PushMessage(Pinetime::System::SystemTask::Messages::OnNewNotification); +} + void OnNewTime(current_time_char_t* currentTime) { auto dayOfWeek = currentTime->exact_time_256.day_date_time.day_of_week; auto year = currentTime->exact_time_256.day_date_time.date_time.year; @@ -96,6 +104,8 @@ void OnNewTime(current_time_char_t* currentTime) { dateTimeController.SetTime(year, month, day, dayOfWeek, hour, minute, second, nrf_rtc_counter_get(portNRF_RTC_REG)); + + systemTask->PushMessage(Pinetime::System::SystemTask::Messages::OnNewTime); } void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void) { @@ -121,13 +131,15 @@ 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(); ble_manager_set_new_time_callback(OnNewTime); ble_manager_set_ble_connection_callback(OnBleConnection); ble_manager_set_ble_disconnection_callback(OnBleDisconnection); + ble_manager_set_new_notification_callback(OnNewNotification); vTaskStartScheduler(); |