08197c4ae1
The CYD restarted under load: a slider fill rounded less than its track made LVGL draw the fill into a buffer of its own size on every redraw (15-20 KB), and when that allocation failed the refresh retried until the task watchdog fired. Track and fill now share one radius, and tests/test_layer_free.py keeps every layer-making style out of the profiles, the packages and the firmware headers. A tile keeps only the fields every card uses; climate modes, select options, weather, sun and timer times, the media title and the vacuum rows moved to an Extra block that exists only while a state needs one, and the state copy became a fingerprint. runtime_tiles::model went from 24,296 to 8,216 bytes. The manual profile that bound tiles to fixed entities in the YAML is gone: 331 TILE* substitutions, DYNAMIC_TILES/TILE_COUNT/DIRECT_ACTIONS, the 80 Home Assistant subscriptions, its tap handlers and scripts, its own vacuum card, its guides and helper scripts, and the five stale header copies in the repository root that two C++ tests were compiling instead of the components. esphome config of both Easy profiles is unchanged by that cleanup. tile_scroll and the wake overlay no longer light up on a tap, and the debug sensor min_free reports the lowest free heap since boot. On the bench CYD static RAM went from 32.0% to 22.8% and free heap from 64-77 KB to about 101 KB, with 78 KB as the lowest point over thirteen hours without a restart. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
48 lines
2.4 KiB
C++
48 lines
2.4 KiB
C++
#include "components/smart_display/runtime_model.h"
|
|
#include "components/smart_display/cyd_ui.h"
|
|
#include <cassert>
|
|
|
|
int main() {
|
|
cyd::TouchGuard guard;
|
|
guard.begin(0); guard.consume();
|
|
assert(!guard.accept(100,1)); assert(!guard.accept_slider(100,1));
|
|
guard.begin(200); assert(guard.accept(300,1));
|
|
|
|
// A tile keeps the fingerprint of its last state message, not the message itself.
|
|
auto rev=[](const char *state){ return runtime_tiles::state_revision(state,""); };
|
|
runtime_tiles::Tile t;
|
|
t.revision=rev("off"); t.begin(100);
|
|
assert(t.loading(200)); assert(t.awaiting_action(200));
|
|
t.observe(rev("off")); assert(!t.confirmed);
|
|
t.observe(rev("on")); assert(t.confirmed);
|
|
assert(t.loading(999)); assert(!t.loading(1100));
|
|
t.begin(2000); t.observe(rev("on"));
|
|
assert(t.loading(7999)); assert(!t.loading(8000)); assert(!t.awaiting_action(8000));
|
|
t.begin(0xFFFFFFF0); assert(t.loading(20));
|
|
t.begin(100,true);
|
|
assert(t.loading(1099)); assert(!t.awaiting_action(1099)); assert(!t.loading(1100));
|
|
|
|
// A plain switch changes state with identical attributes. This must confirm
|
|
// immediately instead of leaving the tile blocked for the six-second timeout.
|
|
runtime_tiles::Tile sw;
|
|
sw.entity="switch.printer";
|
|
sw.revision=runtime_tiles::state_revision("off","{}"); sw.begin(100);
|
|
assert(sw.loading(249));
|
|
sw.observe(runtime_tiles::state_revision("on","{}"));
|
|
assert(!sw.loading(250));
|
|
sw.begin(300); sw.observe(runtime_tiles::state_revision("on","{}"));
|
|
assert(sw.loading(1000)); // Repeated identical data is not confirmation.
|
|
assert(!sw.loading(6300));
|
|
sw.entity="input_boolean.test"; sw.begin(0xFFFFFFF0); sw.observe(rev("off"));
|
|
assert(sw.loading(20)); assert(!sw.loading(200));
|
|
|
|
// The fingerprint follows state and attributes, and the streaming writer (what receive() hands to
|
|
// ArduinoJson) gives the same value as hashing the joined text.
|
|
assert(runtime_tiles::state_revision("on","{\"brightness\":255}")!=runtime_tiles::state_revision("on","{\"brightness\":254}"));
|
|
assert(runtime_tiles::state_revision("on","{}")!=runtime_tiles::state_revision("off","{}"));
|
|
assert(runtime_tiles::state_revision("o","n{}")!=runtime_tiles::state_revision("on","{}"));
|
|
runtime_tiles::Fingerprint f; f.add("on"); f.write('\n');
|
|
const char json[]="{\"a\":1}"; f.write(reinterpret_cast<const uint8_t*>(json),sizeof(json)-1);
|
|
assert(f.value==runtime_tiles::state_revision("on","{\"a\":1}"));
|
|
}
|