Created
September 10, 2025 15:51
-
-
Save hpwit/0ba311bccae236dfd8e18822c36b4dcb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "esp_lcd_panel_rgb.h" | |
| #include "esp_lcd_panel_ops.h" | |
| #include "esp_lcd_panel_vendor.h" | |
| #include "esp32s3/rom/cache.h" | |
| #define LCD_H_RES 800 | |
| #define LCD_V_RES 480 | |
| esp_lcd_panel_handle_t panel_handle = NULL; | |
| static uint16_t image[50*50]; | |
| void display() | |
| { | |
| esp_lcd_rgb_panel_config_t panel_config = { | |
| .clk_src = LCD_CLK_SRC_PLL160M, | |
| .timings = { | |
| .pclk_hz = 16 * 1000 * 1000, // Pixel clock | |
| .h_res = LCD_H_RES, | |
| .v_res = LCD_V_RES, | |
| .hsync_pulse_width = 4, | |
| .hsync_back_porch = 16, | |
| .hsync_front_porch = 80, | |
| .vsync_pulse_width = 4, | |
| .vsync_back_porch = 4, | |
| .vsync_front_porch = 22, | |
| .flags = { | |
| .hsync_idle_low = 1,//(uint32_t)((_hsync_polarity == 0) ? 1 : 0), | |
| .vsync_idle_low = 1,//(uint32_t)((_vsync_polarity == 0) ? 1 : 0), | |
| .de_idle_high = 0, | |
| .pclk_active_neg = 1, | |
| .pclk_idle_high = 0, | |
| }, | |
| }, | |
| .data_width = 16, // RGB565 | |
| .bits_per_pixel = 16, | |
| .bounce_buffer_size_px = 0, | |
| .sram_trans_align = 8, | |
| .psram_trans_align = 64, | |
| .hsync_gpio_num = 39, | |
| .vsync_gpio_num = 41, | |
| .de_gpio_num = 40, | |
| .pclk_gpio_num = 42, | |
| .disp_gpio_num = -1, | |
| .data_gpio_nums = { | |
| 8,3,46,9,1,5,6,7,15,16,4,45,48,47,21,14 | |
| }, | |
| .flags = { | |
| .disp_active_low = true, | |
| // #if defined(ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR >= 3 | |
| .refresh_on_demand = true, | |
| // #endif | |
| .fb_in_psram = true, // allocate frame buffer from PSRAM | |
| // #if defined(ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR >= 3 | |
| .double_fb = false, | |
| .no_fb = false, | |
| .bb_invalidate_cache = false, | |
| // #endif | |
| } | |
| }; | |
| // Create panel | |
| ESP_ERROR_CHECK(esp_lcd_new_rgb_panel(&panel_config, &panel_handle)); | |
| ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle)); | |
| ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle)); | |
| // Example image (red) | |
| for (int i = 0; i < 50 * 50; i++) { | |
| image[i] = 0xFFFF; // RGB565 Red | |
| } | |
| // Push once | |
| // ESP_ERROR_CHECK(esp_lcd_panel_draw_bitmap(panel_handle, 50, 50, 100, 100, image)); | |
| void *frame_buffer = nullptr; | |
| ESP_ERROR_CHECK(esp_lcd_rgb_panel_get_frame_buffer(panel_handle, 1, &frame_buffer)); | |
| uint16_t *f=(uint16_t *)frame_buffer; | |
| for(int i=0;i<500;i++) | |
| { | |
| f[i]=0xFFFF; | |
| } | |
| Cache_WriteBack_Addr((uint32_t)frame_buffer, 800*480); | |
| ESP_ERROR_CHECK( esp_lcd_rgb_panel_refresh(panel_handle)); // 👈 triggers refresh | |
| } | |
| void setup() { | |
| // put your setup code here, to run once: | |
| Serial.begin(115200); | |
| display(); | |
| } | |
| void loop() { | |
| // put your main code here, to run repeatedly: | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I got the same problem you're having there, I'm even using the same display the ST7626.
I'm not sure, but i dont think the problem is in the code itself. I tried tweaking EVERY setting.
It seems a problem with the display itself :(