Files
Flipdot-display/src/esp32/web/page_json.h
T
mangavalkandClaude Opus 5.5 a91d2550d7 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>
2026-10-20 17:52:25 +02:00

23 lines
1.2 KiB
C

#pragma once
#include <ArduinoJson.h>
#include "logic/page.h"
// Dynamic pages (logic/page.h) as JSON for the web UI:
// {slots: [{start: "08:00", bitmap: "Pikachu"}],
// elements: [{type: "clock"|"date"|"ha"|"text", x, y, align: "left"|"center"|"right",
// overlay: "top"|"box"|"invert", font, format, language: "nl"|"en",
// decimals (-1 = as received), text, suffix, entity, attribute, factor,
// scroll_width, scroll_speed, target ("YYYY-MM-DDTHH:MM"),
// show: "number"|"duration"|"time"|"map", input_unit: "s"|"min"|"h",
// auto_unit, absolute, map, bar_width, bar_height, bar_max, bar_frame,
// day_offset}]}
// type also "countdown", "stopwatch", "image", "bar", "life". Game of Life elements also
// have start: "random"|"pattern"|"rotate"|"shuffle" and generations (0: no limit); the
// other fields mean what logic/page.h says. Texts use the UTF-8 degree sign.
void pageToJson(const DynamicPage &page, JsonObject out);
// Returns nullptr or a message for the user. Validates the page (validatePage()).
const char *pageFromJson(JsonVariantConst in, DynamicPage &page);