Public Access
Add a web UI to the clock firmware
- Web UI on port 80: live view of the display, choose the page (clock or a bitmap), bitmaps (list, show, live, edit, delete), draw / image upload with conversion in the browser, live mode, settings, Home Assistant - Live view from a shadow buffer in the BROSE9323 driver (shownPixel) - Settings in NVS with the original behaviour as defaults: schedule times, quarter hours, yawning Pikachu, No WiFi screen, flip time, status LED, Home Assistant broker (restart on change) - Bitmaps on LittleFS; new 320 KB partition, ota slots now 1.31 MB - DisplayController: pages, live mode, settings; app.cpp holds the objects - README for the recovery app; docs for the web UI - Tests: settings, time parsing, bitmap format and names, schedule with settings, pages and live mode (95 total) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c9e0800e36
commit
2b1ac12ed7
34 files changed
+1989
-117
No files matched your search
@@ -3,6 +3,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "logic/power_timer.h"
|
||||
#include "logic/settings.h"
|
||||
|
||||
// Power for the panels and the Nano (implemented by NanoLink)
|
||||
class DisplayPower
|
||||
@@ -18,22 +19,44 @@ public:
|
||||
class Frames
|
||||
{
|
||||
public:
|
||||
virtual void clock(int hour, int minute) = 0;
|
||||
virtual void clock(int hour, int minute, bool evening) = 0;
|
||||
// Shown instead of the clock while WiFi is down (the time keeps running without it)
|
||||
virtual void noWifi(int hour, int minute) = 0;
|
||||
// The bitmap selected as page
|
||||
virtual void page() = 0;
|
||||
// The image sent from the web UI's live mode
|
||||
virtual void live() = 0;
|
||||
virtual void logo() = 0;
|
||||
virtual void blank() = 0;
|
||||
};
|
||||
|
||||
// Decides what the display shows and when it is powered, based on the time and the two
|
||||
// Home Assistant switches. A frame is only sent when it changes. Pure logic, tested in
|
||||
// test/test_esp32.
|
||||
enum class Page : uint8_t
|
||||
{
|
||||
Clock, // Pikachu with the time
|
||||
Bitmap, // a bitmap (FlipdotFrames holds which one)
|
||||
};
|
||||
|
||||
// Decides what the display shows and when it is powered, based on the time, the settings,
|
||||
// the Home Assistant switches and the web UI. A frame is only sent when it changes. Pure
|
||||
// logic, tested in test/test_esp32.
|
||||
class DisplayController
|
||||
{
|
||||
public:
|
||||
DisplayController(DisplayPower &power, Frames &frames);
|
||||
|
||||
// Home Assistant "FlipDot Display Clock" switch: off shows the logo instead of the clock
|
||||
void setSettings(const ScheduleSettings &schedule, const ClockSettings &clock);
|
||||
|
||||
// What is shown during the day. Call pageChanged() when the bitmap itself changed.
|
||||
void setPage(Page page);
|
||||
void pageChanged();
|
||||
|
||||
// Live mode: show Frames::live() now, whatever the time, until stopLive() or
|
||||
// LIVE_TIMEOUT after the last showLive()
|
||||
void showLive(uint32_t now);
|
||||
void stopLive();
|
||||
bool liveActive() const;
|
||||
|
||||
// Home Assistant "FlipDot Display Clock" switch: off shows the logo instead of the page
|
||||
void setClockEnabled(bool enabled);
|
||||
// Home Assistant "FlipDot Display Power" switch: off clears the display and powers it off
|
||||
void setPowerEnabled(bool enabled);
|
||||
@@ -51,6 +74,8 @@ private:
|
||||
Unknown, // nothing sent since the last power on
|
||||
Clock,
|
||||
NoWifi,
|
||||
Page,
|
||||
Live,
|
||||
Logo,
|
||||
Blank,
|
||||
};
|
||||
@@ -59,17 +84,27 @@ private:
|
||||
Frames &_frames;
|
||||
PowerTimer _off_timer;
|
||||
|
||||
ScheduleSettings _schedule;
|
||||
ClockSettings _clock;
|
||||
Page _page = Page::Clock;
|
||||
|
||||
bool _clock_enabled = true;
|
||||
bool _power_enabled = true;
|
||||
|
||||
Screen _screen = Screen::Unknown;
|
||||
int _shown_hour = -1;
|
||||
int _shown_minute = -1;
|
||||
bool _shown_evening = false;
|
||||
uint32_t _content_revision = 0; // changed page, bitmap or live image
|
||||
uint32_t _shown_revision = 0;
|
||||
|
||||
bool _live = false;
|
||||
uint32_t _live_since = 0;
|
||||
|
||||
bool _wifi_lost = false;
|
||||
uint32_t _wifi_lost_since = 0;
|
||||
|
||||
void _ensureOn();
|
||||
void _showClock(int hour, int minute, bool no_wifi);
|
||||
void _showLogo();
|
||||
void _showBlank();
|
||||
void _showOnce(Screen screen);
|
||||
};
|
||||
Reference in new issue
Block a user