Fix garbled graphics on LILYGO T4-S3 display (#6910)

This commit is contained in:
Manuel Kasper 2024-06-18 21:53:01 +02:00 committed by GitHub
parent ed6462fa00
commit 896cdab22d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 4 deletions

View file

@ -42,6 +42,14 @@ COLOR_ORDERS = {
} }
DATA_PIN_SCHEMA = pins.internal_gpio_output_pin_schema 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( CONFIG_SCHEMA = cv.All(
display.FULL_DISPLAY_SCHEMA.extend( display.FULL_DISPLAY_SCHEMA.extend(
cv.Schema( cv.Schema(
@ -52,10 +60,14 @@ CONFIG_SCHEMA = cv.All(
cv.dimensions, cv.dimensions,
cv.Schema( cv.Schema(
{ {
cv.Required(CONF_WIDTH): cv.int_, cv.Required(CONF_WIDTH): validate_dimension,
cv.Required(CONF_HEIGHT): cv.int_, cv.Required(CONF_HEIGHT): validate_dimension,
cv.Optional(CONF_OFFSET_HEIGHT, default=0): cv.int_, cv.Optional(
cv.Optional(CONF_OFFSET_WIDTH, default=0): cv.int_, CONF_OFFSET_HEIGHT, default=0
): validate_dimension,
cv.Optional(
CONF_OFFSET_WIDTH, default=0
): validate_dimension,
} }
), ),
), ),

View file

@ -26,6 +26,19 @@ void QspiAmoLed::setup() {
void QspiAmoLed::update() { void QspiAmoLed::update() {
this->do_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 w = this->x_high_ - this->x_low_ + 1;
int h = this->y_high_ - this->y_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, this->draw_pixels_at(this->x_low_, this->y_low_, w, h, this->buffer_, this->color_mode_, display::COLOR_BITNESS_565,