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:
Max Gramser
2026-09-16 08:06:41 +02:00
parent 79a84a4c77
commit 08197c4ae1
45 changed files with 854 additions and 12896 deletions
-232
View File
@@ -355,7 +355,6 @@ screen also gets a new `SCREEN_FIRMWARE_VERSION` in both board profiles.
- [Complete installation from ESP Screens](docs/EASY_SETUP.md)
- [Guition hardware, mounting, and rotation](docs/GUITION.md)
- [CYD calibration and USB diagnostics](docs/CALIBRATING.md)
- [Physical acceptance test](docs/ACCEPTANCE.md)
- [Instructions for developers and LLMs](AGENTS.md)
Give a developer or LLM a clean copy of this repository and, for example:
@@ -368,234 +367,3 @@ Give a developer or LLM a clean copy of this repository and, for example:
A successful build doesn't prove the physical touch or panel image is correct. The owner
must check the display and perform the requested taps.
<details>
<summary>Older manual CYD installation via a computer</summary>
The route below uses the older manual profile with up to ten
tiles. Its position constraints don't apply to ESP Screen Manager's twenty
runtime tiles. For new installations, prefer the route
above; the manual instructions remain available for maintenance.
# CYD Home Assistant control screen
From a fresh **ESP32-2432S028 with ILI9341 + XPT2046** to a calibrated
Home Assistant screen, over USB. With light control, scenes/scripts, climate,
vacuum, up to ten tiles, and fixed pages. With six tiles or fewer,
pagination disappears. Standby starts after ten minutes by default.
**Manual installation via a computer:** you don't need to create a Home Assistant token
or install an ESPHome add-on to flash from a computer.
## Working with an LLM or developer
Give it the unpacked folder and this prompt:
> First read AGENTS.md and README.md. Guide me through a new installation
> on an ESP32-2432S028 connected via USB, with my own Home
> Assistant. Check the board, the serial port, and the Python environment.
> Create a local device.yaml profile; don't use any existing personal
> entities or panel calibration. Walk through USB calibration, HA pairing,
> tile configuration, and the acceptance test. Ask me for physical taps when
> needed. Keep keys and passwords in local files, and report
> which checks were actually carried out.
The assistant can read the code and logs, but can't see the physical screen
on its own. You check the display and perform the requested taps.
## 1. Check what you need
- The intended board: ESP32-2432S028, 320×240, **ILI9341 display and resistive
XPT2046 touch**. Boards exist with almost the same name and a different
display controller. This guide doesn't cover those variants.
- A USB **data cable** and a computer running macOS, Linux, or Windows.
- Python **3.11–3.14**, internet access for the first build, and a few GB of free space.
The version limit comes from the tested ESPHome package; don't use Python 3.15.
- A 2.4GHz Wi-Fi network; Home Assistant must be able to reach the board over
the network. Keep the Wi-Fi password available locally.
- Access to Home Assistant to choose entities and add ESPHome.
Preferably keep only one ESP board connected at a time. Note the variant and
the MAC address from the boot/upload logs.
## 2. Set up the work environment
Clone [the repository](https://github.com/MaxGramser/homeassistant_espscreen)
or unpack the starter ZIP. Open a terminal **in the code folder**. All commands below
are run from that folder.
macOS/Linux:
```sh
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
```
Windows PowerShell:
```powershell
py -3.13 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
```
If activating PowerShell is blocked, use
`.\.venv\Scripts\python.exe` directly instead of `python`; no system change is
needed. Then check:
```sh
python --version
python -m esphome version
python -m serial.tools.list_ports
```
Expect **ESPHome 2026.6.2**. This repo includes a custom touch driver that's
tested against this version. Don't silently upgrade during an installation.
See also the [official ESPHome installation guide](https://esphome.io/install/).
Note the port: for example `/dev/cu.usbserial-130` on macOS,
`/dev/ttyUSB0` on Linux, or `COM3` on Windows. Further down, `<USB_PORT>`
appears; always replace it with the actual port, without angle brackets.
## 3. Create your own device profile
Choose a unique name, for example `display-kitchen`:
```sh
python tools/new_device.py --name display-kitchen --friendly-name "Display kitchen"
```
This creates three local files and overwrites nothing:
| File | What you edit in it |
|---|---|
| `device.yaml` | Device name, room, tiles, and behavior |
| `calibration.yaml` | Calibration for this one physical panel; the wizard writes this |
| `secrets.yaml` | Wi-Fi, API encryption key, OTA and fallback password |
The keys are generated uniquely. In `secrets.yaml`, only fill in your
`wifi_ssid` and `wifi_password`. Leave the generated keys as they are and
keep this file with your own configuration. Don't include it in the ZIP.
You'll need the API encryption key later for HA pairing; copy it
locally from the file, not through a public chat.
Do these files already exist? Work in a new copy of the folder for a new
screen. Don't erase the keys/calibration of a working screen.
`device.yaml` imports the base configuration and your calibration. It also overwrites
**all hidden tile positions**, so they don't keep tracking someone else's
entities. Start with the six example tiles. `DIRECT_ACTIONS: "false"`
prevents direct HA control during the initial installation. At this
stage, don't yet create HA automations that react to the action sensor.
## 4. First USB flash and calibration
First check the configuration (ESPHome masks secrets by default):
```sh
python -m esphome config device.yaml
```
Flash calibration mode, which works without an HA connection:
```sh
python -m esphome -s CALIBRATION_ON_BOOT true run device.yaml --device <USB_PORT>
```
The first build can take several minutes. After uploading, five
crosshairs appear on a dark screen. `run` keeps showing logs: stop **only the
log reader with Ctrl+C** before starting the calibration wizard. The board stays on.
Now follow [docs/CALIBRATING.md](docs/CALIBRATING.md): three taps are
collected per target, the four corners determine the correction, and the center is an
independent check. Then you flash the result and measure again.
**Never copy the measurements from another panel.**
## 5. Pair with Home Assistant
After a successful calibration, flash the normal mode:
```sh
python -m esphome run device.yaml --device <USB_PORT>
```
Check the logs for the Wi-Fi IP, a stable boot, and the device name. Ctrl+C closes
the log reader. The screen should now show the normal tile page.
1. In HA, open **Settings → Devices & services**.
2. Choose the discovered ESPHome device, or **Add integration → ESPHome**.
3. Use `display-kitchen.local` or the IP address from the logs; API port **6053**.
4. Enter the `api_encryption_key` from your local `secrets.yaml` if asked.
5. Check that the device name is correct and the status becomes online.
6. Open this ESPHome integration's options/configuration and enable
**Allow the device to perform Home Assistant actions**.
The exact wording/location of this option varies by HA version. See the
[official integration guide](https://www.home-assistant.io/integrations/esphome).
The HA integration connects to the board; the ESPHome Device Builder/add-on is
optional and is a separate feature.
## 6. Configure your own tiles
Follow [docs/TILES.md](docs/TILES.md). Collect the real entity IDs in HA,
check supported attributes/actions, and edit `device.yaml`. Use
short titles. Once you've checked everything:
```yaml
substitutions:
DIRECT_ACTIONS: "true"
TILE_COUNT: "6"
```
These are changes in the **existing** substitutions map, not a second map
at the bottom of the file. Build and flash again with `run device.yaml`. The tiles
will then follow the real HA state. An active API connection alone
doesn't prove that HA has been granted permission for actions.
## 7. Handover and testing
Run through [docs/ACCEPTANCE.md](docs/ACCEPTANCE.md). That covers an independent
touch measurement, both pages if present, long press, sliders, climate,
vacuum, real HA state, and the correct action effects. The built-in
render test doesn't control any HA devices itself:
```sh
python diagnostics/run_ui_test.py --host display-kitchen.local --name display-kitchen
```
Keep with this person: `device.yaml`, `calibration.yaml`, `secrets.yaml`, the
measurement files, the ESPHome version used, and a short handover report.
For later updates you can keep using USB or use OTA:
```sh
python -m esphome run device.yaml --device display-kitchen.local
```
Don't change the name/API key without also updating the HA pairing.
For troubleshooting: [docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md).
## Handing this code to the next person
Use the exporter instead of copying your entire working folder:
```sh
python tools/export_bundle.py --output dist/cyd-starter.zip
```
The ZIP contains the code, local fonts, licenses, guides, and neutral
examples. The base defaults are neutralized for the recipient.
No `secrets.yaml`, personal `device.yaml`, measurements, logs, `.git`, `.esphome`,
Python environment, or firmware backups. The exporter refuses to overwrite an
existing ZIP; choose a different filename for a new version.
The original base is from
[akuehlewind/ESPHome-touch-display-mount](https://github.com/akuehlewind/ESPHome-touch-display-mount).
Project, ESPHome driver, and font licenses are in `LICENSE`,
`components/xpt2046/LICENSE`, and `fonts/` respectively. Historical board diagnostics are in
[CYD_STABILITY.md](CYD_STABILITY.md); for a **new** installation, follow the
guides above.
</details>