Files
Flipdot-display/src/esp32/logic/page_render.h
T
mangavalkandClaude Opus 5.5 0166d0ee46 Stopwatch counts in real time from a start date, kept over a restart
The stopwatch counted with millis(), so it started at 0 after every
restart and would overflow after 49 days. It now keeps the real start
time (UTC ms) and the time counted before a pause, stored in NVS
(system/stopwatch_store) on every change, so it keeps counting while
the display is off or restarting. Stop pauses, Start continues, and the
Stopwatch tab can set the start to a date and time (local, summer time
by mktime) to count from, e.g. days since an event. Start, stop and set
need the synced time.

New page formats: 12d 4:05:09 and 3w 2d.

Version 2.19.0, tested on the display over OTA (set start, future and
invalid dates refused, pause, restart).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 22:22:32 +02:00

47 lines
1.9 KiB
C++

#pragma once
#include <stdint.h>
#include "logic/font.h"
#include "logic/life.h"
#include "logic/local_time.h"
#include "logic/page.h"
// Draws a dynamic page into a full screen bitmap (logic/bitmap_format.h). Used for the
// display and for the previews in the web UI. Pure logic, tested in test/test_esp32.
// Where the page gets its bitmaps, fonts, Home Assistant values and the stopwatch
class PageResources
{
public:
// Loads a bitmap (background or image); false when it is gone
virtual bool background(const char *name, uint8_t *bitmap) = 0;
// A font by name; a font without data when it is gone ("Normal" is used then)
virtual Font font(const char *name) = 0;
// The current value of a Home Assistant element; nullptr when not known
virtual const char *haValue(const PageElement &element) = 0;
virtual uint64_t stopwatchMs() { return 0; }
virtual bool stopwatchRunning() { return false; }
// The running Game of Life of the shown page when this element starts like it
// (sameLifeStart); nullptr otherwise (the start is drawn then)
virtual const LifeRunner *life(const PageElement &) { return nullptr; }
};
// The area an element covers on the screen (for the editor), may be partly off screen.
// For scrolling texts, the window.
struct ElementBox
{
int16_t x = 0;
int16_t y = 0;
int16_t width = 0;
int16_t height = 0;
};
// now_ms: a running millisecond counter (millis()), for scrolling. boxes: nullptr, or room
// for page.element_count boxes.
// Returns the ms until the page looks different again (scrolling, seconds, a running
// stopwatch, the next generation of a Game of Life), or 0 when it only changes with the minute or its content (Home Assistant
// values, the stopwatch being started or stopped).
uint32_t renderPage(const DynamicPage &page, const LocalTime &time, uint32_t now_ms, PageResources &resources,
uint8_t *bitmap, ElementBox *boxes = nullptr);