Public Access
An Off screen turns on dimmed for the Toast's duration so the user can see what beeped. It isn't user activity: the timeouts aren't restarted, and a key pressed meanwhile reaches the App. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
34 lines
985 B
C++
34 lines
985 B
C++
#pragma once
|
|
|
|
#include <functional>
|
|
|
|
#include "event_bus.h"
|
|
#include "settings.h"
|
|
#include "toast_queue.h"
|
|
|
|
namespace roro {
|
|
|
|
// Presents Notifications as Toasts. Each Toast gets a short beep and LED flash (when Sound is on)
|
|
// as it appears, so a burst of Notifications alerts once per Toast, not all at once.
|
|
class Notifier {
|
|
public:
|
|
Notifier(EventBus& bus, const Settings& settings);
|
|
void update(uint32_t nowMs); // alerts for a newly shown Toast, ends the LED flash
|
|
ToastQueue& toasts() { return toasts_; }
|
|
|
|
// Called when a Toast appears, with the time it will disappear (e.g. to light the screen).
|
|
std::function<void(uint32_t nowMs, uint32_t untilMs)> onShow;
|
|
|
|
private:
|
|
void alert(NotificationLevel level, uint32_t nowMs);
|
|
|
|
const Settings& settings_;
|
|
static constexpr uint32_t kToastMs = 3000;
|
|
ToastQueue toasts_{kToastMs, 8};
|
|
uint32_t ledOffAtMs_ = 0;
|
|
bool ledOn_ = false;
|
|
uint32_t alertedId_ = 0;
|
|
};
|
|
|
|
} // namespace roro
|