A board file for the Elecrow CrowPanel 7.0" (DIS08070H, ESP32-S3-WROOM-1-N4R8): 800x480 through mipi_rgb, GT911 on the ESP32-S3's USB pins (elecrow_usb_phy.h frees them, behind a flag only this board sets), the Guition's vertical sizes across a wider page, no rotation. Its 4 MB of flash take the CYD's budget: a partition table of the component's (smart_display: partitions: 4mb_wide_slots, 1,984 KB slots), the icon fonts at 2 bits a pixel and the TLS client only bring the firmware to 1,865,440 bytes, 91.8 % of a slot, with camera images kept. docs/ELECROW.md has the numbers and the trade. The add-on reads a large board's name from the type sensor's value, the editor offers the board under New screen and draws the wide preview, tools/check.sh builds it with the budget, render_topbar and capture_ui take the panel's size. Firmware 0.2.79; the CYD image is unchanged (1,633,760 bytes). This fork builds from gittea.trippedonmy.name/Xandrossian/homeassistant_espscreen: the packages, the fonts, the component and the add-on repository point there instead of GitHub.
7.6 KiB
One screen, three files: the shared core and the board files
Since app 0.2.84 a screen's ESPHome configuration is one shared file plus one file per board, put together by ESPHome's own packages mechanism. Before, each board was a 5,000-line profile of which 87 % was the same text as the other board's; every change had to be made twice and the two had already drifted apart in small ways.
| File | What it holds |
|---|---|
packages/core.yaml |
Everything every board shares: the LVGL tree (tiles, cards, overlays, the touch test page), the scripts, the API actions, the entities, the fonts, the globals, and Wi-Fi that never dozes (power_save_mode: none, firmware 0.2.74+; the network itself stays in the screen's own YAML). It contains no number that depends on the board: every such value is a ${NAME} the board file defines. |
packages/boards/cyd-2432s028.yaml |
The CYD: its hardware (ILI9341 over SPI, XPT2046 resistive touch, backlight, LED), its sizes and font sizes, the code the shared lambdas take from it (the hooks, below), and what only a CYD has: the calibration wizard, a page swipe by LVGL's gesture, ui_self_test, the two scripts that drive the backlight as a light action, its climate card layout. |
packages/boards/guition-4848s040.yaml |
The Guition: its hardware (ST7701S RGB, GT911, PSRAM), its sizes, its hooks, and what only a Guition has: camera images (online_image, the alert's picture frame), the Rotation entity, the page swipe from the glass edge, the snapshot diagnostics, the climate card with its fan and swing card, the wider tile labels (!extend on each tile). |
packages/boards/elecrow-crowpanel7.yaml |
The Elecrow CrowPanel 7.0" (app 0.2.93): the Guition's kind at 800×480 on 4 MB of flash. Its hardware (the RGB panel through mipi_rgb, GT911, the USB pins freed for the touch I2C), the Guition's vertical sizes across a wider page, the same hooks and sections as the Guition's file except the Rotation (a landscape panel does not turn), and what the flash asks for: a partition table of the component's (smart_display: partitions), the icon fonts at 2 bits a pixel (font: with !extend). docs/ELECROW.md has the numbers. |
packages/cyd.yaml, packages/guition.yaml, packages/elecrow.yaml |
What a screen installed from ESP Screens builds from over GitHub, unchanged in name and place: ESP Screen Manager writes every screen's YAML with files: [packages/<board>.yaml]. Each is a few lines: where the fonts are, the components from GitHub, and packages: {core: !include core.yaml, board: !include boards/<board>.yaml}. |
home-like-2432s028.yaml, guition-4848s040.yaml, elecrow-crowpanel7.yaml |
The same files for a build from a checkout (the bench, the manual route of README_EXTENDED.md): the components of the checkout, the fonts from fonts/, and the secrets from secrets.yaml. |
ESPHome merges them in this order: the core, then the board file on top of it, then the entry file on top of both.
A mapping merges key by key, a list of components with ids merges by id (!extend adds to an existing widget or
script, !remove takes one away), any other list is the core's items followed by the board's, and a plain value of
the board file replaces the core's. esphome config home-like-2432s028.yaml shows the result.
The three ways a board differs from the core
- A size, a font size, a name.
${TILE_ICON_SIZE},${FONT_HEADLINE_SIZE},${TOUCH_TEST_TITLE}: the core writes the placeholder, the board file'ssubstitutions:table gives the value.tools/check_packages.pyfails when a board leaves one out, so a new board cannot forget a size. - A stretch of C++ inside a shared lambda. The Guition sets
runtime_tiles::rotation_supported, closes its camera when the cards close, prepares the alert's picture frame; the CYD sets its calibration up and lays the climate card out for a portrait panel. Each such stretch is a hook: a substitution whose value is that board's exact lines, written where the old profile had them (${BOOT_ENABLED_HOOK},${CLOSE_CARDS_HOOK},${APPLY_ROTATION}, ...). A board that adds nothing there names the hook with an empty value. The hooks sit at the end of the board file'ssubstitutions:table, each with a line that says where it lands. - A whole section or script. Hardware,
online_image, the Rotation select,capture_ui_snapshot: these are the board file's own sections, merged next to the core's.alert_dismiss,alert_flashandwake_displayare in both board files because their steps differ (alight.turn_onaction on the CYD, theset_backlightscript on the Guition); so areui_self_testandclimate_card_refresh, whose layouts differ by design.
Adding a board
- Copy the board file of the panel that resembles the new one most (a small SPI panel: the CYD; a big RGB panel
with capacitive touch: the Guition) to
packages/boards/<board>.yamland change its hardware sections. Keepassertion_level: SILENTin itsesp32:block (firmware 0.2.75+): every board builds its firmware the same way, andtests/test_easy_package.pychecks it. - Fill the sizes table for the new resolution, and go through the hooks: keep, change or empty each one.
- Add
packages/<board>.yamland<board>.yamlafter the existing entries,<board>toBOARDSandENTRIESintools/profiles.pyand toREFSinscreen_manager/app/core.py(the boardsinstallation_yaml()writes a profile for), and aBANDSentry totools/render_topbar.py. The add-on and the editor know a board as small (the CYD) or large (LARGE_BOARDSincore.pyandweb/src/store.ts: a Guition or an Elecrow, the ones that draw images and take the large cards); a large board reports its name in the value of the "Guition screen type" sensor (discover_screens).ALERT_LIMITS, the camera sizes incamera_feed.py, the editor's New screen choices (InstallerView.vueandboard_<name>in every translation) andBAR_METRICSneed the new board too, andtools/check.shbuilds it (with the flash budget when it has 4 MB). The Elecrow (app 0.2.93) is the worked example. python3 tools/check_packages.py,esphome config <board>.yaml,tools/check.sh --firmware.
The tiles per page (two columns of three) are still fixed in the firmware, the add-on and the editor
(SLOTS_PER_PAGE); a panel that wants more rows is a later round.
How the split was verified
The split was made by a script that replaced every size in the old CYD profile and asserted the value it replaced
in both old profiles (195 places, 84 names), and took every hook's text from the old profiles by line. Then the
result of esphome config and the generated main.cpp of both boards, through the checkout entry and through the
GitHub package route, were compared with the same of the old profiles:
- every scalar, every lambda body and every component is the same, apart from whitespace and
#linedirectives; - on the CYD, the calibration setup runs in the same lambda as the effects page's hooks instead of a lambda of
its own (the same statements, in the same order:
${BOOT_CARDS_TAIL}); - on the Guition, the alert's picture frame is created after the OK button instead of before it (they never
overlap), and the hidden
camera_image_seedafter the labels; - the order in which ESPHome declares and registers fonts, entities, scripts, API actions, styles, includes and build flags follows the merge (the core's first, the board's after), which changes the numbers in ESPHome's component tables and nothing that runs in sequence.
Every other generated source file of both builds was identical, byte for byte.