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>
57 lines
2.8 KiB
Python
57 lines
2.8 KiB
Python
"""Generate self-contained remote packages from the maintained board profiles."""
|
|
import argparse
|
|
from pathlib import Path
|
|
import re
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
REPO = 'https://github.com/MaxGramser/homeassistant_espscreen'
|
|
REFS = {'cyd': 'main', 'guition': 'main'}
|
|
|
|
def generate(board, text=None):
|
|
source = ROOT / ('home-like-2432s028.yaml' if board == 'cyd' else 'guition-4848s040.yaml')
|
|
s = source.read_text() if text is None else text
|
|
# The owner's wizard YAML supplies wifi/API/OTA credentials. No shared keys.
|
|
s = re.sub(r'^ encryption:\n key: !secret api_encryption_key\n', '', s, flags=re.M)
|
|
s = re.sub(r'^ota:\n.*?(?=^\w)', '', s, flags=re.M | re.S)
|
|
s = re.sub(r'^wifi:\n.*?(?=^\w)', '', s, flags=re.M | re.S)
|
|
# Fonts are fetched over HTTPS; the headers come with the external component.
|
|
components = '[xpt2046, smart_display]' if board == 'cyd' else '[smart_display]'
|
|
external = f'''external_components:
|
|
- source:
|
|
type: git
|
|
url: {REPO}.git
|
|
ref: {REFS[board]}
|
|
path: components
|
|
refresh: 0s
|
|
components: {components}
|
|
|
|
'''
|
|
s = re.sub(r'^external_components:\n.*?(?=^\w)', lambda m: external, s, flags=re.M | re.S)
|
|
s = re.sub(r'file: ["\']fonts/([^"\']+)["\']', lambda m: 'file: "https://raw.githubusercontent.com/MaxGramser/homeassistant_espscreen/main/fonts/' + m[1] + '"', s)
|
|
# A screen gets its values from ESP Screen Manager while it runs, entity changes included:
|
|
# a fixed Home Assistant subscription in a board profile is a leftover.
|
|
for section in ['sensor', 'text_sensor']:
|
|
match = re.search(r'^' + section + r':\n.*?(?=^[a-zA-Z_]+:|\Z)', s, re.M | re.S)
|
|
if match and re.search(r'^ - platform: homeassistant$', match[0], re.M):
|
|
raise ValueError(f'{source.name}: a {section} subscribes to Home Assistant; runtime tiles bring their own values')
|
|
if '!secret' in s: raise ValueError('Remote package still depends on local secrets')
|
|
return '# GENERATED by tools/generate_packages.py; edit the source board profile.\n' + s
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--check', action='store_true')
|
|
args = parser.parse_args()
|
|
for board in REFS:
|
|
source = ROOT / ('home-like-2432s028.yaml' if board == 'cyd' else 'guition-4848s040.yaml')
|
|
if not source.exists(): continue
|
|
path = ROOT / 'packages' / f'{board}.yaml'
|
|
expected = generate(board)
|
|
if args.check:
|
|
if not path.exists() or path.read_text() != expected: raise SystemExit(f'Outdated: {path}')
|
|
else:
|
|
path.parent.mkdir(exist_ok=True)
|
|
path.write_text(expected)
|
|
print(f'{board}: package ' + ('verified' if args.check else 'generated'))
|
|
|
|
if __name__ == '__main__': main()
|