Free memory on the CYD and drop the old manual profile (0.2.50)
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>
This commit is contained in:
@@ -1,17 +1,14 @@
|
||||
"""Offline regression tests for installation, calibration and safe export."""
|
||||
"""Offline regression tests for the guided USB touch calibration."""
|
||||
import copy
|
||||
from pathlib import Path
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
import zipfile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / 'tools'))
|
||||
import calibrate
|
||||
import new_device
|
||||
import export_bundle
|
||||
|
||||
|
||||
def measurements():
|
||||
@@ -86,41 +83,4 @@ class CalibrationTests(unittest.TestCase):
|
||||
self.assertEqual(next(Path(tmp).glob('*.bak-*')).read_text(), 'old')
|
||||
|
||||
|
||||
class InstallationTests(unittest.TestCase):
|
||||
def test_unique_secrets_and_no_overwrite(self):
|
||||
with tempfile.TemporaryDirectory() as a, tempfile.TemporaryDirectory() as b:
|
||||
new_device.create(a, 'display-a', 'Display A')
|
||||
new_device.create(b, 'display-b', 'Display B')
|
||||
original = (Path(a)/'secrets.yaml').read_text()
|
||||
self.assertNotEqual(original, (Path(b)/'secrets.yaml').read_text())
|
||||
self.assertNotIn('WILL_BE_UNIQUELY_GENERATED', original)
|
||||
with self.assertRaises(ValueError): new_device.create(a, 'new', 'New')
|
||||
self.assertEqual(original, (Path(a)/'secrets.yaml').read_text())
|
||||
|
||||
def test_invalid_device_name(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
for name in ('../oops', 'UPPER', 'has space', 'trailing-'):
|
||||
with self.assertRaises(ValueError): new_device.create(tmp, name, 'Test')
|
||||
self.assertEqual(list(Path(tmp).iterdir()), [])
|
||||
|
||||
def test_export_is_neutral_and_has_required_sources(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
output = Path(tmp)/'starter.zip'
|
||||
export_bundle.export(ROOT, output)
|
||||
with zipfile.ZipFile(output) as archive:
|
||||
names = archive.namelist()
|
||||
for forbidden in ('secrets.yaml', 'device.yaml', 'calibration.yaml', '.git/', '.esphome/', '.log', '.bin', '.json'):
|
||||
self.assertFalse(any(('/'+forbidden in n if forbidden.endswith('/') else n.endswith(forbidden) if forbidden.startswith('.') else n.endswith('/'+forbidden)) for n in names), forbidden)
|
||||
self.assertIn('cyd-display/.gitignore', names)
|
||||
base = archive.read('cyd-display/home-like-2432s028.yaml').decode()
|
||||
values = dict(re.findall(r'^ (\w+): "([^"]*)"', base, re.M))
|
||||
self.assertEqual(values['TOUCH_AFFINE_XX'], '1.000000000')
|
||||
self.assertEqual(values['DIRECT_ACTIONS'], 'false')
|
||||
for i in range(1,11):
|
||||
self.assertRegex(values[f'TILE{i}_ENTITY'], r'\.(example_|unused_)')
|
||||
archive.extractall(tmp)
|
||||
new_device.create(Path(tmp)/'cyd-display', 'fresh-board', 'Fresh board')
|
||||
with self.assertRaises(FileExistsError): export_bundle.export(ROOT, output)
|
||||
|
||||
|
||||
if __name__ == '__main__': unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user