-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The problem of esp_lcd handling color data (IDFGH-8881) #10302
Comments
Is there a reason not to use esp_lcd_panel_draw_bitmap sending pixel data line by line? Using this API sends the column/line offsets to the LCD prior to sending the block of pixel data. By directly using Your first usage of |
@atanisoft
Before moving each line of color data, I set the column/line offsets on the LCD, and it is displayed normally. for (size_t i = 0; i < (y_end - y_start); i++) {
esp_lcd_panel_io_tx_param(
self->io_handle,
0x2A,
(uint8_t[]) {
((x_start >> 8) & 0xFF),
(x_start & 0xFF),
(((x_end - 1) >> 8) & 0xFF),
((x_end - 1) & 0xFF),
},
4
);
esp_lcd_panel_io_tx_param(
self->io_handle,
0x2B,
(uint8_t[]) {
(((y_start + i) >> 8) & 0xFF),
((y_start + i) & 0xFF),
(((y_start + i + 1) >> 8) & 0xFF),
((y_start + i + 1) & 0xFF),
},
4
);
size_t len = (x_end - x_start) * self->bits_per_pixel / 8;
esp_lcd_panel_io_tx_color((lcd_spi_panel_obj_t *)self->bus_obj, 0x2C, &bufinfo.buf[i * len], len);
} When I change the code to the following way, it doesn't work: esp_lcd_panel_io_tx_param(
(lcd_spi_panel_obj_t *)self->bus_obj,
0x2A,
(uint8_t[]) {
((x_start >> 8) & 0xFF),
(x_start & 0xFF),
(((x_end - 1) >> 8) & 0xFF),
((x_end - 1) & 0xFF),
},
4
);
esp_lcd_panel_io_tx_param(
(lcd_spi_panel_obj_t *)self->bus_obj,
0x2B,
(uint8_t[]) {
(((y_start) >> 8) & 0xFF),
((y_start ) & 0xFF),
(((x_end -1) >> 8) & 0xFF),
((x_end -1) & 0xFF),
},
4
);
esp_lcd_panel_io_tx_color(self->io_handle, 0x2C, NULL, 0);
for (i = 0; i < (y_end - y_start ); i++) {
esp_lcd_panel_io_tx_color(
self->io_handle,
-1,
(const void *)&((const uint8_t *)color)[i * (x_end - x_start ) * 2],
(x_end - x_start ) * 2
);
}
esp_lcd_panel_io_tx_color(
self->io_handle,
-1,
(const void *)&((const uint8_t *)color)[i * (x_end - x_start ) * 2],
color_size - (i * (x_end - x_start ) * 2)
); I looked at the code implementation of |
@lbuque if you want to send a single command, suggest using I tested the following code, it works on my ST7789 panel (master branch, but I think it should have the same behavior on 5.0) // define an area of frame memory where MCU can access
esp_lcd_panel_io_tx_param(io, LCD_CMD_CASET, (uint8_t[]) {
(x_start >> 8) & 0xFF,
x_start & 0xFF,
((x_end - 1) >> 8) & 0xFF,
(x_end - 1) & 0xFF,
}, 4);
esp_lcd_panel_io_tx_param(io, LCD_CMD_RASET, (uint8_t[]) {
(y_start >> 8) & 0xFF,
y_start & 0xFF,
((y_end - 1) >> 8) & 0xFF,
(y_end - 1) & 0xFF,
}, 4);
// transfer frame buffer
esp_lcd_panel_io_tx_param(io, LCD_CMD_RAMWR, NULL, 0);
size_t len = (x_end - x_start) * st7789->fb_bits_per_pixel / 8;
uint8_t *data = (uint8_t *) color_data;
for (int i = 0; i < y_end - y_start; i++) {
esp_lcd_panel_io_tx_color(io, -1, &data[i * len], len);
}
Yes, seems like some commits in #9881 need to be backported to the 4.4 branch to allow |
@suda-morris Thank you very much for your answer! At present, micropython is not compatible with idf 5.0, I can't verify it, but it must be correct. So now I just have to wait for it to be backported to the 4.4 branch. Hope you can let me know after the backport! I think this issue can be closed now! |
Thanks for sharing the updates, the backport on release/4.4 is available at ca6a427, feel free to reopen. |
Answers checklist.
General issue report
I'm compiling micropython's binding library for esp_lcd.
I consider that esp32 may not have psram, so moving data to esp_lcd line by line has saved memory overhead.
The result I get is that the lcd doesn't display my image properly.
Below is my code to initialize the lcd panel:
How should I use esp_lcd_panel_io_tx_color correctly?
Answers from anyone are welcome!
Here's how to move color data:
The text was updated successfully, but these errors were encountered: