mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 05:24:53 +01:00
Fix garbled graphics on LILYGO T4-S3 display (#6910)
This commit is contained in:
parent
ed6462fa00
commit
896cdab22d
2 changed files with 29 additions and 4 deletions
|
@ -42,6 +42,14 @@ COLOR_ORDERS = {
|
|||
}
|
||||
DATA_PIN_SCHEMA = pins.internal_gpio_output_pin_schema
|
||||
|
||||
|
||||
def validate_dimension(value):
|
||||
value = cv.positive_int(value)
|
||||
if value % 2 != 0:
|
||||
raise cv.Invalid("Width/height/offset must be divisible by 2")
|
||||
return value
|
||||
|
||||
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
display.FULL_DISPLAY_SCHEMA.extend(
|
||||
cv.Schema(
|
||||
|
@ -52,10 +60,14 @@ CONFIG_SCHEMA = cv.All(
|
|||
cv.dimensions,
|
||||
cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_WIDTH): cv.int_,
|
||||
cv.Required(CONF_HEIGHT): cv.int_,
|
||||
cv.Optional(CONF_OFFSET_HEIGHT, default=0): cv.int_,
|
||||
cv.Optional(CONF_OFFSET_WIDTH, default=0): cv.int_,
|
||||
cv.Required(CONF_WIDTH): validate_dimension,
|
||||
cv.Required(CONF_HEIGHT): validate_dimension,
|
||||
cv.Optional(
|
||||
CONF_OFFSET_HEIGHT, default=0
|
||||
): validate_dimension,
|
||||
cv.Optional(
|
||||
CONF_OFFSET_WIDTH, default=0
|
||||
): validate_dimension,
|
||||
}
|
||||
),
|
||||
),
|
||||
|
|
|
@ -26,6 +26,19 @@ void QspiAmoLed::setup() {
|
|||
|
||||
void QspiAmoLed::update() {
|
||||
this->do_update_();
|
||||
// Start addresses and widths/heights must be divisible by 2 (CASET/RASET restriction in datasheet)
|
||||
if (this->x_low_ % 2 == 1) {
|
||||
this->x_low_--;
|
||||
}
|
||||
if (this->x_high_ % 2 == 0) {
|
||||
this->x_high_++;
|
||||
}
|
||||
if (this->y_low_ % 2 == 1) {
|
||||
this->y_low_--;
|
||||
}
|
||||
if (this->y_high_ % 2 == 0) {
|
||||
this->y_high_++;
|
||||
}
|
||||
int w = this->x_high_ - this->x_low_ + 1;
|
||||
int h = this->y_high_ - this->y_low_ + 1;
|
||||
this->draw_pixels_at(this->x_low_, this->y_low_, w, h, this->buffer_, this->color_mode_, display::COLOR_BITNESS_565,
|
||||
|
|
Loading…
Reference in a new issue