Skip to content
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

esp-lcd driver for st7789 - static on cold boot, or last displayed screen on reboot (IDFGH-6896) #8516

Closed
tvanfossen opened this issue Mar 7, 2022 · 4 comments
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@tvanfossen
Copy link

tvanfossen commented Mar 7, 2022

Environment

  • Development Kit: esp32s3 w/ quad spi and 2mb psram (comparable to esp-box)

  • Kit version (for WroverKit/PicoKit/DevKitC): [v1|v2|v3|v4]

  • Module or chip used: ESP32S3-WROOM1

  • IDF version v4.4-330-g871a585c79

  • Build System: idf.py

  • Compiler version xtensa-esp32-elf-gcc (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a) 5.2.0

  • Operating System: Linux

  • Using an IDE?: VSCode

  • Power Supply: USB

Running with LVGL, using lv_port code from esp-box for initialization

Problem Description

esp-lcd panel for st7789 creates static on screen during cold boot. On a reboot (such as ctrl+t+r in idf.py monitor), the st7789 buffer will display the last screen before reboot.

I'd like to make this optional, and enable a user to overwrite this buffer before the DISPON command has been sent to the st7789

I've added the following kconfig option for the esp_lcd component

config LCD_INIT_TO_COLOR
        int "Default color to init screen to, default is static from power off"
        default 0
        help
            On cold boot, LCD driver will initialize with static when the DISP_ON command is sent
            Setting this option will send an additional set of commands which overwrite the static in the display buffer
            before turning the screen on

When LCD_INIT_TO_COLOR is set to 1, the st7789 initialization runs an additional call in order to populate the display buffer before it turns on like below:

#if CONFIG_LCD_INIT_TO_COLOR
    #define INIT_DISP_BUF_SIZE 240*10
    const int init_buf[INIT_DISP_BUF_SIZE] = {0xffff};

    esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR, init_buf, INIT_DISP_BUF_SIZE);

    for (int i = 0; i < 320; i++)
    {
        esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWRC, init_buf, INIT_DISP_BUF_SIZE);
    }
#endif
    // turn on display
    esp_lcd_panel_io_tx_param(io, LCD_CMD_DISPON, NULL, 0);

This is not a perfect solution by any means, a better implementation might allow for the user to select a specific color to set, variation by screen size, maybe even write a bitmap into the buffer, all before DISPON command is sent. This fix does stop the static on the screen I am seeing

@espressif-bot espressif-bot added the Status: Opened Issue is new label Mar 7, 2022
@github-actions github-actions bot changed the title esp-lcd driver for st7789 - static on cold boot, or last displayed screen on reboot esp-lcd driver for st7789 - static on cold boot, or last displayed screen on reboot (IDFGH-6896) Mar 7, 2022
@tvanfossen
Copy link
Author

Gif of the static
ezgif com-gif-maker(4)
n

@suda-morris
Copy link
Collaborator

Hi @tvanfossen

I think you can flush any pattern before **Turn on the backlight", e.g. here

@tvanfossen
Copy link
Author

This makes the assumption that I have IO for backlight control, which I do not on this LCD board. Backlight in this case turns on as soon as power is received.

Yes in a perfect world, I'd flush the screen before turning on the backlight, but this is a bandaid over the actual issue.

Speaking to benefit instead of problem, the st7789 initialization is the earliest possible time at which something can be written to the screen, an ideal spot for a bitmap to be shown during bootup to get something up in < 250ms

@suda-morris
Copy link
Collaborator

Hi @tvanfossen

If that's the case, you can even skip calling panel_st7789_init, and calling esp_lcd_panel_io_tx_param in your code directly. The resources used by panel_st7789_init are also public to users.
For example, in the user code:

// allocate bus handle
ESP_ERROR_CHECK(spi_bus_initialize(LCD_HOST, &buscfg, SPI_DMA_CH_AUTO));
// create LCD IO handle (SPI)
ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)LCD_HOST, &io_config, &io_handle));
// st7789 panel handle
ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle));

ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
// don't call `esp_lcd_panel_init()`, instead, we send LCD commands in another order
esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_SLPOUT, NULL, 0);
vTaskDelay(pdMS_TO_TICKS(100));
// flush color before turn on the display
for (int i = 0; i < 320; i++)
{
    esp_lcd_panel_io_tx_color(io_handle, LCD_CMD_RAMWRC, init_buf, INIT_DISP_BUF_SIZE);
}
// turn on display
esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_DISPON, NULL, 0);

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Apr 11, 2022
@espressif-bot espressif-bot added Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: In Progress Work is in progress Resolution: NA Issue resolution is unavailable labels Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

3 participants