Skip to content

ST7789: Make display offsets runtime configurable #164

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

Merged
merged 3 commits into from
Jan 7, 2022

Conversation

C47D
Copy link
Collaborator

@C47D C47D commented Jan 6, 2022

We don't change previous functionality by adding a helper function that sets the user offsets when initializing the display.

Proposal to fix #163

@C47D C47D requested a review from tore-espressif January 6, 2022 06:03
We don't change previous functionality by adding a helper function that sets the user offsets when initializing the display
@arktrin
Copy link
Contributor

arktrin commented Jan 6, 2022

Looks promising overall.

@C47D
Copy link
Collaborator Author

C47D commented Jan 6, 2022

@arktrin I forgot to ask, are you using the master or develop branch of this repo?

@arktrin
Copy link
Contributor

arktrin commented Jan 6, 2022

I'm using only the master branch.

@C47D
Copy link
Collaborator Author

C47D commented Jan 6, 2022

Ok, this commit is for the develop one, can I send you a patch for the master branch in order to test it in your setup?

@arktrin
Copy link
Contributor

arktrin commented Jan 6, 2022

Yeah, sure. I also don't see any problems in switching to the develop branch if it's easier and more convenient (for test purposes at least).

@C47D
Copy link
Collaborator Author

C47D commented Jan 6, 2022

It would be great if you can test it using the develop branch. I'm also planning to test it develop, but using the ESP32 module.

EDIT
There's an important change in develop, we need to pass a pointer of the registered lv_disp_drv_t to st7789_init, which is no longer called by lvgl_driver_init, it has to be called by the user, see here for more reference.

    static lv_disp_drv_t disp_drv;
    lv_disp_drv_init(&disp_drv);
    disp_drv.flush_cb = st7789_flush;
    disp_drv.rotated = LV_DISP_ROT_NONE;

    /* Initialize SPI or I2C bus used by the drivers */
    lvgl_driver_init();
    /* Initialize GPIOs not related to SPI nor I2C, such as reset, backlight, DC, etc */
    display_bsp_init_io();
    
    /* Removed from lvgl_driver_init, that function is meant to initialize all
     * the needed peripherals */
    st7789_init(&disp_drv);

EDIT 2
I've pushed a commit to https://github.com/lvgl/lv_port_esp32/tree/feat/new_driver_test to test this branch
you will also need the following patch, the fix is in the other pending PR

