Add the Elecrow CrowPanel 7.0" as a third board, and take the packages and the add-on from Gitea (0.2.93)
CI / checks (push) Successful in 12m50s
CI / firmware (add-on) (push) Successful in 18m19s
CI / firmware (min_version) (push) Successful in 17m55s

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.
This commit is contained in:
Xandrossian
2026-09-20 23:18:01 -07:00
parent efbab04b39
commit 9857cc3bda
64 changed files with 1664 additions and 145 deletions
+17 -2
View File
@@ -4,19 +4,26 @@
screen_manager/translations/nl.json, with English for any key it lacks, becomes one table in main.cpp
(screen_text_gen.py, screen_text.h). The shared core sets it from the LANGUAGE substitution, which ESP Screens writes
into a screen's YAML.
`smart_display: partitions: 4mb_wide_slots` (firmware 0.2.79) builds with one of the partition tables of partitions.py
instead of ESPHome's own: two update slots of 1,984 KB on a 4 MB ESP32-S3, which the Elecrow CrowPanel 7.0" needs.
"""
import logging
import esphome.codegen as cg
from esphome.components import esp32
import esphome.config_validation as cv
from esphome.core import CORE
from esphome.helpers import write_file_if_changed
from . import screen_text_gen
from . import partitions, screen_text_gen
CODEOWNERS = []
AUTO_LOAD = ["json"]
_LOGGER = logging.getLogger(__name__)
CONF_LANGUAGE = "language"
CONF_PARTITIONS = "partitions"
def _language(value):
@@ -26,7 +33,10 @@ def _language(value):
return value
CONFIG_SCHEMA = cv.Schema({cv.Optional(CONF_LANGUAGE, default="en"): _language})
CONFIG_SCHEMA = cv.Schema({
cv.Optional(CONF_LANGUAGE, default="en"): _language,
cv.Optional(CONF_PARTITIONS): cv.one_of(*partitions.TABLES, lower=True),
})
async def to_code(config):
@@ -36,3 +46,8 @@ async def to_code(config):
# ESP Screens only writes languages it has; a hand-written one it lacks builds in the nearest it does have.
_LOGGER.warning("No translation for %s yet; the screen's texts are in %s", wanted, language)
cg.add_global(cg.RawStatement(code))
if CONF_PARTITIONS in config:
# ESPHome writes no partitions.csv of its own when one is among the extra build files (esp32.copy_files).
table = CORE.relative_build_path("smart_display_partitions.csv")
write_file_if_changed(table, partitions.TABLES[config[CONF_PARTITIONS]])
esp32.add_extra_build_file("partitions.csv", table)
@@ -0,0 +1,30 @@
#pragma once
// The Elecrow CrowPanel 7.0" wires its GT911 touch I2C to GPIO19 and GPIO20, the ESP32-S3's USB D- and D+. The ROM
// leaves the USB_SERIAL_JTAG PHY on those pads, and ESP-IDF's I2C driver cannot take them back: the bus reads as
// "I2C software timeout" and the touch never answers (esphome/esphome#15356, ESPHome 2026.3+). This runs before any
// ESPHome component (a static constructor at priority 101): the PHY lets the pads go, and both become plain GPIOs
// with their pull-ups, as the I2C driver expects to find them. The board's USB-C port is a CH340 on UART0, so nothing
// is lost.
//
// ESPHome includes every header of the component in every build, so the code is behind a flag only the Elecrow's board
// file sets (`-DESP_SCREENS_FREE_USB_PADS=1`, packages/boards/elecrow-crowpanel7.yaml): the CYD has no such peripheral,
// and the Guition, an ESP32-S3 too, keeps its USB.
#if defined(ESP_SCREENS_FREE_USB_PADS) && ESP_SCREENS_FREE_USB_PADS
#include "hal/usb_serial_jtag_ll.h"
#include "soc/io_mux_reg.h"
#include "soc/usb_serial_jtag_reg.h"
namespace elecrow {
static __attribute__((constructor(101))) void release_usb_pads() {
usb_serial_jtag_ll_phy_enable_pad(false);
CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_USB_PAD_ENABLE);
CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_DP_PULLUP);
for (uint32_t reg : {IO_MUX_GPIO19_REG, IO_MUX_GPIO20_REG}) {
PIN_FUNC_SELECT(reg, PIN_FUNC_GPIO);
PIN_INPUT_ENABLE(reg);
REG_SET_BIT(reg, FUN_PU);
REG_CLR_BIT(reg, FUN_PD);
}
}
} // namespace elecrow
#endif
+17 -11
View File
@@ -1,18 +1,22 @@
#pragma once
#include <algorithm>
#include "lvgl.h"
#include "esphome/core/log.h"
// On-demand 240x240 diagnostic image of LVGL's rendered screen. Nothing is
// allocated or streamed during normal use. The RGB display signal itself
// still needs a physical visual check.
// On-demand diagnostic image of LVGL's rendered screen at half its resolution (240x240 on the Guition, 400x240 on
// the Elecrow): every second pixel of every second row. Nothing is allocated or streamed during normal use. The RGB
// display signal itself still needs a physical visual check. The geometry check takes the panel's own size.
namespace guition {
inline int screen_w() { return lv_display_get_horizontal_resolution(lv_display_get_default()); }
inline int screen_h() { return lv_display_get_vertical_resolution(lv_display_get_default()); }
inline bool check_geometry(lv_obj_t *obj) {
if (lv_obj_has_flag(obj, LV_OBJ_FLAG_HIDDEN)) return true;
bool ok = true;
lv_area_t area;
lv_obj_get_coords(obj, &area);
if (lv_obj_has_flag(obj, LV_OBJ_FLAG_CLICKABLE) &&
(area.x1 < 0 || area.y1 < 0 || area.x2 >= 480 || area.y2 >= 480)) {
(area.x1 < 0 || area.y1 < 0 || area.x2 >= screen_w() || area.y2 >= screen_h())) {
ESP_LOGE("ui_test", "GEOMETRY FAIL clickable=(%d,%d)-(%d,%d)",
area.x1, area.y1, area.x2, area.y2);
ok = false;
@@ -32,7 +36,7 @@ inline void snapshot_begin() {
overlay = nullptr;
snapshot = lv_snapshot_take(lv_screen_active(), LV_COLOR_FORMAT_RGB565);
snapshot_row = 0;
if (!snapshot || snapshot->header.w != 480 || snapshot->header.h != 480) {
if (!snapshot || (int) snapshot->header.w != screen_w() || (int) snapshot->header.h != screen_h()) {
if (snapshot) lv_draw_buf_destroy(snapshot);
snapshot = nullptr;
ESP_LOGE("ui_image", "IMAGE FAIL allocation/dimensions");
@@ -41,10 +45,10 @@ inline void snapshot_begin() {
for (uint32_t i = 0; i < lv_obj_get_child_count(lv_layer_top()); ++i)
if (!lv_obj_has_flag(lv_obj_get_child(lv_layer_top(), i), LV_OBJ_FLAG_HIDDEN)) {
overlay = lv_snapshot_take(lv_layer_top(), LV_COLOR_FORMAT_ARGB8888);
if (overlay && (overlay->header.w != 480 || overlay->header.h != 480)) { lv_draw_buf_destroy(overlay); overlay = nullptr; }
if (overlay && ((int) overlay->header.w != screen_w() || (int) overlay->header.h != screen_h())) { lv_draw_buf_destroy(overlay); overlay = nullptr; }
break;
}
ESP_LOGI("ui_image", "IMAGE BEGIN 240 240%s", overlay ? " with top layer" : "");
ESP_LOGI("ui_image", "IMAGE BEGIN %d %d%s", screen_w() / 2, screen_h() / 2, overlay ? " with top layer" : "");
}
// The top layer's pixel over the page's, as the panel shows them.
inline uint16_t layered(uint16_t pixel, int x, int y) {
@@ -62,15 +66,17 @@ inline void snapshot_next_row() {
const auto *row = reinterpret_cast<const uint16_t *>(
snapshot->data + snapshot_row * 2 * snapshot->header.stride);
static constexpr char hex[] = "0123456789abcdef";
char line[961];
for (int x = 0; x < 240; ++x) {
// Four hex digits a pixel; the widest panel is 800 px, 400 in the image.
static char line[1601];
const int columns = std::min(screen_w() / 2, 400);
for (int x = 0; x < columns; ++x) {
uint16_t pixel = layered(row[x * 2], x * 2, snapshot_row * 2);
for (int digit = 0; digit < 4; ++digit)
line[x * 4 + digit] = hex[(pixel >> (12 - digit * 4)) & 15];
}
line[960] = 0;
line[columns * 4] = 0;
ESP_LOGI("ui_image", "ROW %03d %s", snapshot_row, line);
if (++snapshot_row == 240) {
if (++snapshot_row == screen_h() / 2) {
lv_draw_buf_destroy(snapshot);
snapshot = nullptr;
if (overlay) lv_draw_buf_destroy(overlay);
+23
View File
@@ -0,0 +1,23 @@
"""Partition tables a board file can ask for with `smart_display: partitions:` (firmware 0.2.79).
ESPHome's own table for 4 MB of flash keeps 448 KB for NVS and gives the two update slots 1,792 KB each. The screen's
preferences take a few KB of NVS (ESP-IDF's own two-slot example keeps 16 KB), and the Elecrow CrowPanel 7.0" needs
the room: its firmware is the Guition's, which does not fit 1,792 KB. The tables live here, as text, because a board
file over GitHub cannot carry a file of its own; __init__.py hands the chosen one to ESPHome as the build's
partitions.csv. A table never changes once a screen is flashed with it: an update over Wi-Fi writes into the other slot
of the table the screen has, and only a USB install lays the flash out anew.
"""
# 4 MB as two update slots of 0x1F0000 bytes, the largest 64 KB-aligned pair that fits, and 64 KB of NVS at the end;
# otadata and phy_init where ESPHome puts them. Offsets are explicit so the table is the same on every build.
TABLES = {
'4mb_wide_slots': """\
# ESP Screens: 4 MB ESP32-S3 with two update slots of 1,984 KB (components/smart_display/partitions.py).
# Name, Type, SubType, Offset, Size
otadata, data, ota, 0x9000, 0x2000
phy_init, data, phy, 0xB000, 0x1000
app0, app, ota_0, 0x10000, 0x1F0000
app1, app, ota_1, 0x200000, 0x1F0000
nvs, data, nvs, 0x3F0000, 0x10000
""",
}