[image] Fix byte order handling (#15800)

This commit is contained in:
Clyde Stubbs
2026-04-17 22:11:05 +10:00
committed by Jesse Hills
parent c3e739eba9
commit f5806818cd
2 changed files with 11 additions and 8 deletions
+10 -7
View File
@@ -28,7 +28,6 @@ from esphome.const import (
CONF_URL, CONF_URL,
) )
from esphome.core import CORE, HexInt from esphome.core import CORE, HexInt
from esphome.final_validate import full_config
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@@ -676,12 +675,16 @@ def _final_validate(config):
:param config: :param config:
:return: :return:
""" """
fv = full_config.get() config = config.copy()
if "lvgl" in fv and not all(CONF_BYTE_ORDER in x for x in config): for c in config:
config = config.copy() if byte_order := c.get(CONF_BYTE_ORDER):
for c in config: if byte_order == "BIG_ENDIAN":
if not c.get(CONF_BYTE_ORDER): _LOGGER.warning(
c[CONF_BYTE_ORDER] = "LITTLE_ENDIAN" "The image '%s' is configured with big-endian byte order, little-endian is expected",
c.get(CONF_FILE),
)
else:
c[CONF_BYTE_ORDER] = "LITTLE_ENDIAN"
return config return config
+1 -1
View File
@@ -189,7 +189,7 @@ Color Image::get_rgb_pixel_(int x, int y) const {
} }
Color Image::get_rgb565_pixel_(int x, int y) const { Color Image::get_rgb565_pixel_(int x, int y) const {
const uint8_t *pos = this->data_start_ + (x + y * this->width_) * this->bpp_ / 8; const uint8_t *pos = this->data_start_ + (x + y * this->width_) * this->bpp_ / 8;
uint16_t rgb565 = encode_uint16(progmem_read_byte(pos), progmem_read_byte(pos + 1)); uint16_t rgb565 = encode_uint16(progmem_read_byte(pos + 1), progmem_read_byte(pos));
auto r = (rgb565 & 0xF800) >> 11; auto r = (rgb565 & 0xF800) >> 11;
auto g = (rgb565 & 0x07E0) >> 5; auto g = (rgb565 & 0x07E0) >> 5;
auto b = rgb565 & 0x001F; auto b = rgb565 & 0x001F;