diff options
author | JF <jf@codingfield.com> | 2020-03-28 19:05:28 +0100 |
---|---|---|
committer | JF <jf@codingfield.com> | 2020-03-28 19:05:28 +0100 |
commit | baca0fc3e59e88420d6c7983ad133fe63c794ec0 (patch) | |
tree | e817de0b040712bb95129520fcc51eae59ecc161 /src/Components/Ble/NotificationManager.h | |
parent | 68240704c7a60534342cfc0157564f11cf82d9d8 (diff) |
Encapsulate Notification management in NotificationManager. It implement a static array of notifications to avoid dynamic allocation.
Diffstat (limited to 'src/Components/Ble/NotificationManager.h')
-rw-r--r-- | src/Components/Ble/NotificationManager.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/Components/Ble/NotificationManager.h b/src/Components/Ble/NotificationManager.h new file mode 100644 index 00000000..8edd6828 --- /dev/null +++ b/src/Components/Ble/NotificationManager.h @@ -0,0 +1,29 @@ +#pragma once + +#include <array> + +namespace Pinetime { + namespace Controllers { + class NotificationManager { + public: + enum class Categories {Unknown, SimpleAlert, Email, News, IncomingCall, MissedCall, Sms, VoiceMail, Schedule, HighProriotyAlert, InstantMessage }; + static constexpr uint8_t MessageSize = 18; + + struct Notification { + std::array<char, MessageSize> message; + Categories category = Categories::Unknown; + }; + + void Push(Categories category, const char* message, uint8_t messageSize); + Notification Pop(); + + + private: + static constexpr uint8_t TotalNbNotifications = 5; + std::array<Notification, TotalNbNotifications> notifications; + uint8_t readIndex = 0; + uint8_t writeIndex = 0; + bool empty = true; + }; + } +}
\ No newline at end of file |