Skip to content

Feature/esp32c3 support #69

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 9 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ if(CONFIG_LV_TOUCH_CONTROLLER)
list(APPEND SOURCES "lvgl_touch/FT81x.c")
elseif(CONFIG_LV_TOUCH_CONTROLLER_RA8875)
list(APPEND SOURCES "lvgl_touch/ra8875_touch.c")
elseif(CONFIG_LV_TOUCH_CONTROLLER_GT911)
list(APPEND SOURCES "lvgl_touch/gt911.c")
endif()

if(CONFIG_LV_TOUCH_DRIVER_PROTOCOL_SPI)
Expand Down
26 changes: 23 additions & 3 deletions lvgl_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include "driver/i2c.h"

#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "src/lv_core/lv_refr.h"
#include "lvgl.h"
#else
#include "lvgl/src/lv_core/lv_refr.h"
#include "lvgl/lvgl.h"
#endif

/*********************
Expand Down Expand Up @@ -53,7 +53,12 @@
/* Interface and driver initialization */
void lvgl_driver_init(void)
{
/* Since LVGL v8 LV_HOR_RES_MAX and LV_VER_RES_MAX are not defined, so
* print it only if they are defined. */
#if (LVGL_VERSION_MAJOR < 8)
ESP_LOGI(TAG, "Display hor size: %d, ver size: %d", LV_HOR_RES_MAX, LV_VER_RES_MAX);
#endif

ESP_LOGI(TAG, "Display buffer size: %d", DISP_BUF_SIZE);

#if defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X)
Expand Down Expand Up @@ -204,16 +209,31 @@ bool lvgl_spi_driver_init(int host,
int dma_channel,
int quadwp_pin, int quadhd_pin)
{
spi_dma_chan_t dma_chan = SPI_DMA_DISABLED;

#if defined (CONFIG_IDF_TARGET_ESP32)
assert((SPI_HOST <= host) && (VSPI_HOST >= host));
const char *spi_names[] = {
"SPI_HOST", "HSPI_HOST", "VSPI_HOST"
};

dma_chan = dma_channel;
#elif defined (CONFIG_IDF_TARGET_ESP32S2)
assert((SPI_HOST <= host) && (HSPI_HOST >= host));
const char *spi_names[] = {
"SPI_HOST", "", ""
};

dma_chan = dma_channel;
#elif defined (CONFIG_IDF_TARGET_ESP32C3)
assert((SPI1_HOST <= host) && (SPI3_HOST >= host));
const char *spi_names[] = {
"SPI1_HOST", "SPI2_HOST", "SPI3_HOST"
};

dma_chan = SPI_DMA_CH_AUTO;
#else
#error "Target chip not selected"
#endif

ESP_LOGI(TAG, "Configuring SPI host %s (%d)", spi_names[host], host);
Expand All @@ -232,7 +252,7 @@ bool lvgl_spi_driver_init(int host,
};

ESP_LOGI(TAG, "Initializing SPI bus...");
esp_err_t ret = spi_bus_initialize(host, &buscfg, dma_channel);
esp_err_t ret = spi_bus_initialize(host, &buscfg, dma_chan);
assert(ret == ESP_OK);

return ESP_OK != ret;
Expand Down
10 changes: 7 additions & 3 deletions lvgl_spi_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,15 @@ extern "C" {
#define ENABLE_TOUCH_INPUT CONFIG_LV_ENABLE_TOUCH

#if defined (CONFIG_LV_TFT_DISPLAY_SPI_HSPI)
#define TFT_SPI_HOST HSPI_HOST
#if defined (CONFIG_IDF_TARGET_ESP32C3)
#define TFT_SPI_HOST SPI2_HOST
#else
#define TFT_SPI_HOST HSPI_HOST
#endif
#elif defined (CONFIG_LV_TFT_DISPLAY_SPI_VSPI)
#define TFT_SPI_HOST VSPI_HOST
#define TFT_SPI_HOST VSPI_HOST
#elif defined (CONFIG_LV_TFT_DISPLAY_SPI_FSPI)
#define TFT_SPI_HOST FSPI_HOST
#define TFT_SPI_HOST FSPI_HOST
#endif

#if defined (CONFIG_LV_TFT_DISPLAY_SPI_HALF_DUPLEX)
Expand Down
15 changes: 14 additions & 1 deletion lvgl_tft/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ menu "LVGL TFT Display controller"
int "GPIO for MOSI (Master Out Slave In)" if LV_TFT_DISPLAY_PROTOCOL_SPI
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 23 if LV_PREDEFINED_DISPLAY_WROVER4
default 23 if LV_PREDEFINED_DISPLAY_ATAG
Expand Down Expand Up @@ -801,6 +802,7 @@ menu "LVGL TFT Display controller"
depends on LV_DISPLAY_USE_SPI_MISO
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 19 if LV_PREDEFINED_PINS_TKOALA
default 38 if LV_PREDEFINED_DISPLAY_M5CORE2
Expand All @@ -823,6 +825,7 @@ menu "LVGL TFT Display controller"
depends on LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
range -1 39 if IDF_TARGET_ESP32
range -1 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 22 if LV_PREDEFINED_PINS_TKOALA && LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
default -1
Expand All @@ -834,6 +837,7 @@ menu "LVGL TFT Display controller"
depends on LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
range -1 39 if IDF_TARGET_ESP32
range -1 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 21 if LV_PREDEFINED_PINS_TKOALA && LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
default -1
Expand All @@ -844,6 +848,7 @@ menu "LVGL TFT Display controller"
int "GPIO for CLK (SCK / Serial Clock)" if LV_TFT_DISPLAY_PROTOCOL_SPI
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 18 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
default 18 if LV_PREDEFINED_DISPLAY_M5CORE2
Expand Down Expand Up @@ -872,6 +877,7 @@ menu "LVGL TFT Display controller"
depends on LV_DISPLAY_USE_SPI_CS
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 5 if LV_PREDEFINED_PINS_38V1
default 14 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
Expand Down Expand Up @@ -900,6 +906,7 @@ menu "LVGL TFT Display controller"
int "GPIO for DC (Data / Command)" if LV_TFT_DISPLAY_PROTOCOL_SPI
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

depends on LV_DISPLAY_USE_DC
default 19 if LV_PREDEFINED_PINS_38V1
Expand Down Expand Up @@ -937,6 +944,7 @@ menu "LVGL TFT Display controller"
depends on LV_DISP_USE_RST
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 18 if LV_PREDEFINED_PINS_38V1
default 25 if LV_PREDEFINED_PINS_38V4
Expand All @@ -958,9 +966,11 @@ menu "LVGL TFT Display controller"
int "GPIO for Busy" if LV_TFT_DISPLAY_CONTROLLER_IL3820 || LV_TFT_DISPLAY_CONTROLLER_JD79653A || LV_TFT_DISPLAY_CONTROLLER_UC8151D
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 35 if LV_TFT_DISPLAY_CONTROLLER_IL3820 || LV_TFT_DISPLAY_CONTROLLER_JD79653A || LV_TFT_DISPLAY_CONTROLLER_UC8151D
default 35
default 35 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2
default 21 if IDF_TARGET_ESP32C3

help
Configure the display Busy pin here.
Expand Down Expand Up @@ -997,6 +1007,7 @@ menu "LVGL TFT Display controller"
depends on LV_ENABLE_BACKLIGHT_CONTROL
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 23 if LV_PREDEFINED_PINS_38V1
default 26 if LV_PREDEFINED_PINS_38V4
Expand All @@ -1017,6 +1028,7 @@ menu "LVGL TFT Display controller"
int "GPIO for I2C SDA" if LV_TFT_DISPLAY_PROTOCOL_I2C
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 5 if LV_PREDEFINED_DISPLAY_WEMOS_LOLIN
default 5
Expand All @@ -1028,6 +1040,7 @@ menu "LVGL TFT Display controller"
int "GPIO for I2C SCL" if LV_TFT_DISPLAY_PROTOCOL_I2C
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 4 if LV_PREDEFINED_DISPLAY_WEMOS_LOLIN
default 4
Expand Down
60 changes: 60 additions & 0 deletions lvgl_touch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ menu "LVGL Touch controller"
default 4 if LV_TOUCH_CONTROLLER_ADCRAW
default 5 if LV_TOUCH_CONTROLLER_FT81X
default 6 if LV_TOUCH_CONTROLLER_RA8875
default 7 if LV_TOUCH_CONTROLLER_GT911

choice
prompt "Select a touch panel controller model."
Expand Down Expand Up @@ -36,6 +37,9 @@ menu "LVGL Touch controller"
config LV_TOUCH_CONTROLLER_RA8875
select LV_TOUCH_DRIVER_DISPLAY
bool "RA8875"
config LV_TOUCH_CONTROLLER_GT911
select LV_TOUCH_DRIVER_PROTOCOL_I2C
bool "GT911"
endchoice

config LV_TOUCH_DRIVER_PROTOCOL_SPI
Expand Down Expand Up @@ -98,6 +102,7 @@ menu "LVGL Touch controller"
prompt "GPIO for MISO (Master In Slave Out)"
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 35 if LV_PREDEFINED_PINS_38V1
default 19
Expand All @@ -109,6 +114,7 @@ menu "LVGL Touch controller"
prompt "GPIO for MOSI (Master Out Slave In)"
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 32 if LV_PREDEFINED_PINS_38V1
default 23
Expand All @@ -119,6 +125,7 @@ menu "LVGL Touch controller"
int "GPIO for CLK (SCK / Serial Clock)"
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 26 if LV_PREDEFINED_PINS_38V1
default 18
Expand All @@ -139,6 +146,7 @@ menu "LVGL Touch controller"
int "GPIO for IRQ (Interrupt Request)"
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 27 if LV_PREDEFINED_PINS_38V4
default 25
Expand Down Expand Up @@ -211,6 +219,7 @@ menu "LVGL Touch controller"
prompt "GPIO for SDA (I2C)"
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 21
help
Expand All @@ -220,6 +229,7 @@ menu "LVGL Touch controller"
int "GPIO for clock signal SCL (I2C)"
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 22
help
Expand Down Expand Up @@ -254,6 +264,7 @@ menu "LVGL Touch controller"
prompt "GPIO for MISO (Master In Slave Out)"
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 35 if LV_PREDEFINED_PINS_38V1
default 19 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
Expand All @@ -263,10 +274,12 @@ menu "LVGL Touch controller"
Configure the touchpanel MISO pin here.

config LV_TOUCH_SPI_MOSI
# TODO Fix default for ESP32C3
int
prompt "GPIO for MOSI (Master Out Slave In)"
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 32 if LV_PREDEFINED_PINS_38V1
default 18 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
Expand All @@ -279,6 +292,7 @@ menu "LVGL Touch controller"
int "GPIO for CLK (SCK / Serial Clock)"
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 26 if LV_PREDEFINED_PINS_38V1
default 5 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
Expand All @@ -290,6 +304,7 @@ menu "LVGL Touch controller"
int "GPIO for CS (Slave Select)"
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 33 if LV_PREDEFINED_PINS_38V1
default 32 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
Expand Down Expand Up @@ -487,5 +502,50 @@ menu "LVGL Touch controller"
default y

endmenu

menu "Touchpanel (GT911) Pin Assignments"
depends on LV_TOUCH_CONTROLLER_GT911

config LV_TOUCH_I2C_SDA
int
prompt "GPIO for SDA (I2C)"
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 2
help
Configure the I2C touchpanel SDA pin here.

config LV_TOUCH_I2C_SCL
int "GPIO for clock signal SCL (I2C)"
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
range 0 21 if IDF_TARGET_ESP32C3

default 3
help
Configure the I2C touchpanel SCL pin here.
endmenu

menu "Touchpanel Configuration (GT911)"
depends on LV_TOUCH_CONTROLLER_GT911

config LV_GT911_SWAPXY
bool
prompt "Swap X with Y coordinate."
default y

config LV_GT911_INVERT_X
bool
prompt "Invert X coordinate value."
default n

config LV_GT911_INVERT_Y
bool
prompt "Invert Y coordinate value."
default y

endmenu

endmenu
Loading