Public Access
Add widget kit, input layer with Compose Key, Launcher and demo apps
Steps 5 and 6 of M0. - lib/ui (host-tested): ListModel, LineEditor (UTF-8, byte-limited), wrapText, ToastQueue, DialogModel - lib/input (host-tested): KeyMapper turns keyboard state into logical keys (Fn arrows, ` Back, Fn+` Home) and composes accents with opt - src/ui: off-screen 16-bit frame pushed in one transfer (fixes the flicker), Status Bar, list, text, line editor, dialog, Toast widgets, Notifier (Toast + beep + LED), vendored public-domain Latin-1 fonts - Apps: minimal Launcher, Widget demo, Diagnostics (SD erase now behind a confirmation dialog) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#include "notifier.h"
|
||||
|
||||
#include <M5Cardputer.h>
|
||||
|
||||
namespace roro {
|
||||
|
||||
namespace {
|
||||
constexpr int kLedPin = 21; // WS2812, powered with the backlight rail (G38)
|
||||
}
|
||||
|
||||
Notifier::Notifier(EventBus& bus, const Settings& settings) : settings_(settings) {
|
||||
bus.subscribe(EventType::Notification, [this](const Event& e) { present(e); });
|
||||
}
|
||||
|
||||
void Notifier::present(const Event& e) {
|
||||
auto level = static_cast<NotificationLevel>(e.a);
|
||||
uint32_t now = millis();
|
||||
toasts_.push(e.text, level, now);
|
||||
|
||||
if (!settings_.getBool(Setting::Sound)) return;
|
||||
M5Cardputer.Speaker.tone(level == NotificationLevel::Warning ? 880 : 1760, 60);
|
||||
switch (level) {
|
||||
case NotificationLevel::Warning: rgbLedWrite(kLedPin, 40, 16, 0); break;
|
||||
case NotificationLevel::Message: rgbLedWrite(kLedPin, 0, 40, 0); break;
|
||||
default: rgbLedWrite(kLedPin, 0, 16, 40); break;
|
||||
}
|
||||
ledOn_ = true;
|
||||
ledOffAtMs_ = now + 150;
|
||||
}
|
||||
|
||||
void Notifier::update(uint32_t nowMs) {
|
||||
if (ledOn_ && static_cast<int32_t>(nowMs - ledOffAtMs_) >= 0) {
|
||||
rgbLedWrite(kLedPin, 0, 0, 0);
|
||||
ledOn_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace roro
|
||||
Reference in New Issue
Block a user