mirror of
https://github.com/esphome/esphome.git
synced 2026-05-27 20:53:46 +08:00
[image] Fix byte order handling (#15800)
This commit is contained in:
committed by
Jesse Hills
parent
c3e739eba9
commit
f5806818cd
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user