From 165b615d96b374107842ad3d8e6e3bd02609feb8 Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Sun, 17 Dec 2023 14:10:35 +0100 Subject: [PATCH] Renamed defines Updated manual --- .github/workflows/main.yml | 2 +- README.md | 341 ++++++++++++++---------- {example => examples/ci}/lv_conf.h | 0 {example => examples/ci}/main.cpp | 0 {example => examples/ci}/platformio.ini | 15 +- library.json | 20 +- src/esp32_smartdisplay.c | 100 +++---- src/lvgl_cst816s.c | 14 +- src/lvgl_gc9a01.c | 12 +- src/lvgl_gt911.c | 14 +- src/lvgl_ili9341.c | 12 +- src/lvgl_parallel16.c | 6 +- src/lvgl_st7789.c | 12 +- src/lvgl_st7796.c | 10 +- src/lvgl_xpt2046.c | 12 +- 15 files changed, 310 insertions(+), 260 deletions(-) rename {example => examples/ci}/lv_conf.h (100%) rename {example => examples/ci}/main.cpp (100%) rename {example => examples/ci}/platformio.ini (83%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7971f2c..8d5cf22 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,6 +23,6 @@ jobs: - name: Check boards run: pio boards espressif32 - name: Build firmware - run: pio ci --lib=src --lib=include --exclude=assets --exclude=example --exclude=boards --project-conf="example/platformio.ini" "example/main.cpp" + run: pio ci --lib=src --lib=include --exclude=assets --exclude=example --exclude=boards --project-conf="examples/ci/platformio.ini" "examples/ci/main.cpp" env: PLATFORMIO_BUILD_FLAGS: -DLV_CONF_PATH="${{github.workspace}}/example/lv_conf.h" diff --git a/README.md b/README.md index d2ad130..98ebfe2 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ This library integrates seamlessly in [PlatformIO](https://platformio.org/) and ## Why this library With the boards, there is a link supplied and there are a lot of examples present and this looks fine.... If you know your way around.... -These examples for [LVGL](https://lvgl.io/) depend on external libraries ([TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) or [LovyanGFX](https://github.com/lovyan03/LovyanGFX)). +These examples for [LVGL](https://lvgl.io/) depend on external libraries ([LCD_eSPI](https://github.com/Bodmer/LCD_eSPI) or [LovyanGFX](https://github.com/lovyan03/LovyanGFX)). However, when working with these libraries, I found out that these libraries had their flaws using these boards: - Lots of configuring to do before it all works, @@ -108,29 +108,21 @@ This library is made for usage in PlatformIO. If not familiar with PlatformIO pl Make sure you have PlatformIO installed and functional. Follow the documentation on their site: [https://docs.platformio.org/en/latest/](https://docs.platformio.org/en/latest/) -Board definitions are in the directory ```boards```. This is done because some boards use an ESP32-S3 with **16Mb flash and 8Mb PSRAM**. There is no definition for this board in the standard PlatformIO boards selection. -Additionally, each board has definitions of the GPIO RGB LEDs, CDR sensor GPIO IO ports and other settings. +The definitions required for this library are defined in the boards. This is done because some boards use an ESP32-S3 with **16Mb flash and 8Mb PSRAM**. There is no definition for this board in the standard PlatformIO boards selection. These boards definitions contain more information than just the CPU, FLASH/PSRAM sizes etc but also information about the hardware present on the boards. See [more on board defines](#more-on-board-defines) for the details. ->[!IMPORTANT] ->To be able to use these boards copy the board definitions from the [```boards/```](boards/) to the ```.platformio\platforms\espressif32\boards``` directory. ->The ```.platformio``` directory can be found under ```C:\Users\``` (Windows) or ```/home/``` (Linux). - -### Step 2: Create a new project +These boards are defined in the repository [platformio-espressif32-sunton](https://github.com/rzeldent/platformio-espressif32-sunton) so they can also be used in other projects. It is recommended to use the git submodule to include these board definitions automatically. -Use the standard PlatformIO create project to start a new project. -Because depending on the type of board used, the type of ESP32 can be different, choose the right board for your project. The CPU for your board can be looked up in the table of the [supported boards](#supported-boards). +>[!TIP] +>If you already have a project, clone it with the ```git clone --recurse-submodules```. If creating a new project, use ```git submodule add https://github.com/rzeldent/platformio-espressif32-sunton.git boards``` to add them to your project. -Then, choose the right board for your CPU: +### Step 2: Create a new project -| CPU | board | -|--- |--- | -| ESP32-WROOM-32 | esp32dev | -| ESP32-C3-MINI-1U-XXN4 | esp32-c3-devkitm-1 | -| ESP32-S3-WROOM-1-MCN16R8 | esp32-s3-devkitc-1-n16-psram | +Use the standard PlatformIO create project to start a new project. When using a new PlatformIO installation these boards, defined in [platformio-espressif32-sunton](https://github.com/rzeldent/platformio-espressif32-sunton), are not present. +You can copy the boards definition to the ```/.platformio\platforms\espressif32\boards``` directory to have them always available but it is probably easier to create the project, add the baords as a git submodule and change the board afterwards. For each supported board there is a board definition. ### Step 3: Add this library to your project -To add this library (and its dependencies) add the following line to the ```platformio.ini``` file: +To add this library (and its dependency on LVGL) add the following line to the ```platformio.ini``` file: ```ini lib_deps = https://github.com/rzeldent/esp32-smartdisplay.git#feature/esp32s3 @@ -157,7 +149,7 @@ Important settings are: ``` - Because of the SPI interface, the bytes are sent in big endian format so this must be corrected. - The RGB panel interface takes care of this by swapping the GPIO lines. More information about this [below](#more-on-lv_color_16_swap). + The RGB panel interface takes care of this by swapping the GPIO lines but for the SPI controllers this is not optimal. More information about this [below](#more-on-lv_color_16_swap). ```h /*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/ @@ -179,10 +171,12 @@ Important settings are: #define LV_USE_MEM_MONITOR 1 ``` -- Include (some) fonts that are bigger smaller but at lease 22pt. +- (Optionally) Include additional fonts. ```h + ... #define LV_FONT_MONTSERRAT_22 1 + ... ``` - Optionally, only enable widgets that are used to save on code @@ -195,7 +189,8 @@ Important settings are: ... ``` -For debugging it is possible to enable logging from LVGL. The library will output logging debugging output (using ```lv_log_register_print_cb```). To enable logging, set the define: +For debugging it is possible to enable logging from LVGL. The library will output to the debugging output (using ```lv_log_register_print_cb```). +To enable logging, set the define: ```h /*Enable the log module*/ @@ -208,7 +203,7 @@ More information about the LVGL configuration can be found in the excellent [LVG ### Step 5: Copy the defines below in your project -Especially the definition of the LV_CONF_PATH is critical. More about this in the [section below](#more-on-lvglh). +Especially the definition of the LV_CONF_PATH is critical, this must point to an **absolute path** where the ```lv_conf.h``` file is located. More about this in the [section below](#more-on-lvglh). ```ini build_flags = @@ -217,16 +212,6 @@ build_flags = -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE # LVGL settings. Point to your lv_conf.h file -D LV_CONF_PATH="${PROJECT_DIR}/example/lv_conf.h" - # EspressIf library defines - -D ESP_LCD_ST7796_VER_MAJOR=1 - -D ESP_LCD_ST7796_VER_MINOR=2 - -D ESP_LCD_ST7796_VER_PATCH=0 - -D ESP_LCD_ILI9341_VER_MAJOR=1 - -D ESP_LCD_ILI9341_VER_MINOR=2 - -D ESP_LCD_ILI9341_VER_PATCH=0 - -D CONFIG_ESP_LCD_TOUCH_MAX_POINTS=1 - -D CONFIG_XPT2046_CONVERT_ADC_TO_COORDS - -D CONFIG_XPT2046_Z_THRESHOLD=600 ``` The line in the settings logs to the serial console but can be omitted for production builds: @@ -234,9 +219,6 @@ The line in the settings logs to the serial console but can be omitted for produ ```ini -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE ``` ->[!NOTE] ->Flash size, memory type and PSRAM settings are set by using the board settings and do not need to be added. - ### Step 6: Initialize the display (and touch) in your project @@ -288,41 +270,67 @@ If there are problems: ## More on board defines -The boards definitions also contain information about the hardware available. - -| Define | Explanation | -|--- |--- | -| BUTTON_BOOT | GPIO of the BOOT pushbutton | -| TF_PIN_CS | GPIO of the CS of the TF card | -| TF_PIN_MOSI | GPIO of the MOSI of the TF card | -| TF_PIN_SCLK | GPIO of the SCLK of the TF card | -| TF_PIN_MISO | GPIO of the MISO of the TF card | -| TFT_WIDTH | The width of the panel | -| TFT_HEIGHT | The height of the panel | -| PIN_BCKL | The backlight GPIO pin | -| USES_ST7789 | Uses the ST7789 display driver | -| ST7789_SPI_HOST | The SPI host to use for the ST7789 | -| ST7789_SPI_BUS_CONFIG | The ST7789 SPI BUS configuration | -| ST7789_IO_SPI_CONFIG | The ST7789 IO SPI configuration | -| ST7789_PANEL_DEV_CONFIG | The ST7789 Panel device configuration | -| PANEL_SWAP_XY | Swap the panel for LV_DISP_ROT_NONE | -| PANEL_MIRROR_X | Mirror the panel horizontally for LV_DISP_ROT_NONE | -| PANEL_MIRROR_Y | Mirror the panel vertically for LV_DISP_ROT_NONE | -| PANEL_GAP_X | The horizontal gap before the panel starts | -| PANEL_GAP_Y | The vertical gap before the panel starts | -| USES_GT911 | Uses the GT911 capacitive touch controller | -| GT911_I2C_HOST | The GT11 I2C host to user for the GT911 | -| GT911_I2C_CONFIG | The GT11 I2C configuration | -| GT911_IO_I2C_CONFIG | The GT11 IO I2C configuration | -| GT911_TOUCH_CONFIG | The GT11 touch configuration | -| TOUCH_ROT_SWAP_X | Swap the touch horizontally for for LV_DISP_ROT_NONE | -| TOUCH_ROT_SWAP_Y | Swap the touch vertically for for LV_DISP_ROT_NONE | - - - - - -## More on LVGL.h +The [board definitions](https://github.com/rzeldent/platformio-espressif32-sunton) also contain information about the hardware available and how connected. +The table below provides some explanation. At the moment of writing this in still incomplete because focus has been on implementing the defines required for the display and touch. + +| Define | Explanation | +|--- |--- | +| ESP32_wwhhS0ddN/R/C | The board name, e.g. 2423S012C, see [boards](#supported-boards) | +| | | +| BOARD_HAS_PSRAM | The boards has PSRAM | +| | | +| BUTTON_BOOT_GPIO | GPIO of the BOOT pushbutton | +| | | +| LCD_USES_ST7789 | LCD uses the ST7789 display driver | +| LCD_USES_GC9A01 | LCD uses the GC9A01 display driver | +| LCD_USES_ILI9341 | LCD uses the ILI9341 display driver | +| LCD_USES_DIRECT_IO | LCD uses direct IO with the display | +| | | +| LCD_WIDTH | The width of the LCD panel in pixels | +| LCD_HEIGHT | The height of the LCD panel in pixels | +| LCD_BCKL_GPIO | GPIO of the backlight | +| LCD_SPI_HOST | The SPI host to use for the LCD driver | +| LCD_SPI_BUS_CONFIG | The LCD SPI BUS configuration | +| LCD_IO_SPI_CONFIG | The LCD IO SPI configuration | +| LCD_PANEL_DEV_CONFIG | The LCD panel device configuration | +| LCD_RGB_PANEL_CONFIG | The LCD panel settings for LV_COLOR_16_SWAP = 0 | +| LCD_RGB_PANEL_CONFIG_COLOR_16_SWAP | The LCD panel settings for LV_COLOR_16_SWAP = 1 | +| LCD_SWAP_XY | Swap the X and Y axes for the panel | +| LCD_MIRROR_X | Mirror the panel horizontally | +| LCD_MIRROR_Y | Mirror the panel vertically | +| LCD_GAP_X | The horizontal gap in pixels before the panel | +| LCD_GAP_Y | The vertical gap in pixels before the panel | +| | | +| BOARD_HAS_TOUCH | The panel has a touch interface | +| TOUCH_USES_GT911 | Touch uses the GT911 capacitive touch controller | +| TOUCH_USES_CST816S | Touch uses the CST816S capacitive touch controller | +| TOUCH_USES_XPT2046 | Touch uses the XPT2046 resistive touch controller | +| | | +| TOUCH_I2C_HOST | The I2C host to use for the touch controller | +| TOUCH_I2C_CONFIG | The touch I2C configuration | +| TOUCH_IO_I2C_CONFIG | The touch IO I2C configuration | +| TOUCH_DEV_CONFIG | The touch device configuration | +| TOUCH_SWAP_X | Swap the touch horizontally | +| TOUCH_SWAP_Y | Swap the touch vertically | +| | | +| BOARD_HAS_TF | The board has a TF slot | +| TF_CS_GPIO | GPIO of the CS of the TF slot | +| TF_MOSI_GPIO | GPIO of the MOSI of the TF slot | +| TF_SCLK_GPIO | GPIO of the SCLK of the TF slot | +| TF_MISO_GPIO | GPIO of the MISO of the TF slot | +| | | +| BOARD_HAS_RGB_LED | The board has an RGB led | +| LED_R_GPIO | GPIO of the red LED | +| LED_G_GPIO | GPIO of the green LED | +| LED_B_GPIO | GPIO of the blue LED | +| | | +| BOARD_HAS_CDS | The board has a CdS resistive light sensor | +| CDS_GPIO | Analogue GPIO input of the CdS sensor | +| | | +| BOARD_HAS_SPEAK_GPIO | The board has an onboard amplifier for a speaker | +| SPEAK_GPIO | GPIO of the speaker | + +## More on lv_conf.h To use the LVGL library, a `lv_conf.h` file is required to define the settings for LVGL. This file needs to be provided by the application. @@ -400,19 +408,19 @@ Rotating is done calling the ```lv_disp_set_rotation``` function in the LVGL lib >[!NOTE] >Not all boards have a LED. Refer to the [supported boards](#supported-boards) to see if this is available. -If the board has an RGB led, the define ```HAS_RGB_LED``` is defined. +If the board has an RGB led, the define ```BOARD_HAS_RGB_LED``` is defined. Additionally, the following defines are present for the definition of the GPIO pins: -- LED_R -- LED_G -- LED_B +- LED_R_GPIO +- LED_G_GPIO +- LED_B_GPIO Before using the RGB LEDs, the GPIOs must be defined as output ```c++ - pinmode(LED_R, OUTPUT); - pinmode(LED_G, OUTPUT); - pinmode(LED_B, OUTPUT); + pinmode(LED_R_GPIO, OUTPUT); + pinmode(LED_G_GPIO, OUTPUT); + pinmode(LED_B_GPIO, OUTPUT); ``` The LEDs are connected between the GPIO pin and the 3.3V. So the LED will light up if the GPIO is set to LOW (inverted). @@ -422,9 +430,9 @@ The LEDs are connected between the GPIO pin and the 3.3V. So the LED will light For example: set the RGB led to red is done by the following code: ```c++ - digitalWrite(LED_R, false); - digitalWrite(LED_G, true); - digitalWrite(LED_B, true); + digitalWrite(LED_R_GPIO, false); + digitalWrite(LED_G_GPIO, true); + digitalWrite(LED_B_GPIO, true); ``` To have more colors than the 8 RGB combinations, PWM can be used to mix the colors. @@ -445,15 +453,15 @@ ESP_ARDUINO_VERSION_MAJOR < 3: ```c++ ledcSetup(0, 5000, 8); - ledcAttachPin(LED_R, 0); + ledcAttachPin(LED_R_GPIO, 0); ledcWrite(0, 192); ``` ESP_ARDUINO_VERSION_MAJOR >= 3 ```c++ - ledcAttach(LED_R, 0, 8); - ledcWrite(LED_R, 192); + ledcAttach(LED_R_GPIO, 0, 8); + ledcWrite(LED_R_GPIO, 192); ``` ## Reading the CDS (light sensor) @@ -461,22 +469,22 @@ ESP_ARDUINO_VERSION_MAJOR >= 3 >[!NOTE] >Not all boards have a light sensor. Refer to the [supported boards](#supported-boards) to see if this is available. -If the board has a CDS photo resistor (Cadmium Sulfide) light sensor, the define ```HAS_LIGHTSENSOR``` is defined. +If the board has a CDS photo resistor (Cadmium Sulfide, CdS) light sensor, the define ```BOARD_HAS_CDS``` is defined. It is attached to the analogue input of the ESP32 with two resistors between the GND and the VCC. When the CDS is covered, it's resistance is in the order of megaΩ but in bright light can drop to a few 100Ω. ![CDS](assets/images/CDS.png) -To use the sensor, the define ```LIGHTSENSOR_IN``` indicates the analogue port to read. +To use the sensor, the define ```BOARD_HAS_CDS``` indicates the analogue port to read. ```c++ analogSetAttenuation(ADC_0db); // 0dB(1.0x) 0~800mV - pinMode(LIGHTSENSOR_IN, INPUT); + pinMode(CDS_GPIO, INPUT); ``` Next, read the value using: ```c++ - auto value = analogReadMilliVolts(LIGHTSENSOR_IN); + auto value = analogReadMilliVolts(CDS_GPIO); ``` The value ranges from 75mV (not covered) to 400mV (completely covered). @@ -487,13 +495,13 @@ The value ranges from 75mV (not covered) to 400mV (completely covered). >[!NOTE] >Not all boards have a LED. Refer to the [supported boards](#supported-boards) to see if this is available. -An 8Ω speaker can be connected to the SPEAK pin. This is a 1.25 JST connector. -Beeps can be generated by generating a PWM signal on the SPEAK pin: +An 8Ω speaker can be connected to the output marked SPEAK. This is a 1.25 JST connector. +Beeps can be generated by generating a PWM signal on the SPEAK_GPIO: ```c++ -pinmode(SPEAKER, OUTPUT) +pinmode(SPEAK_GPIO, OUTPUT) // Uses PWM Channel 0 -tone(AUDIO_PIN, frequency, duration); +tone(SPEAK_GPIO, frequency, duration); ``` To produce "real" audio connect the internal 8 bits D2A converter in the ESP32. Because the speaker is connected to GPIO26, this is the DAC2 (Left Channel). @@ -501,7 +509,7 @@ To produce "real" audio connect the internal 8 bits D2A converter in the ESP32. >[!TIP] >Make sure the I2S connection is only to the LEFT channel. -The audio is a bit distorted. [HexeguitarDIY](https://github.com/hexeguitar/ESP32_TFT_PIO) has a fix for that by changing the resistor values to prevent distortion. +The audio is a bit distorted. [HexeguitarDIY](https://github.com/hexeguitar/ESP32_LCD_PIO) has a fix for that by changing the resistor values to prevent distortion. [![HexeguitarDIY Audio mod](https://img.youtube.com/vi/6JCLHIXXVus/0.jpg)](https://www.youtube.com/watch?v=6JCLHIXXVus) ## Appendix: Board details @@ -583,9 +591,30 @@ The platformio.ini file below supports all the boards. This is useful when runni ```ini [platformio] -#default_envs = esp32dev -#default_envs = esp32-c3-devkitm-1 -#default_envs = esp32-s3-devkitc-1-n16-psram +#default_envs = esp32-2424S012C +#default_envs = esp32-2424S012N +#default_envs = esp32-2432S024C +#default_envs = esp32-2432S024N +#default_envs = esp32-2432S024R +#default_envs = esp32-2432S028R +#default_envs = esp32-2432S032C +#default_envs = esp32-2432S032N +#default_envs = esp32-2432S032R +#default_envs = esp32-3248S035C +#default_envs = esp32-3248S035R +#default_envs = esp32-1732S019C +#default_envs = esp32-1732S019N +#default_envs = esp32-4827S043C +#default_envs = esp32-4827S043N +#default_envs = esp32-4827S043R +#default_envs = esp32-8048S043C +#default_envs = esp32-8048S043N +#default_envs = esp32-8048S043R +#default_envs = esp32-8048S050C +#default_envs = esp32-8048S050N +#default_envs = esp32-8048S050R +#default_envs = esp32-8048S070C +#default_envs = esp32-8048S070N [env] platform = espressif32 @@ -597,61 +626,81 @@ build_flags = -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE # LVGL settings. Point to your lv_conf.h file -D LV_CONF_PATH="${PROJECT_DIR}/example/lv_conf.h" - # EspressIf library defines - -D ESP_LCD_ST7796_VER_MAJOR=1 - -D ESP_LCD_ST7796_VER_MINOR=2 - -D ESP_LCD_ST7796_VER_PATCH=0 - -D ESP_LCD_ILI9341_VER_MAJOR=1 - -D ESP_LCD_ILI9341_VER_MINOR=2 - -D ESP_LCD_ILI9341_VER_PATCH=0 - -D CONFIG_ESP_LCD_TOUCH_MAX_POINTS=1 - -D CONFIG_XPT2046_CONVERT_ADC_TO_COORDS - -D CONFIG_XPT2046_Z_THRESHOLD=600 - -[env:esp32dev] -board = esp32dev -build_flags = - ${env.build_flags} - # Smartdisplay selection - #-D ESP32_2432S024N - #-D ESP32_2432S024R - #-D ESP32_2432S024C - #-D ESP32_2432S028R - #-D ESP32_3248S032N - #-D ESP32_3248S032R - #-D ESP32_3248S032C - #-D ESP32_3248S035R - #-D ESP32_3248S035C - -[env:esp32-c3-devkitm-1] -board = esp32-c3-devkitm-1 -build_flags = - ${env.build_flags} - # Smartdisplay selection - #-D ESP32_2424S012N - #-D ESP32_2424S012C -[env:esp32-s3-devkitc-1-n16-psram] -board = esp32-s3-devkitc-1-n16-psram -build_flags = - ${env.build_flags} - # Smartdisplay selection - #-D ESP32_1732S019N - #-D ESP32_1732S019C - #-D ESP32_4827S043R - #-D ESP32_4827S043C - #-D ESP32_8048S043N - #-D ESP32_8048S043R - #-D ESP32_8048S043C - #-D ESP32_8048S050N - #-D ESP32_8048S050R - #-D ESP32_8048S050C - #-D ESP32_8048S070N - #-D ESP32_8048S070R - #-D ESP32_8048S070C +[env:esp32-2424S012C] +board = esp32-2424S012C + +[env:esp32-2424S012N] +board = esp32-2424S012N + +[env:esp32-2432S024C] +board = esp32-2432S024C + +[env:esp32-2432S024N] +board = esp32-2432S024N + +[env:esp32-2432S024R] +board = esp32-2432S024R + +[env:esp32-2432S028R] +board = esp32-2432S024R + +[env:esp32-2432S032C] +board = esp32-2432S032C + +[env:esp32-2432S032N] +board = esp32-2432S032N + +[env:esp32-2432S032R] +board = esp32-2432S032R + +[env:esp32-3248S035C] +board = esp32-3248S035C + +[env:esp32-3248S035R] +board = esp32-3248S035R + +[env:esp32-1732S019C] +board = esp32-1732S019C + +[env:esp32-1732S019N] +board = esp32-1732S019N + +[env:esp32-4827S043C] +board = esp32-4827S043C + +[env:esp32-4827S043N] +board = esp32-4827S043N + +[env:esp32-4827S043R] +board = esp32-4827S043R + +[env:esp32-8048S043C] +board = esp32-8048S043C + +[env:esp32-8048S043N] +board = esp32-8048S043N + +[env:esp32-8048S043R] +board = esp32-8048S043R + +[env:esp32-8048S050C] +board = esp32-8048S050C + +[env:esp32-8048S050N] +board = esp32-8048S050N + +[env:esp32-8048S050R] +board = esp32-8048S050R + +[env:esp32-8048S070C] +board = esp32-8048S070C + +[env:esp32-8048S070N] +board = esp32-8048S070N ``` -## Appendix: lvgl_conf.h example +## Appendix: lv_conf.h example ```cpp /** diff --git a/example/lv_conf.h b/examples/ci/lv_conf.h similarity index 100% rename from example/lv_conf.h rename to examples/ci/lv_conf.h diff --git a/example/main.cpp b/examples/ci/main.cpp similarity index 100% rename from example/main.cpp rename to examples/ci/main.cpp diff --git a/example/platformio.ini b/examples/ci/platformio.ini similarity index 83% rename from example/platformio.ini rename to examples/ci/platformio.ini index 94bdfd6..909a023 100644 --- a/example/platformio.ini +++ b/examples/ci/platformio.ini @@ -51,20 +51,7 @@ build_flags = #-Wall -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE # LVGL settings - #-D LV_CONF_PATH=${PROJECT_INCLUDE_DIR}/lv_conf.h - # EspressIf library defines - -D ESP_LCD_ST7796_VER_MAJOR=1 - -D ESP_LCD_ST7796_VER_MINOR=2 - -D ESP_LCD_ST7796_VER_PATCH=0 - -D ESP_LCD_ILI9341_VER_MAJOR=1 - -D ESP_LCD_ILI9341_VER_MINOR=2 - -D ESP_LCD_ILI9341_VER_PATCH=0 - -D ESP_LCD_GC9A01_VER_MAJOR=1 - -D ESP_LCD_GC9A01_VER_MINOR=2 - -D ESP_LCD_GC9A01_VER_PATCH=0 - -D CONFIG_ESP_LCD_TOUCH_MAX_POINTS=1 - -D CONFIG_XPT2046_CONVERT_ADC_TO_COORDS - -D CONFIG_XPT2046_Z_THRESHOLD=600 + -D LV_CONF_PATH=${PROJECT_INCLUDE_DIR}/lv_conf.h [env:esp32-2424S012C] board = esp32-2424S012C diff --git a/library.json b/library.json index 8eafaec..5cd05a2 100644 --- a/library.json +++ b/library.json @@ -2,15 +2,29 @@ "$schema": "https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/schema/library.json", "name": "esp32_smartdisplay", "version": "2.0.0", - "description": "LVGL driver for Sunton ESP32 TFT display boards", - "keywords": "LVGL Sunton CYD TFT", + "description": "LVGL driver for Sunton ESP32 display boards", + "keywords": "LVGL Sunton CYD - Cheap Yellow Display LCD TFT Touch", "repository": { "type": "git", "url": "https://github.com/rzeldent/esp32-smartdisplay" }, "build": { "srcDir": "src", - "includeDir": "include" + "includeDir": "include", + "flags": [ + "-DESP_LCD_ST7796_VER_MAJOR=1", + "-DESP_LCD_ST7796_VER_MINOR=2", + "-DESP_LCD_ST7796_VER_PATCH=0", + "-DESP_LCD_ILI9341_VER_MAJOR=1", + "-DESP_LCD_ILI9341_VER_MINOR=2", + "-DESP_LCD_ILI9341_VER_PATCH=0", + "-DESP_LCD_GC9A01_VER_MAJOR=1", + "-DESP_LCD_GC9A01_VER_MINOR=2", + "-DESP_LCD_GC9A01_VER_PATCH=0", + "-DCONFIG_ESP_LCD_TOUCH_MAX_POINTS=1", + "-DCONFIG_XPT2046_CONVERT_ADC_TO_COORDS", + "-DCONFIG_XPT2046_Z_THRESHOLD=600" + ] }, "export": { "include": [ diff --git a/src/esp32_smartdisplay.c b/src/esp32_smartdisplay.c index 2a982da..f8395ac 100644 --- a/src/esp32_smartdisplay.c +++ b/src/esp32_smartdisplay.c @@ -27,55 +27,55 @@ static void lvgl_update_callback(lv_disp_drv_t *drv) switch (drv->rotated) { case LV_DISP_ROT_NONE: -#if defined(PANEL_SWAP_XY) && defined(PANEL_MIRROR_X) && defined(PANEL_MIRROR_Y) - ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, PANEL_SWAP_XY)); - ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, PANEL_MIRROR_X, PANEL_MIRROR_Y)); +#if defined(LCD_SWAP_XY) && defined(LCD_MIRROR_X) && defined(LCD_MIRROR_Y) + ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, LCD_SWAP_XY)); + ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, LCD_MIRROR_X, LCD_MIRROR_Y)); #endif -#if defined(PANEL_GAP_X) || defined(PANEL_GAP_Y) - ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle, PANEL_GAP_X, PANEL_GAP_Y)); +#if defined(LCD_GAP_X) || defined(LCD_GAP_Y) + ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle, LCD_GAP_X, LCD_GAP_Y)); #endif -#ifdef HAS_TOUCH - ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, TOUCH_ROT_SWAP_X)); - ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, TOUCH_ROT_SWAP_Y)); +#ifdef BOARD_HAS_TOUCH + ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, TOUCH_SWAP_X)); + ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, TOUCH_SWAP_Y)); #endif break; case LV_DISP_ROT_90: -#if defined(PANEL_SWAP_XY) && defined(PANEL_MIRROR_X) && defined(PANEL_MIRROR_Y) - ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, !PANEL_SWAP_XY)); - ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, !PANEL_MIRROR_X, PANEL_MIRROR_Y)); +#if defined(LCD_SWAP_XY) && defined(LCD_MIRROR_X) && defined(LCD_MIRROR_Y) + ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, !LCD_SWAP_XY)); + ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, !LCD_MIRROR_X, LCD_MIRROR_Y)); #endif -#if defined(PANEL_GAP_X) || defined(PANEL_GAP_Y) - ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle, PANEL_GAP_Y, PANEL_GAP_X)); +#if defined(LCD_GAP_X) || defined(LCD_GAP_Y) + ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle, LCD_GAP_Y, LCD_GAP_X)); #endif -#ifdef HAS_TOUCH - ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, !TOUCH_ROT_SWAP_X)); - ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, !TOUCH_ROT_SWAP_Y)); +#ifdef BOARD_HAS_TOUCH + ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, !TOUCH_SWAP_X)); + ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, !TOUCH_SWAP_Y)); #endif break; case LV_DISP_ROT_180: -#if defined(PANEL_SWAP_XY) && defined(PANEL_MIRROR_X) && defined(PANEL_MIRROR_Y) - ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, PANEL_SWAP_XY)); - ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, !PANEL_MIRROR_X, !PANEL_MIRROR_Y)); +#if defined(LCD_SWAP_XY) && defined(LCD_MIRROR_X) && defined(LCD_MIRROR_Y) + ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, LCD_SWAP_XY)); + ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, !LCD_MIRROR_X, !LCD_MIRROR_Y)); #endif -#if defined(PANEL_GAP_X) || defined(PANEL_GAP_Y) - ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle, PANEL_GAP_X, PANEL_GAP_Y)); +#if defined(LCD_GAP_X) || defined(LCD_GAP_Y) + ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle, LCD_GAP_X, LCD_GAP_Y)); #endif -#ifdef HAS_TOUCH - ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, TOUCH_ROT_SWAP_X)); - ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, TOUCH_ROT_SWAP_Y)); +#ifdef BOARD_HAS_TOUCH + ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, TOUCH_SWAP_X)); + ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, TOUCH_SWAP_Y)); #endif break; case LV_DISP_ROT_270: -#if defined(PANEL_SWAP_XY) && defined(PANEL_MIRROR_X) && defined(PANEL_MIRROR_Y) - ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, !PANEL_SWAP_XY)); - ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, PANEL_MIRROR_X, !PANEL_MIRROR_Y)); +#if defined(LCD_SWAP_XY) && defined(LCD_MIRROR_X) && defined(LCD_MIRROR_Y) + ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, !LCD_SWAP_XY)); + ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, LCD_MIRROR_X, !LCD_MIRROR_Y)); #endif -#if defined(PANEL_GAP_X) || defined(PANEL_GAP_Y) - ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle, PANEL_GAP_Y, PANEL_GAP_X)); +#if defined(LCD_GAP_X) || defined(LCD_GAP_Y) + ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle, LCD_GAP_Y, LCD_GAP_X)); #endif -#ifdef HAS_TOUCH - ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, !TOUCH_ROT_SWAP_X)); - ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, !TOUCH_ROT_SWAP_Y)); +#ifdef BOARD_HAS_TOUCH + ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, !TOUCH_SWAP_X)); + ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, !TOUCH_SWAP_Y)); #endif break; } @@ -83,14 +83,14 @@ static void lvgl_update_callback(lv_disp_drv_t *drv) void smartdisplay_init() { -#ifdef HAS_RGB_LED +#ifdef BOARD_HAS_RGB_LED // Setup RGB LED. High is off - pinMode(LED_R, OUTPUT); - digitalWrite(LED_R, true); - pinMode(LED_G, OUTPUT); - digitalWrite(LED_G, true); - pinMode(LED_B, OUTPUT); - digitalWrite(LED_B, true); + pinMode(LED_R_GPIO, OUTPUT); + digitalWrite(LED_R_GPIO, true); + pinMode(LED_G_GPIO, OUTPUT); + digitalWrite(LED_G_GPIO, true); + pinMode(LED_B_GPIO, OUTPUT); + digitalWrite(LED_B_GPIO, true); #endif #ifdef HAS_LIGHTSENSOR @@ -99,10 +99,10 @@ void smartdisplay_init() pinMode(LIGHTSENSOR_IN, INPUT); #endif -#ifdef HAS_SPEAK +#ifdef BOARD_HAS_SPEAK_GPIO // Speaker // Note: tone function uses PWM channel 0 - pinMode(SPEAKER, INPUT); // Set high impedance + pinMode(SPEAK_GPIO, OUTPUT); #endif #if LV_USE_LOG @@ -111,21 +111,21 @@ void smartdisplay_init() lv_init(); // Setup backlight - pinMode(PIN_BCKL, OUTPUT); + pinMode(LCD_BCKL_GPIO, OUTPUT); #if ESP_ARDUINO_VERSION_MAJOR >= 3 - ledcAttach(PIN_BCKL, PWM_FREQ_BCKL, PWM_BITS_BCKL); + ledcAttach(LCD_BCKL_GPIO, PWM_FREQ_BCKL, PWM_BITS_BCKL); #else ledcSetup(PWM_CHANNEL_BCKL, PWM_FREQ_BCKL, PWM_BITS_BCKL); - ledcAttachPin(PIN_BCKL, PWM_CHANNEL_BCKL); + ledcAttachPin(LCD_BCKL_GPIO, PWM_CHANNEL_BCKL); #endif - digitalWrite(PIN_BCKL, LOW); + digitalWrite(LCD_BCKL_GPIO, LOW); // Setup TFT display lv_disp_drv_init(&disp_drv); - disp_drv.hor_res = TFT_WIDTH; - disp_drv.ver_res = TFT_HEIGHT; + disp_drv.hor_res = LCD_WIDTH; + disp_drv.ver_res = LCD_HEIGHT; // Create drawBuffer disp_drv.draw_buf = (lv_disp_draw_buf_t *)malloc(sizeof(lv_disp_draw_buf_t)); - uint drawBufferPixels = TFT_WIDTH * LVGL_PIXEL_BUFFER_LINES; + uint drawBufferPixels = LCD_WIDTH * LVGL_PIXEL_BUFFER_LINES; void *drawBuffer = heap_caps_malloc(sizeof(lv_color16_t) * drawBufferPixels, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); lv_disp_draw_buf_init(disp_drv.draw_buf, drawBuffer, NULL, drawBufferPixels); // Initialize specific driver @@ -137,7 +137,7 @@ void smartdisplay_init() smartdisplay_tft_set_backlight(0.5f); // If there is a touch controller defined -#ifdef HAS_TOUCH +#ifdef BOARD_HAS_TOUCH // Setup touch lv_indev_drv_init(&indev_drv); indev_drv.disp = display; @@ -154,7 +154,7 @@ void smartdisplay_init() void smartdisplay_tft_set_backlight(float duty) { #if ESP_ARDUINO_VERSION_MAJOR >= 3 - ledcWrite(PIN_BCKL, dut * PWM_MAX_BCKL); + ledcWrite(LCD_BCKL_GPIO, dut * PWM_MAX_BCKL); #else ledcWrite(PWM_CHANNEL_BCKL, duty * PWM_MAX_BCKL); #endif diff --git a/src/lvgl_cst816s.c b/src/lvgl_cst816s.c index 2240e76..5551e30 100644 --- a/src/lvgl_cst816s.c +++ b/src/lvgl_cst816s.c @@ -1,6 +1,6 @@ #include -#ifdef USES_CST816S +#ifdef TOUCH_USES_CST816S #include "driver/i2c.h" #include "esp_lcd_touch.h" @@ -31,18 +31,18 @@ static void cst816s_lvgl_touch_cb(lv_indev_drv_t *drv, lv_indev_data_t *data) void lvgl_touch_init(lv_indev_drv_t *drv) { // Create I2C bus - const i2c_config_t i2c_config = CST816S_I2C_CONFIG; - ESP_ERROR_CHECK(i2c_param_config(CST816S_I2C_HOST, &i2c_config)); - ESP_ERROR_CHECK(i2c_driver_install(CST816S_I2C_HOST, i2c_config.mode, 0, 0, 0)); + const i2c_config_t i2c_config = TOUCH_I2C_CONFIG; + ESP_ERROR_CHECK(i2c_param_config(TOUCH_I2C_HOST, &i2c_config)); + ESP_ERROR_CHECK(i2c_driver_install(TOUCH_I2C_HOST, i2c_config.mode, 0, 0, 0)); // Create IO handle - esp_lcd_panel_io_i2c_config_t io_i2c_config = CST816S_IO_I2C_CONFIG; + esp_lcd_panel_io_i2c_config_t io_i2c_config = TOUCH_IO_I2C_CONFIG; io_i2c_config.user_ctx = drv; esp_lcd_panel_io_handle_t io_handle; - ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)CST816S_I2C_HOST, &io_i2c_config, &io_handle)); + ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TOUCH_I2C_HOST, &io_i2c_config, &io_handle)); // Create touch configuration - esp_lcd_touch_config_t touch_config = CST816S_TOUCH_CONFIG; + esp_lcd_touch_config_t touch_config = TOUCH_DEV_CONFIG; touch_config.user_data = io_handle; esp_lcd_touch_handle_t touch_handle; ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_cst816s(io_handle, &touch_config, &touch_handle)); diff --git a/src/lvgl_gc9a01.c b/src/lvgl_gc9a01.c index 8adfabe..208f3b2 100644 --- a/src/lvgl_gc9a01.c +++ b/src/lvgl_gc9a01.c @@ -1,6 +1,6 @@ #include -#ifdef USES_GC9A01 +#ifdef LCD_USES_GC9A01 #include #include @@ -36,18 +36,18 @@ void lvgl_tft_init(lv_disp_drv_t *drv) drv->rotated = LV_DISP_ROT_NONE; // Create SPI bus - const spi_bus_config_t spi_bus_config = GC9A01_SPI_BUS_CONFIG; - ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(GC9A01_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO)); + const spi_bus_config_t spi_bus_config = LCD_SPI_BUS_CONFIG; + ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(LCD_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO)); // Attach the LCD controller to the SPI bus - esp_lcd_panel_io_spi_config_t io_config = GC9A01_IO_SPI_CONFIG; + esp_lcd_panel_io_spi_config_t io_config = LCD_IO_SPI_CONFIG; io_config.user_ctx = drv; io_config.on_color_trans_done = gc9a01_color_trans_done; esp_lcd_panel_io_handle_t io_handle; - ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)GC9A01_SPI_HOST, &io_config, &io_handle)); + ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)LCD_SPI_HOST, &io_config, &io_handle)); // Create gc9a01 panel handle - esp_lcd_panel_dev_config_t panel_dev_config = GC9A01_PANEL_DEV_CONFIG; + esp_lcd_panel_dev_config_t panel_dev_config = LCD_PANEL_DEV_CONFIG; esp_lcd_panel_handle_t panel_handle; ESP_ERROR_CHECK(esp_lcd_new_panel_gc9a01(io_handle, &panel_dev_config, &panel_handle)); diff --git a/src/lvgl_gt911.c b/src/lvgl_gt911.c index 76eb37b..3884c95 100644 --- a/src/lvgl_gt911.c +++ b/src/lvgl_gt911.c @@ -1,6 +1,6 @@ #include -#ifdef USES_GT911 +#ifdef TOUCH_USES_GT911 #include "driver/i2c.h" #include "esp_lcd_touch.h" @@ -31,18 +31,18 @@ static void gt911_lvgl_touch_cb(lv_indev_drv_t *drv, lv_indev_data_t *data) void lvgl_touch_init(lv_indev_drv_t *drv) { // Create I2C bus - const i2c_config_t i2c_config = GT911_I2C_CONFIG; - ESP_ERROR_CHECK(i2c_param_config(GT911_I2C_HOST, &i2c_config)); - ESP_ERROR_CHECK(i2c_driver_install(GT911_I2C_HOST, i2c_config.mode, 0, 0, 0)); + const i2c_config_t i2c_config = TOUCH_I2C_CONFIG; + ESP_ERROR_CHECK(i2c_param_config(TOUCH_I2C_HOST, &i2c_config)); + ESP_ERROR_CHECK(i2c_driver_install(TOUCH_I2C_HOST, i2c_config.mode, 0, 0, 0)); // Create IO handle - esp_lcd_panel_io_i2c_config_t io_i2c_config = GT911_IO_I2C_CONFIG; + esp_lcd_panel_io_i2c_config_t io_i2c_config = TOUCH_IO_I2C_CONFIG; io_i2c_config.user_ctx = drv; esp_lcd_panel_io_handle_t io_handle; - ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)GT911_I2C_HOST, &io_i2c_config, &io_handle)); + ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TOUCH_I2C_HOST, &io_i2c_config, &io_handle)); // Create touch configuration - esp_lcd_touch_config_t touch_config = GT911_TOUCH_CONFIG; + esp_lcd_touch_config_t touch_config = TOUCH_DEV_CONFIG; touch_config.user_data = io_handle; esp_lcd_touch_handle_t touch_handle; diff --git a/src/lvgl_ili9341.c b/src/lvgl_ili9341.c index 2a3fe49..800f687 100644 --- a/src/lvgl_ili9341.c +++ b/src/lvgl_ili9341.c @@ -1,6 +1,6 @@ #include -#ifdef USES_ILI9341 +#ifdef LCD_USES_ILI9341 #include #include @@ -36,18 +36,18 @@ void lvgl_tft_init(lv_disp_drv_t *drv) drv->rotated = LV_DISP_ROT_NONE; // Create SPI bus - const spi_bus_config_t spi_bus_config = ILI9341_SPI_BUS_CONFIG; - ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(ILI9341_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO)); + const spi_bus_config_t spi_bus_config = LCD_SPI_BUS_CONFIG; + ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(LCD_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO)); // Attach the LCD controller to the SPI bus - esp_lcd_panel_io_spi_config_t io_config = ILI9341_IO_SPI_CONFIG; + esp_lcd_panel_io_spi_config_t io_config = LCD_IO_SPI_CONFIG; io_config.on_color_trans_done = ili9341_color_trans_done; io_config.user_ctx = drv; esp_lcd_panel_io_handle_t io_handle; - ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)ILI9341_SPI_HOST, &io_config, &io_handle)); + ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)LCD_SPI_HOST, &io_config, &io_handle)); // Create ili9341 panel handle - const esp_lcd_panel_dev_config_t panel_dev_config = ILI9341_PANEL_DEV_CONFIG; + const esp_lcd_panel_dev_config_t panel_dev_config = LCD_PANEL_DEV_CONFIG; esp_lcd_panel_handle_t panel_handle; ESP_ERROR_CHECK(esp_lcd_new_panel_ili9341(io_handle, &panel_dev_config, &panel_handle)); ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle)); diff --git a/src/lvgl_parallel16.c b/src/lvgl_parallel16.c index d08111d..74cdb8d 100644 --- a/src/lvgl_parallel16.c +++ b/src/lvgl_parallel16.c @@ -1,6 +1,6 @@ #include -#ifdef USES_PARALLEL_16 +#ifdef LCD_USES_DIRECT_IO #include #include @@ -27,9 +27,9 @@ void lvgl_tft_init(lv_disp_drv_t *drv) // Create direct_io panel handle #if LV_COLOR_16_SWAP != 0 - esp_lcd_rgb_panel_config_t tft_panel_config = TFT_RGB_CONFIG_COLOR_16_SWAP; + esp_lcd_rgb_panel_config_t tft_panel_config = LCD_RGB_PANEL_CONFIG_COLOR_16_SWAP; #else - esp_lcd_rgb_panel_config_t tft_panel_config = TFT_RGB_CONFIG; + esp_lcd_rgb_panel_config_t tft_panel_config = LCD_RGB_PANEL_CONFIG; #endif tft_panel_config.on_frame_trans_done = direct_io_frame_trans_done; tft_panel_config.user_ctx = drv; diff --git a/src/lvgl_st7789.c b/src/lvgl_st7789.c index f15b53b..8186a3a 100644 --- a/src/lvgl_st7789.c +++ b/src/lvgl_st7789.c @@ -1,6 +1,6 @@ #include -#ifdef USES_ST7789 +#ifdef LCD_USES_ST7789 #include #include @@ -34,18 +34,18 @@ void lvgl_tft_init(lv_disp_drv_t *drv) drv->rotated = LV_DISP_ROT_NONE; // Create SPI bus - const spi_bus_config_t spi_bus_config = ST7789_SPI_BUS_CONFIG; - ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(ST7789_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO)); + const spi_bus_config_t spi_bus_config = LCD_SPI_BUS_CONFIG; + ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(LCD_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO)); // Attach the LCD controller to the SPI bus - esp_lcd_panel_io_spi_config_t io_spi_config = ST7789_IO_SPI_CONFIG; + esp_lcd_panel_io_spi_config_t io_spi_config = LCD_IO_SPI_CONFIG; io_spi_config.on_color_trans_done = st7789_color_trans_done; io_spi_config.user_ctx = drv; esp_lcd_panel_io_handle_t io_handle; - ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)ST7789_SPI_HOST, &io_spi_config, &io_handle)); + ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)LCD_SPI_HOST, &io_spi_config, &io_handle)); // Create st7789 panel handle - const esp_lcd_panel_dev_config_t panel_dev_config = ST7789_PANEL_DEV_CONFIG; + const esp_lcd_panel_dev_config_t panel_dev_config = LCD_PANEL_DEV_CONFIG; esp_lcd_panel_handle_t panel_handle; ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(io_handle, &panel_dev_config, &panel_handle)); diff --git a/src/lvgl_st7796.c b/src/lvgl_st7796.c index 2322779..422b6aa 100644 --- a/src/lvgl_st7796.c +++ b/src/lvgl_st7796.c @@ -36,18 +36,18 @@ void lvgl_tft_init(lv_disp_drv_t *drv) drv->rotated = LV_DISP_ROT_NONE; // Create SPI bus - const spi_bus_config_t spi_bus_config = ST7796_SPI_BUS_CONFIG; - ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(ST7796_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO)); + const spi_bus_config_t spi_bus_config = LCD_SPI_BUS_CONFIG; + ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(LCD_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO)); // Attach the LCD controller to the SPI bus - esp_lcd_panel_io_spi_config_t io_spi_config = ST7796_IO_SPI_CONFIG; + esp_lcd_panel_io_spi_config_t io_spi_config = LCD_IO_SPI_CONFIG; io_spi_config.on_color_trans_done = st7796_color_trans_done; io_spi_config.user_ctx = drv; esp_lcd_panel_io_handle_t io_handle; - ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)ST7796_SPI_HOST, &io_spi_config, &io_handle)); + ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)LCD_SPI_HOST, &io_spi_config, &io_handle)); // Create st7796 panel handle - const esp_lcd_panel_dev_config_t panel_dev_config = ST7796_PANEL_DEV_CONFIG; + const esp_lcd_panel_dev_config_t panel_dev_config = LCD_PANEL_DEV_CONFIG; esp_lcd_panel_handle_t panel_handle; ESP_ERROR_CHECK(esp_lcd_new_panel_st7796(io_handle, &panel_dev_config, &panel_handle)); diff --git a/src/lvgl_xpt2046.c b/src/lvgl_xpt2046.c index e07e72f..f523ce5 100644 --- a/src/lvgl_xpt2046.c +++ b/src/lvgl_xpt2046.c @@ -1,6 +1,6 @@ #include -#ifdef USES_XPT2046 +#ifdef TOUCH_USES_XPT2046 #include #include "esp_lcd_touch.h" @@ -31,17 +31,17 @@ static void xpt2046_lvgl_touch_cb(lv_indev_drv_t *drv, lv_indev_data_t *data) void lvgl_touch_init(lv_indev_drv_t *drv) { // Create SPI bus only if not already initialized (S035R shares the SPI bus) - const spi_bus_config_t spi_bus_config = XPT2046_SPI_BUS_CONFIG; - ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(XPT2046_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO)); + const spi_bus_config_t spi_bus_config = TOUCH_SPI_BUS_CONFIG; + ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(TOUCH_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO)); // Attach the touch controller to the SPI bus - esp_lcd_panel_io_spi_config_t io_spi_config = XPT2046_IO_SPI_CONFIG; + esp_lcd_panel_io_spi_config_t io_spi_config = TOUCH_IO_SPI_CONFIG; io_spi_config.user_ctx = drv; esp_lcd_panel_io_handle_t io_handle; - ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)XPT2046_SPI_HOST, &io_spi_config, &io_handle)); + ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)TOUCH_SPI_HOST, &io_spi_config, &io_handle)); // Create touch configuration - esp_lcd_touch_config_t touch_config = XPT2046_TOUCH_CONFIG; + esp_lcd_touch_config_t touch_config = TOUCH_DEV_CONFIG; touch_config.user_data = io_handle; esp_lcd_touch_handle_t touch_handle; ESP_ERROR_CHECK(esp_lcd_touch_new_spi_xpt2046(io_handle, &touch_config, &touch_handle));