diff --git a/lvgl_helpers.c b/lvgl_helpers.c
index 6bfdff0..1b17cf1 100644
--- a/lvgl_helpers.c
+++ b/lvgl_helpers.c
@@ -182,7 +182,7 @@ bool lvgl_spi_driver_init(int host,
     int dma_channel,
     int quadwp_pin, int quadhd_pin)
 {
-    assert((0 <= host) && (SPI_HOST_MAX > host));
+    // assert((0 <= host) && (SPI_HOST_MAX > host));
     const char *spi_names[] = {
         "SPI1_HOST", "SPI2_HOST", "SPI3_HOST"
     };

@C47D C47D changed the title ST7789: Display offsets are now runtime configurable ST7789: Make display offsets runtime configurable Jan 7, 2022
@C47D
Copy link
Collaborator Author

C47D commented Jan 7, 2022

Found a couple of issues, I'm placing them here as reminder:

I (70) gpio: GPIO[22]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 1| Intr:-1
E (90) gpio: gpio_set_intr_type(151): GPIO interrupt type error
I (90) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 1| Intr:-1
E (100) gpio: gpio_set_intr_type(151): GPIO interrupt type error
I (110) gpio: GPIO[35]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 1| Intr:-1
E (110) gpio: gpio_set_intr_type(151): GPIO interrupt type error

GPIO 35 is pin busy, we need to add an option such as USE_BUSY.

@arktrin
Copy link
Contributor

arktrin commented Jan 7, 2022

@C47D Hmm, I thought it would be easier. I've cloned this branch - github.com/lvgl/lv_port_esp32/tree/feat/new_driver_test, updated to latest develop branch of lvgl_esp32_drivers, and it doesn't compiles because of multiple definition of display_bsp_init_io() function - in main.c and lvgl_helpers.c

@C47D
Copy link
Collaborator Author

C47D commented Jan 7, 2022

Sorry about that, it seems like I forgot to push that change, you should comment out that function on the main.c file. Also, you should clone this particular branch, not develop.

@arktrin
Copy link
Contributor

arktrin commented Jan 7, 2022

Commenting out display_bsp_init_io() function in the main.c helped. Switched to feat/runtime_offsets branch and everything is working fine on my setup (ESP32-C3 + ST7789 display).

@C47D
Copy link
Collaborator Author

C47D commented Jan 7, 2022

It worked as well for me using the ESP32 module. I didn't tried changing the offset after initializing the display tho.

Do you think it's ready to merge?

@arktrin
Copy link
Contributor

arktrin commented Jan 7, 2022

I'm getting some warning during compilation:

../components/lvgl_esp32_drivers/lvgl_tft/ili9481.c: In function 'ili9481_flush':
../components/lvgl_esp32_drivers/lvgl_tft/ili9481.c:117:81: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
         if (mybuf == NULL)  LV_LOG_WARN("Could not allocate enough DMA memory!");
                                                                                 ^
../components/lvgl_esp32_drivers/lvgl_tft/ili9481.c: In function 'ili9481_set_orientation':
../components/lvgl_esp32_drivers/lvgl_tft/ili9481.c:192:17: warning: unused variable 'orientation_str' [-Wunused-variable]
     const char *orientation_str[] = {
                 ^~~~~~~~~~~~~~~
[1105/1130] Building C object esp-idf/lvgl_esp32_drivers/CMakeFiles/__idf_lvgl_esp32_drivers.dir/lvgl_tft/ili9486.c.obj
../components/lvgl_esp32_drivers/lvgl_tft/ili9486.c: In function 'ili9486_set_orientation':
../components/lvgl_esp32_drivers/lvgl_tft/ili9486.c:168:17: warning: unused variable 'orientation_str' [-Wunused-variable]
     const char *orientation_str[] = {
                 ^~~~~~~~~~~~~~~
[1107/1130] Building C object esp-idf/lvgl_esp32_drivers/CMakeFiles/__idf_lvgl_esp32_drivers.dir/lvgl_tft/st7735s.c.obj
../components/lvgl_esp32_drivers/lvgl_tft/st7735s.c: In function 'st7735s_set_orientation':
../components/lvgl_esp32_drivers/lvgl_tft/st7735s.c:208:17: warning: unused variable 'orientation_str' [-Wunused-variable]
     const char *orientation_str[] = {
                 ^~~~~~~~~~~~~~~
[1110/1130] Building C object esp-idf/lvgl_esp32_drivers/CMakeFiles/__idf_lvgl_esp32_drivers.dir/lvgl_tft/st7796s.c.obj
../components/lvgl_esp32_drivers/lvgl_tft/st7796s.c: In function 'st7796s_set_orientation':
../components/lvgl_esp32_drivers/lvgl_tft/st7796s.c:192:14: warning: unused variable 'orientation_str' [-Wunused-variable]
  const char *orientation_str[] = {
              ^~~~~~~~~~~~~~~
[1112/1130] Building C object esp-idf/lvgl_esp32_drivers/CMakeFiles/__idf_lvgl_esp32_drivers.dir/lvgl_tft/ili9488.c.obj
../components/lvgl_esp32_drivers/lvgl_tft/ili9488.c: In function 'ili9488_set_orientation':
../components/lvgl_esp32_drivers/lvgl_tft/ili9488.c:192:17: warning: unused variable 'orientation_str' [-Wunused-variable]
     const char *orientation_str[] = {
                 ^~~~~~~~~~~~~~~
[1117/1130] Building C object esp-idf/lvgl_esp32_drivers/CMakeFiles/__idf_lvgl_esp32_drivers.dir/lvgl_tft/GC9A01.c.obj
../components/lvgl_esp32_drivers/lvgl_tft/GC9A01.c: In function 'GC9A01_set_orientation':
../components/lvgl_esp32_drivers/lvgl_tft/GC9A01.c:224:17: warning: unused variable 'orientation_str' [-Wunused-variable]
     const char *orientation_str[] = {
                 ^~~~~~~~~~~~~~~
[1119/1130] Building C object esp-idf/lvgl_esp32_drivers/CMakeFiles/__idf_lvgl_esp32_drivers.dir/lvgl_tft/ili9163c.c.obj
../components/lvgl_esp32_drivers/lvgl_tft/ili9163c.c: In function 'ili9163c_set_orientation':
../components/lvgl_esp32_drivers/lvgl_tft/ili9163c.c:226:14: warning: unused variable 'orientation_str' [-Wunused-variable]
  const char *orientation_str[] = {
              ^~~~~~~~~~~~~~~
[1120/1130] Building C object esp-idf/lvgl_esp32_drivers/CMakeFiles/__idf_lvgl_esp32_drivers.dir/lvgl_tft/jd79653a.c.obj
../components/lvgl_esp32_drivers/lvgl_tft/jd79653a.c: In function 'jd79653a_lv_fb_flush':
../components/lvgl_esp32_drivers/lvgl_tft/jd79653a.c:412:12: warning: unused variable 'len' [-Wunused-variable]
     size_t len = ((area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1)) / 8;
            ^~~
At top level:
../components/lvgl_esp32_drivers/lvgl_tft/jd79653a.c:179:13: warning: 'jd79653a_spi_send_fb' defined but not used [-Wunused-function]
 static void jd79653a_spi_send_fb(uint8_t *data, size_t len)
             ^~~~~~~~~~~~~~~~~~~~
[1121/1130] Building C object esp-idf/lvgl_esp32_drivers/CMakeFiles/__idf_lvgl_esp32_drivers.dir/lvgl_tft/uc8151d.c.obj
../components/lvgl_esp32_drivers/lvgl_tft/uc8151d.c: In function 'uc8151d_lv_fb_flush':
../components/lvgl_esp32_drivers/lvgl_tft/uc8151d.c:199:12: warning: unused variable 'len' [-Wunused-variable]
     size_t len = ((area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1)) / 8;
            ^~~
At top level:
../components/lvgl_esp32_drivers/lvgl_tft/uc8151d.c:104:13: warning: 'uc8151d_spi_send_seq' defined but not used [-Wunused-function]
 static void uc8151d_spi_send_seq(const uc8151d_seq_t *seq, size_t len)
             ^~~~~~~~~~~~~~~~~~~~
../components/lvgl_esp32_drivers/lvgl_tft/uc8151d.c:97:13: warning: 'uc8151d_spi_send_fb' defined but not used [-Wunused-function]
 static void uc8151d_spi_send_fb(uint8_t *data, size_t len)
             ^~~~~~~~~~~~~~~~~~~

Is it ok to have them?

@C47D
Copy link
Collaborator Author

C47D commented Jan 7, 2022

Is it ok to have them?

Not really, can you fill a issue to keep track of them? They don't harm tho, will address them when possible.

@arktrin
Copy link
Contributor

arktrin commented Jan 7, 2022

#165 Done!

@C47D
Copy link
Collaborator Author

C47D commented Jan 7, 2022

@arktrin Thanks 👍 , can we merge this PR?

@arktrin
Copy link
Contributor

arktrin commented Jan 7, 2022

Excluding warnings everything seems to work fine. I do think it's ready to be merged.

@C47D C47D merged commit 35d2d3a into develop Jan 7, 2022
@C47D C47D deleted the feat/runtime_offsets branch January 7, 2022 19:24
@C47D
Copy link
Collaborator Author

C47D commented Jan 7, 2022

Thanks for the reviews @arktrin , something I noticed after updating the offset at runtime is that we don't have a function to clear the display.

@arktrin
Copy link
Contributor

arktrin commented Jan 9, 2022

@C47D I've tried to update to latest develop branch and now I've got these errors:

../main/main.c: In function 'guiTask':
../main/main.c:115:5: error: implicit declaration of function 'lvgl_driver_init'; did you mean 'lvgl_spi_driver_init'? [-Werror=implicit-function-declaration]
     lvgl_driver_init();
     ^~~~~~~~~~~~~~~~
     lvgl_spi_driver_init
../main/main.c:124:41: error: 'DISP_BUF_SIZE' undeclared (first use in this function); did you mean 'LV_INV_BUF_SIZE'?
     lv_color_t* buf1 = heap_caps_malloc(DISP_BUF_SIZE * sizeof(lv_color_t), MALLOC_CAP_DMA);
                                         ^~~~~~~~~~~~~
                                         LV_INV_BUF_SIZE
../main/main.c:124:41: note: each undeclared identifier is reported only once for each function it appears in
cc1: some warnings being treated as errors

Can't reproduce yesterday's results. What am I doing wrong?

@C47D
Copy link
Collaborator Author

C47D commented Jan 9, 2022

I merged a PR last Friday into develop and didn't updated the lv_port_esp32 project. Let me do that, sorry for the inconvenience.

@C47D
Copy link
Collaborator Author

C47D commented Jan 10, 2022

@arktrin Sorry, I was pushing to the wrong remote repo, you should be able to get it working now.

@arktrin
Copy link
Contributor

arktrin commented Jan 11, 2022

@C47D Thanks a lot! But with a latest develop now I've got even larger number of errors:

../main/main.c: In function 'guiTask':
../main/main.c:137:16: warning: unused variable 'display' [-Wunused-variable]
     lv_disp_t* display = lv_disp_drv_register(&disp_drv);
                ^~~~~~~

../components/lvgl_esp32_drivers/lvgl_tft/esp_lcd_backlight.c: In function 'disp_backlight_new':
../components/lvgl_esp32_drivers/lvgl_tft/esp_lcd_backlight.c:59:9: error: implicit declaration of function 'gpio_matrix_out'; did you mean 'gpio_iomux_out'? [-Werror=implicit-function-declaration]
         gpio_matrix_out(config->gpio_num, ledc_periph_signal[LEDC_LOW_SPEED_MODE].sig_out0_idx + config->channel_idx, config->output_invert, 0);
         ^~~~~~~~~~~~~~~
         gpio_iomux_out
../components/lvgl_esp32_drivers/lvgl_tft/esp_lcd_backlight.c:65:9: error: implicit declaration of function 'gpio_pad_select_gpio'; did you mean 'esp_rom_gpio_pad_select_gpio'? [-Werror=implicit-function-declaration]
         gpio_pad_select_gpio(config->gpio_num);
         ^~~~~~~~~~~~~~~~~~~~
         esp_rom_gpio_pad_select_gpio
../components/lvgl_esp32_drivers/lvgl_tft/esp_lcd_backlight.c:67:43: error: 'SIG_GPIO_OUT_IDX' undeclared (first use in this function); did you mean 'GPIO_NUM_MAX'?
         gpio_matrix_out(config->gpio_num, SIG_GPIO_OUT_IDX, config->output_invert, false);
                                           ^~~~~~~~~~~~~~~~
                                           GPIO_NUM_MAX
../components/lvgl_esp32_drivers/lvgl_tft/esp_lcd_backlight.c:67:43: note: each undeclared identifier is reported only once for each function it appears in

../components/lvgl_esp32_drivers/lvgl_helpers.c: In function 'lvgl_interface_init':
../components/lvgl_esp32_drivers/lvgl_helpers.c:107:32: error: 'SPI_DMA_CH1' undeclared (first use in this function); did you mean 'SPI_DMA_CH_AUTO'?
         spi_max_transfer_size, SPI_DMA_CH1,
                                ^~~~~~~~~~~
                                SPI_DMA_CH_AUTO
../components/lvgl_esp32_drivers/lvgl_helpers.c:107:32: note: each undeclared identifier is reported only once for each function it appears in

../components/lvgl_esp32_drivers/lvgl_tft/ili9481.c: In function 'ili9481_init':
../components/lvgl_esp32_drivers/lvgl_tft/ili9481.c:74:5: error: implicit declaration of function 'gpio_pad_select_gpio'; did you mean 'esp_rom_gpio_pad_select_gpio'? [-Werror=implicit-function-declaration]
     gpio_pad_select_gpio(ILI9481_DC);
     ^~~~~~~~~~~~~~~~~~~~
     esp_rom_gpio_pad_select_gpio

../components/lvgl_esp32_drivers/lvgl_tft/ili9486.c: In function 'ili9486_init':
../components/lvgl_esp32_drivers/lvgl_tft/ili9486.c:67:5: error: implicit declaration of function 'gpio_pad_select_gpio'; did you mean 'esp_rom_gpio_pad_select_gpio'? [-Werror=implicit-function-declaration]
     gpio_pad_select_gpio(ILI9486_DC);
     ^~~~~~~~~~~~~~~~~~~~
     esp_rom_gpio_pad_select_gpio

../components/lvgl_esp32_drivers/lvgl_tft/st7735s.c: In function 'st7735s_init':
../components/lvgl_esp32_drivers/lvgl_tft/st7735s.c:102:9: error: implicit declaration of function 'gpio_pad_select_gpio'; did you mean 'esp_rom_gpio_pad_select_gpio'? [-Werror=implicit-function-declaration]
         gpio_pad_select_gpio(ST7735S_DC);
         ^~~~~~~~~~~~~~~~~~~~
         esp_rom_gpio_pad_select_gpio


../components/lvgl_esp32_drivers/lvgl_tft/sh1107.c: In function 'sh1107_init':
../components/lvgl_esp32_drivers/lvgl_tft/sh1107.c:97:9: error: implicit declaration of function 'gpio_pad_select_gpio'; did you mean 'esp_rom_gpio_pad_select_gpio'? [-Werror=implicit-function-declaration]
         gpio_pad_select_gpio(SH1107_DC);
         ^~~~~~~~~~~~~~~~~~~~
         esp_rom_gpio_pad_select_gpio


../components/lvgl_esp32_drivers/lvgl_tft/hx8357.c: In function 'hx8357_init':
../components/lvgl_esp32_drivers/lvgl_tft/hx8357.c:160:5: error: implicit declaration of function 'gpio_pad_select_gpio'; did you mean 'esp_rom_gpio_pad_select_gpio'? [-Werror=implicit-function-declaration]
     gpio_pad_select_gpio(HX8357_DC);
     ^~~~~~~~~~~~~~~~~~~~
     esp_rom_gpio_pad_select_gpio


../components/lvgl_esp32_drivers/lvgl_tft/st7796s.c: In function 'st7796s_init':
../components/lvgl_esp32_drivers/lvgl_tft/st7796s.c:83:2: error: implicit declaration of function 'gpio_pad_select_gpio'; did you mean 'esp_rom_gpio_pad_select_gpio'? [-Werror=implicit-function-declaration]
  gpio_pad_select_gpio(ST7796S_DC);
  ^~~~~~~~~~~~~~~~~~~~
  esp_rom_gpio_pad_select_gpio

@C47D
Copy link
Collaborator Author

C47D commented Jan 11, 2022

Damn, I compiled the project multiple times yesterday and didn't got that much errors, only the first warning.

Can you remind me the idf version that you are using? I will move your last message to a new issue to find it more easily.

@tore-espressif
Copy link
Collaborator

Offsets are now handled by LVGL see lvgl/lvgl#2583 !

@arktrin
Copy link
Contributor

arktrin commented Feb 3, 2022

@tore-espressif wow, huge change. develop branch of lvgl_esp32_drivers still uses its own offsets handling? It is a part of moving to lvgl v8 ?

@C47D
Copy link
Collaborator Author

C47D commented Feb 3, 2022

develop branch of lvgl_esp32_drivers still uses its own offsets handling?

Yep, still using the offsets you sent previously

Offsets are now handled by LVGL see lvgl/lvgl#2583 !

Nice, didn't knew this one, thanks for sharing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants