9857cc3bda
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.
54 lines
2.2 KiB
Python
54 lines
2.2 KiB
Python
"""Runtime tile configuration transported through the normal ESPHome API.
|
|
|
|
`smart_display: language: nl` (app 0.2.90) builds the screen's texts in that language: the `screen` section of
|
|
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 partitions, screen_text_gen
|
|
|
|
CODEOWNERS = []
|
|
AUTO_LOAD = ["json"]
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
CONF_LANGUAGE = "language"
|
|
CONF_PARTITIONS = "partitions"
|
|
|
|
|
|
def _language(value):
|
|
value = cv.string_strict(value).strip()
|
|
if not screen_text_gen.LANGUAGE_CODE.fullmatch(value):
|
|
raise cv.Invalid("Expected a language code such as en, nl or pt-BR")
|
|
return value
|
|
|
|
|
|
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):
|
|
wanted = config[CONF_LANGUAGE]
|
|
language, code = screen_text_gen.definitions(wanted)
|
|
if language != wanted:
|
|
# 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)
|