From db3144c4f9b0462e0e4ad962f595408f9adfb76c Mon Sep 17 00:00:00 2001 From: Reinhold Gschweicher Date: Sat, 19 Feb 2022 00:05:06 +0100 Subject: [PATCH] main: one notification per notification category Notifications store the title and the message in the same array, separated by a `\0`. Add the notification category as title to the notifications. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vitae aliquet nec ullamcorper sit amet. Id aliquet risus feugiat in ante metus dictum at. Ut porttitor leo a diam sollicitudin. Ultrices tincidunt arcu non sodales neque sodales ut etiam sit. Pellentesque dignissim enim sit amet. Urna nec tincidunt praesent semper feugiat nibh sed pulvinar proin. Tellus id interdum velit laoreet id donec ultrices tincidunt. Viverra maecenas accumsan lacus vel facilisis volutpat est velit egestas. Volutpat consequat mauris nunc congue. --- main.cpp | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 4aee494..7c76ed1 100644 --- a/main.cpp +++ b/main.cpp @@ -376,14 +376,48 @@ public: SDL_RenderPresent(renderer); } + // prepared notficitions, one per message category + const std::vector notification_messages { + "category:\nUnknown", + "Lorem ipsum\ndolor sit amet,\nconsectetur adipiscing elit,\n", + "SimpleAlert", + "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Email:", + "Vitae aliquet nec ullamcorper sit amet.", + "News:", + "Id\naliquet\nrisus\nfeugiat\nin\nante\nmetus\ndictum\nat.", + "IncomingCall:", + "Ut porttitor leo a diam sollicitudin.", + "MissedCall:", + "Ultrices tincidunt arcu non sodales neque sodales ut etiam sit.", + "Sms:", + "Pellentesque dignissim enim sit amet.", + "VoiceMail:", + "Urna nec tincidunt praesent semper feugiat nibh sed pulvinar proin.", + "Schedule:", + "Tellus id interdum velit laoreet id donec ultrices tincidunt.", + "HighProriotyAlert:", + "Viverra maecenas accumsan lacus vel facilisis volutpat est velit egestas.", + "InstantMessage:", + "Volutpat consequat mauris nunc congue.", + }; + size_t notification_idx = 0; // which message to send next void send_notification() { Pinetime::Controllers::NotificationManager::Notification notif; - const std::string message("Lorem Ipsum"); - std::copy(message.begin(), message.end(), notif.message.data()); - notif.message[message.size() - 1] = '\0'; - notif.size = message.size(); - notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert; + const std::string &title = notification_messages.at(notification_idx*2); + const std::string &message = notification_messages.at(notification_idx*2+1); + std::copy(title.begin(), title.end(), notif.message.data()); + notif.message[title.size()] = '\0'; // title and message is \0 separated + std::copy(message.begin(), message.end(), notif.message.data()+title.size()+1); + notif.message[title.size() + 1 + message.size()] = '\0'; // zero terminate the message + notif.size = title.size() + 1 + message.size(); + notif.category = static_cast(notification_idx % 11); notificationManager.Push(std::move(notif)); + // send next message the next time + notification_idx++; + if (notification_idx >= notification_messages.size()) { + notification_idx = 0; + } } // can't use SDL_PollEvent, as those are fed to lvgl