backward compatibility with esp-idf release/v4.4

This commit is contained in:
hiruna 2023-06-03 23:08:29 +10:00
parent 50b212aa56
commit de52f295db
18 changed files with 216 additions and 18 deletions

View file

@ -23,6 +23,9 @@
#include "lvgl/lvgl.h" #include "lvgl/lvgl.h"
#endif #endif
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
#define SPI_HOST_MAX SOC_SPI_PERIPH_NUM
#endif
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View file

@ -7,7 +7,10 @@
#include "EVE.h" #include "EVE.h"
#include "EVE_commands.h" #include "EVE_commands.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
/* some pre-definded colors */ /* some pre-definded colors */
#define RED 0xff0000UL #define RED 0xff0000UL
#define ORANGE 0xffa500UL #define ORANGE 0xffa500UL
@ -263,7 +266,12 @@ void TFT_bitmap_display(void)
void FT81x_init(void) void FT81x_init(void)
{ {
#if EVE_USE_PDN #if EVE_USE_PDN
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(EVE_PDN);
#else
esp_rom_gpio_pad_select_gpio(EVE_PDN); esp_rom_gpio_pad_select_gpio(EVE_PDN);
#endif
#endif #endif
gpio_set_level(EVE_CS, 1); gpio_set_level(EVE_CS, 1);

View file

@ -12,7 +12,10 @@
#include "esp_log.h" #include "esp_log.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
@ -112,11 +115,19 @@ void GC9A01_init(void)
}; };
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(GC9A01_DC);
#else
esp_rom_gpio_pad_select_gpio(GC9A01_DC); esp_rom_gpio_pad_select_gpio(GC9A01_DC);
#endif
gpio_set_direction(GC9A01_DC, GPIO_MODE_OUTPUT); gpio_set_direction(GC9A01_DC, GPIO_MODE_OUTPUT);
#if GC9A01_USE_RST #if GC9A01_USE_RST
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(GC9A01_RST);
#else
esp_rom_gpio_pad_select_gpio(GC9A01_RST); esp_rom_gpio_pad_select_gpio(GC9A01_RST);
#endif
gpio_set_direction(GC9A01_RST, GPIO_MODE_OUTPUT); gpio_set_direction(GC9A01_RST, GPIO_MODE_OUTPUT);
//Reset the display //Reset the display

View file

@ -12,7 +12,10 @@
#include "driver/gpio.h" #include "driver/gpio.h"
#include "esp_log.h" #include "esp_log.h"
#include "soc/ledc_periph.h" // to invert LEDC output on IDF version < v4.3 #include "soc/ledc_periph.h" // to invert LEDC output on IDF version < v4.3
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
typedef struct { typedef struct {
bool pwm_control; // true: LEDC is used, false: GPIO is used bool pwm_control; // true: LEDC is used, false: GPIO is used
int index; // Either GPIO or LEDC channel int index; // Either GPIO or LEDC channel
@ -63,7 +66,11 @@ disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config)
{ {
// Configure GPIO for output // Configure GPIO for output
bckl_dev->index = config->gpio_num; bckl_dev->index = config->gpio_num;
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(config->gpio_num);
#else
esp_rom_gpio_pad_select_gpio(config->gpio_num); esp_rom_gpio_pad_select_gpio(config->gpio_num);
#endif
ESP_ERROR_CHECK(gpio_set_direction(config->gpio_num, GPIO_MODE_OUTPUT)); ESP_ERROR_CHECK(gpio_set_direction(config->gpio_num, GPIO_MODE_OUTPUT));
gpio_iomux_out(config->gpio_num, SIG_GPIO_OUT_IDX, config->output_invert); gpio_iomux_out(config->gpio_num, SIG_GPIO_OUT_IDX, config->output_invert);
} }
@ -102,7 +109,11 @@ void disp_backlight_delete(disp_backlight_h bckl)
if (bckl_dev->pwm_control) { if (bckl_dev->pwm_control) {
ledc_stop(LEDC_LOW_SPEED_MODE, bckl_dev->index, 0); ledc_stop(LEDC_LOW_SPEED_MODE, bckl_dev->index, 0);
} else { } else {
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(bckl_dev->index);
#else
esp_rom_gpio_pad_select_gpio(bckl_dev->index); esp_rom_gpio_pad_select_gpio(bckl_dev->index);
#endif
} }
free (bckl); free (bckl);
} }

View file

@ -21,7 +21,10 @@
#include <esp_log.h> #include <esp_log.h>
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
@ -160,11 +163,19 @@ static uint8_t displayType = HX8357D;
void hx8357_init(void) void hx8357_init(void)
{ {
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(HX8357_DC);
#else
esp_rom_gpio_pad_select_gpio(HX8357_DC); esp_rom_gpio_pad_select_gpio(HX8357_DC);
#endif
gpio_set_direction(HX8357_DC, GPIO_MODE_OUTPUT); gpio_set_direction(HX8357_DC, GPIO_MODE_OUTPUT);
#if HX8357_USE_RST #if HX8357_USE_RST
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(HX8357_RST);
#else
esp_rom_gpio_pad_select_gpio(HX8357_RST); esp_rom_gpio_pad_select_gpio(HX8357_RST);
#endif
gpio_set_direction(HX8357_RST, GPIO_MODE_OUTPUT); gpio_set_direction(HX8357_RST, GPIO_MODE_OUTPUT);
//Reset the display //Reset the display

View file

@ -33,6 +33,10 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include "esp_log.h" #include "esp_log.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
#include "il3820.h" #include "il3820.h"
@ -196,14 +200,26 @@ void il3820_init(void)
uint8_t tmp[3] = {0}; uint8_t tmp[3] = {0};
/* Initialize non-SPI GPIOs */ /* Initialize non-SPI GPIOs */
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(IL3820_DC_PIN);
#else
esp_rom_gpio_pad_select_gpio(IL3820_DC_PIN); esp_rom_gpio_pad_select_gpio(IL3820_DC_PIN);
#endif
gpio_set_direction(IL3820_DC_PIN, GPIO_MODE_OUTPUT); gpio_set_direction(IL3820_DC_PIN, GPIO_MODE_OUTPUT);
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(IL3820_BUSY_PIN);
#else
esp_rom_gpio_pad_select_gpio(IL3820_BUSY_PIN); esp_rom_gpio_pad_select_gpio(IL3820_BUSY_PIN);
#endif
gpio_set_direction(IL3820_BUSY_PIN, GPIO_MODE_INPUT); gpio_set_direction(IL3820_BUSY_PIN, GPIO_MODE_INPUT);
#if IL3820_USE_RST #if IL3820_USE_RST
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(IL3820_RST_PIN);
#else
esp_rom_gpio_pad_select_gpio(IL3820_RST_PIN); esp_rom_gpio_pad_select_gpio(IL3820_RST_PIN);
#endif
gpio_set_direction(IL3820_RST_PIN, GPIO_MODE_OUTPUT); gpio_set_direction(IL3820_RST_PIN, GPIO_MODE_OUTPUT);
/* Harware reset */ /* Harware reset */

View file

@ -13,6 +13,10 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "assert.h" #include "assert.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
/********************* /*********************
* DEFINES * DEFINES
@ -138,9 +142,17 @@ void ili9163c_init(void)
}; };
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ILI9163C_DC);
#else
esp_rom_gpio_pad_select_gpio(ILI9163C_DC); esp_rom_gpio_pad_select_gpio(ILI9163C_DC);
#endif
gpio_set_direction(ILI9163C_DC, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9163C_DC, GPIO_MODE_OUTPUT);
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ILI9163C_RST);
#else
esp_rom_gpio_pad_select_gpio(ILI9163C_RST); esp_rom_gpio_pad_select_gpio(ILI9163C_RST);
#endif
gpio_set_direction(ILI9163C_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9163C_RST, GPIO_MODE_OUTPUT);
//Reset the display //Reset the display

View file

@ -12,6 +12,10 @@
#include "esp_log.h" #include "esp_log.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
/********************* /*********************
* DEFINES * DEFINES
@ -81,11 +85,19 @@ void ili9341_init(void)
}; };
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ILI9341_DC);
#else
esp_rom_gpio_pad_select_gpio(ILI9341_DC); esp_rom_gpio_pad_select_gpio(ILI9341_DC);
#endif
gpio_set_direction(ILI9341_DC, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9341_DC, GPIO_MODE_OUTPUT);
#if ILI9341_USE_RST #if ILI9341_USE_RST
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ILI9341_RST);
#else
esp_rom_gpio_pad_select_gpio(ILI9341_RST); esp_rom_gpio_pad_select_gpio(ILI9341_RST);
#endif
gpio_set_direction(ILI9341_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9341_RST, GPIO_MODE_OUTPUT);
//Reset the display //Reset the display

View file

@ -13,7 +13,10 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
@ -74,11 +77,19 @@ void ili9481_init(void)
}; };
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ILI9481_DC);
#else
esp_rom_gpio_pad_select_gpio(ILI9481_DC); esp_rom_gpio_pad_select_gpio(ILI9481_DC);
#endif
gpio_set_direction(ILI9481_DC, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9481_DC, GPIO_MODE_OUTPUT);
#if ILI9481_USE_RST #if ILI9481_USE_RST
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ILI9481_RST);
#else
esp_rom_gpio_pad_select_gpio(ILI9481_RST); esp_rom_gpio_pad_select_gpio(ILI9481_RST);
#endif
gpio_set_direction(ILI9481_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9481_RST, GPIO_MODE_OUTPUT);
//Reset the display //Reset the display

View file

@ -12,6 +12,10 @@
#include "esp_log.h" #include "esp_log.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
/********************* /*********************
* DEFINES * DEFINES
@ -66,11 +70,19 @@ void ili9486_init(void)
}; };
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ILI9486_DC);
#else
esp_rom_gpio_pad_select_gpio(ILI9486_DC); esp_rom_gpio_pad_select_gpio(ILI9486_DC);
#endif
gpio_set_direction(ILI9486_DC, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9486_DC, GPIO_MODE_OUTPUT);
#if ILI9486_USE_RST #if ILI9486_USE_RST
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ILI9486_RST);
#else
esp_rom_gpio_pad_select_gpio(ILI9486_RST); esp_rom_gpio_pad_select_gpio(ILI9486_RST);
#endif
gpio_set_direction(ILI9486_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9486_RST, GPIO_MODE_OUTPUT);
//Reset the display //Reset the display

View file

@ -13,6 +13,10 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
/********************* /*********************
* DEFINES * DEFINES
@ -76,11 +80,19 @@ void ili9488_init(void)
}; };
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ILI9488_DC);
#else
esp_rom_gpio_pad_select_gpio(ILI9488_DC); esp_rom_gpio_pad_select_gpio(ILI9488_DC);
#endif
gpio_set_direction(ILI9488_DC, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9488_DC, GPIO_MODE_OUTPUT);
#if ILI9488_USE_RST #if ILI9488_USE_RST
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ILI9488_RST);
#else
esp_rom_gpio_pad_select_gpio(ILI9488_RST); esp_rom_gpio_pad_select_gpio(ILI9488_RST);
#endif
gpio_set_direction(ILI9488_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9488_RST, GPIO_MODE_OUTPUT);
//Reset the display //Reset the display

View file

@ -14,7 +14,10 @@
#include "freertos/task.h" #include "freertos/task.h"
#include "pcd8544.h" #include "pcd8544.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
#define TAG "lv_pcd8544" #define TAG "lv_pcd8544"
/********************** /**********************
@ -57,9 +60,17 @@ void pcd8544_init(void){
// TODO: orientation // TODO: orientation
// Initialize non-SPI GPIOs // Initialize non-SPI GPIOs
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(PCD8544_DC);
#else
esp_rom_gpio_pad_select_gpio(PCD8544_DC); esp_rom_gpio_pad_select_gpio(PCD8544_DC);
#endif
gpio_set_direction(PCD8544_DC, GPIO_MODE_OUTPUT); gpio_set_direction(PCD8544_DC, GPIO_MODE_OUTPUT);
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(PCD8544_RST);
#else
esp_rom_gpio_pad_select_gpio(PCD8544_RST); esp_rom_gpio_pad_select_gpio(PCD8544_RST);
#endif
gpio_set_direction(PCD8544_RST, GPIO_MODE_OUTPUT); gpio_set_direction(PCD8544_RST, GPIO_MODE_OUTPUT);
// Reset the display // Reset the display

View file

@ -12,6 +12,10 @@
#include "esp_log.h" #include "esp_log.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
/********************* /*********************
* DEFINES * DEFINES
@ -151,7 +155,11 @@ void ra8875_init(void)
// Initialize non-SPI GPIOs // Initialize non-SPI GPIOs
#if RA8875_USE_RST #if RA8875_USE_RST
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(RA8875_RST);
#else
esp_rom_gpio_pad_select_gpio(RA8875_RST); esp_rom_gpio_pad_select_gpio(RA8875_RST);
#endif
gpio_set_direction(RA8875_RST, GPIO_MODE_OUTPUT); gpio_set_direction(RA8875_RST, GPIO_MODE_OUTPUT);
// Reset the RA8875 // Reset the RA8875

View file

@ -12,6 +12,10 @@
#include "esp_log.h" #include "esp_log.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
/********************* /*********************
* DEFINES * DEFINES
@ -92,11 +96,19 @@ void sh1107_init(void)
}; };
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(SH1107_DC);
#else
esp_rom_gpio_pad_select_gpio(SH1107_DC); esp_rom_gpio_pad_select_gpio(SH1107_DC);
#endif
gpio_set_direction(SH1107_DC, GPIO_MODE_OUTPUT); gpio_set_direction(SH1107_DC, GPIO_MODE_OUTPUT);
#if SH1107_USE_RST #if SH1107_USE_RST
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(SH1107_RST);
#else
esp_rom_gpio_pad_select_gpio(SH1107_RST); esp_rom_gpio_pad_select_gpio(SH1107_RST);
#endif
gpio_set_direction(SH1107_RST, GPIO_MODE_OUTPUT); gpio_set_direction(SH1107_RST, GPIO_MODE_OUTPUT);
//Reset the display //Reset the display

View file

@ -12,6 +12,10 @@
#include "esp_log.h" #include "esp_log.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
#ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192 #ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192
#include "lvgl_i2c/i2c_manager.h" #include "lvgl_i2c/i2c_manager.h"
@ -98,11 +102,19 @@ void st7735s_init(void)
}; };
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ST7735S_DC);
#else
esp_rom_gpio_pad_select_gpio(ST7735S_DC); esp_rom_gpio_pad_select_gpio(ST7735S_DC);
#endif
gpio_set_direction(ST7735S_DC, GPIO_MODE_OUTPUT); gpio_set_direction(ST7735S_DC, GPIO_MODE_OUTPUT);
#if ST7735S_USE_RST #if ST7735S_USE_RST
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ST7735S_RST);
#else
esp_rom_gpio_pad_select_gpio(ST7735S_RST); esp_rom_gpio_pad_select_gpio(ST7735S_RST);
#endif
gpio_set_direction(ST7735S_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ST7735S_RST, GPIO_MODE_OUTPUT);
//Reset the display //Reset the display

View file

@ -14,6 +14,10 @@
#include "disp_spi.h" #include "disp_spi.h"
#include "driver/gpio.h" #include "driver/gpio.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
/********************* /*********************
* DEFINES * DEFINES
@ -86,11 +90,19 @@ void st7789_init(void)
}; };
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ST7789_DC);
#else
esp_rom_gpio_pad_select_gpio(ST7789_DC); esp_rom_gpio_pad_select_gpio(ST7789_DC);
#endif
gpio_set_direction(ST7789_DC, GPIO_MODE_OUTPUT); gpio_set_direction(ST7789_DC, GPIO_MODE_OUTPUT);
#if !defined(ST7789_SOFT_RST) #if !defined(ST7789_SOFT_RST)
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ST7789_RST);
#else
esp_rom_gpio_pad_select_gpio(ST7789_RST); esp_rom_gpio_pad_select_gpio(ST7789_RST);
#endif
gpio_set_direction(ST7789_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ST7789_RST, GPIO_MODE_OUTPUT);
#endif #endif

View file

@ -12,6 +12,10 @@
#include "esp_log.h" #include "esp_log.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
/********************* /*********************
* DEFINES * DEFINES
@ -82,11 +86,19 @@ void st7796s_init(void)
}; };
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ST7796S_DC);
#else
esp_rom_gpio_pad_select_gpio(ST7796S_DC); esp_rom_gpio_pad_select_gpio(ST7796S_DC);
#endif
gpio_set_direction(ST7796S_DC, GPIO_MODE_OUTPUT); gpio_set_direction(ST7796S_DC, GPIO_MODE_OUTPUT);
#if ST7796S_USE_RST #if ST7796S_USE_RST
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ST7796S_RST);
#else
esp_rom_gpio_pad_select_gpio(ST7796S_RST); esp_rom_gpio_pad_select_gpio(ST7796S_RST);
#endif
gpio_set_direction(ST7796S_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ST7796S_RST, GPIO_MODE_OUTPUT);
//Reset the display //Reset the display

View file

@ -9,6 +9,10 @@
#include "freertos/task.h" #include "freertos/task.h"
#include "driver/gpio.h" #include "driver/gpio.h"
#include <stddef.h> #include <stddef.h>
#include "esp_idf_version.h"
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0)
#include "rom/gpio.h"
#endif
#if CONFIG_LV_TOUCH_CONTROLLER_ADCRAW #if CONFIG_LV_TOUCH_CONTROLLER_ADCRAW
@ -139,10 +143,18 @@ static void setup_axis(gpio_num_t plus, gpio_num_t minus, gpio_num_t measure, gp
{ {
// Set GPIOs: // Set GPIOs:
// - Float "ignore" and "measure" // - Float "ignore" and "measure"
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(ignore);
#else
esp_rom_gpio_pad_select_gpio(ignore); esp_rom_gpio_pad_select_gpio(ignore);
#endif
gpio_set_direction(ignore, GPIO_MODE_DISABLE); gpio_set_direction(ignore, GPIO_MODE_DISABLE);
gpio_set_pull_mode(ignore, GPIO_FLOATING); gpio_set_pull_mode(ignore, GPIO_FLOATING);
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
gpio_pad_select_gpio(measure);
#else
esp_rom_gpio_pad_select_gpio(measure); esp_rom_gpio_pad_select_gpio(measure);
#endif
gpio_set_direction(measure, GPIO_MODE_DISABLE); gpio_set_direction(measure, GPIO_MODE_DISABLE);
gpio_set_pull_mode(measure, GPIO_FLOATING); gpio_set_pull_mode(measure, GPIO_FLOATING);
// - Set "plus" to 1, "minus" to 0 // - Set "plus" to 1, "minus" to 0