diff options
author | JF002 <JF002@users.noreply.github.com> | 2020-10-27 21:57:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-27 21:57:48 +0100 |
commit | cb9e8815d8bc6ce71fd8e97f3e3dae402658ce1f (patch) | |
tree | 1750edfed02f547102e468eca485caab3b08e98d /src/components/ble/NotificationManager.h | |
parent | c5bf09d21b2ed8e2435ec625e351594f58713924 (diff) | |
parent | 7de43a16608e599369867cb3cfa7d5776a5b6380 (diff) |
Merge pull request #108 from JF002/notification-ui
Improved notification UI
Diffstat (limited to 'src/components/ble/NotificationManager.h')
-rw-r--r-- | src/components/ble/NotificationManager.h | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/components/ble/NotificationManager.h b/src/components/ble/NotificationManager.h index daa1571b..49fe8306 100644 --- a/src/components/ble/NotificationManager.h +++ b/src/components/ble/NotificationManager.h @@ -1,29 +1,43 @@ #pragma once #include <array> +#include <atomic> 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}; + static constexpr uint8_t MessageSize{100}; struct Notification { + using Id = uint8_t; + Id id; + bool valid = false; + uint8_t index; std::array<char, MessageSize+1> message; Categories category = Categories::Unknown; }; + Notification::Id nextId {0}; - void Push(Categories category, const char* message, uint8_t messageSize); - Notification Pop(); + void Push(Notification&& notif); + Notification GetLastNotification(); + Notification GetNext(Notification::Id id); + Notification GetPrevious(Notification::Id id); + bool ClearNewNotificationFlag(); + bool AreNewNotificationsAvailable(); + static constexpr uint8_t MaximumMessageSize() { return MessageSize; }; + size_t NbNotifications() const; private: + Notification::Id GetNextId(); static constexpr uint8_t TotalNbNotifications = 5; std::array<Notification, TotalNbNotifications> notifications; uint8_t readIndex = 0; uint8_t writeIndex = 0; bool empty = true; + std::atomic<bool> newNotification{false}; }; } }
\ No newline at end of file |