Public Access
Game of Life page element and built-in page
A new page element runs Conway's Game of Life in an area (the whole display by default), one per page. Start: random dots, one pattern, or the icons whose names start with a text in turn or in random order. Edges: wrap around, dead, or a hidden margin where gliders fly out of view (leftovers that stay put in the margin are cleared, so a glider gun runs cleanly). It restarts when the board is still or repeats within 16 generations and/or after a number of generations, after a hold time (an empty board at once). logic/life holds the board and timing (tested), display/life_player runs the board of the shown page, ticked before each frame; frames are paced like scrolling text. The element reuses existing fields, so the page format stays the same. The Icons tab has a library of 17 LifeWiki patterns (checked with a simulation), and the built-in page "Game of Life" shuffles through the life_ icons. About 12 KB flash, 8 KB RAM. Version 2.17.0, tested on the display over OTA. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
948087077d
commit
a91d2550d7
29 files changed
+1402
-31
No files matched your search
@@ -3,6 +3,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "logic/font.h"
|
||||
#include "logic/life.h"
|
||||
#include "logic/local_time.h"
|
||||
#include "logic/page.h"
|
||||
|
||||
@@ -21,6 +22,9 @@ public:
|
||||
virtual const char *haValue(const PageElement &element) = 0;
|
||||
virtual uint32_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.
|
||||
@@ -36,7 +40,7 @@ struct ElementBox
|
||||
// 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), or 0 when it only changes with the minute or its content (Home Assistant
|
||||
// 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);
|
||||
Reference in new issue
Block a user