Added Lilygo T-Deck support & more (#4)
* added lilygo t-deck restructured boards implemented HardwareConfig implemented lilygo t-deck lcd and touch drivers added sdkconfig defaults for supported boards * cleanup * added esp32s3 job * build job names updated * wip * partial revert * update readme and build.yml * updated build.yaml with fix for quotes * use esp-idf 5.1.2 * improvements and fixes * fixes for display code * made config const * various improvements
This commit is contained in:
committed by
GitHub
parent
eed990217f
commit
8336316133
@@ -0,0 +1,5 @@
|
||||
idf_component_register(
|
||||
SRC_DIRS "."
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES nanobake esp_lcd_touch_cst816s esp_lcd_ili9341
|
||||
)
|
||||
@@ -0,0 +1,124 @@
|
||||
#include "nanobake.h"
|
||||
#include "esp_lcd_ili9341.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/spi_master.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#define TAG "2432s024_ili9341"
|
||||
|
||||
static SemaphoreHandle_t refresh_finish = NULL;
|
||||
|
||||
#define LCD_SPI_HOST SPI2_HOST
|
||||
#define LCD_PIN_SCLK GPIO_NUM_14
|
||||
#define LCD_PIN_MOSI GPIO_NUM_13
|
||||
#define LCD_PIN_CS GPIO_NUM_15
|
||||
#define LCD_PIN_DC GPIO_NUM_2
|
||||
#define LCD_PIN_BACKLIGHT GPIO_NUM_27
|
||||
|
||||
#define LCD_HORIZONTAL_RESOLUTION 240
|
||||
#define LCD_VERTICAL_RESOLUTION 320
|
||||
#define LCD_BITS_PER_PIXEL 16
|
||||
#define LCD_DRAW_BUFFER_HEIGHT (LCD_VERTICAL_RESOLUTION / 10)
|
||||
|
||||
static bool create_display_device(DisplayDevice* display) {
|
||||
ESP_LOGI(TAG, "creating display");
|
||||
|
||||
gpio_config_t io_conf = {
|
||||
.pin_bit_mask = BIT64(LCD_PIN_BACKLIGHT),
|
||||
.mode = GPIO_MODE_OUTPUT,
|
||||
.pull_up_en = GPIO_PULLUP_DISABLE,
|
||||
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
||||
.intr_type = GPIO_INTR_DISABLE,
|
||||
};
|
||||
gpio_config(&io_conf);
|
||||
|
||||
size_t draw_buffer_size = LCD_HORIZONTAL_RESOLUTION * LCD_DRAW_BUFFER_HEIGHT * (LCD_BITS_PER_PIXEL / 8);
|
||||
const spi_bus_config_t bus_config = ILI9341_PANEL_BUS_SPI_CONFIG(
|
||||
LCD_PIN_SCLK,
|
||||
LCD_PIN_MOSI,
|
||||
draw_buffer_size
|
||||
);
|
||||
|
||||
if (spi_bus_initialize(LCD_SPI_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
|
||||
ESP_LOGD(TAG, "spi bus init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
const esp_lcd_panel_io_spi_config_t panel_io_config = ILI9341_PANEL_IO_SPI_CONFIG(
|
||||
LCD_PIN_CS,
|
||||
LCD_PIN_DC,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)LCD_SPI_HOST, &panel_io_config, &display->io_handle) != ESP_OK) {
|
||||
ESP_LOGD(TAG, "failed to create panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "install driver");
|
||||
const esp_lcd_panel_dev_config_t panel_config = {
|
||||
.reset_gpio_num = GPIO_NUM_NC,
|
||||
.rgb_endian = LCD_RGB_ENDIAN_RGB,
|
||||
.bits_per_pixel = LCD_BITS_PER_PIXEL,
|
||||
};
|
||||
|
||||
if (esp_lcd_new_panel_ili9341(display->io_handle, &panel_config, &display->display_handle) != ESP_OK) {
|
||||
ESP_LOGD(TAG, "failed to create ili9341");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (esp_lcd_panel_reset(display->display_handle) != ESP_OK) {
|
||||
ESP_LOGD(TAG, "failed to reset panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_init(display->display_handle) != ESP_OK) {
|
||||
ESP_LOGD(TAG, "failed to init panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_mirror(display->display_handle, true, false) != ESP_OK) {
|
||||
ESP_LOGD(TAG, "failed to set panel to mirror");
|
||||
display->mirror_x = true;
|
||||
display->mirror_y = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_swap_xy(display->display_handle, false) != ESP_OK) {
|
||||
ESP_LOGD(TAG, "failed to set panel xy swap");
|
||||
display->swap_xy = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_disp_on_off(display->display_handle, true) != ESP_OK) {
|
||||
ESP_LOGD(TAG, "failed to turn display on");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gpio_set_level(LCD_PIN_BACKLIGHT, 1) != ESP_OK) {
|
||||
ESP_LOGD(TAG, "failed to turn backlight on");
|
||||
return false;
|
||||
}
|
||||
|
||||
display->horizontal_resolution = LCD_HORIZONTAL_RESOLUTION;
|
||||
display->vertical_resolution = LCD_VERTICAL_RESOLUTION;
|
||||
display->draw_buffer_height = LCD_DRAW_BUFFER_HEIGHT;
|
||||
display->bits_per_pixel = LCD_BITS_PER_PIXEL;
|
||||
display->monochrome = false;
|
||||
display->double_buffering = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DisplayDriver board_2432s024_create_display_driver() {
|
||||
return (DisplayDriver) {
|
||||
.name = "ili9341_2432s024",
|
||||
.create_display_device = &create_display_device
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
#include "nanobake.h"
|
||||
#include "esp_lcd_touch_cst816s.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_err.h"
|
||||
#include "driver/i2c.h"
|
||||
|
||||
#define TOUCH_I2C_PORT 0
|
||||
|
||||
#define TAG "2432s024_cst816"
|
||||
|
||||
static bool create_touch_device(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle) {
|
||||
ESP_LOGI(TAG, "creating touch");
|
||||
|
||||
const i2c_config_t i2c_conf = {
|
||||
.mode = I2C_MODE_MASTER,
|
||||
.sda_io_num = GPIO_NUM_33,
|
||||
.sda_pullup_en = GPIO_PULLUP_DISABLE,
|
||||
.scl_io_num = GPIO_NUM_32,
|
||||
.scl_pullup_en = GPIO_PULLUP_DISABLE,
|
||||
.master.clk_speed = 400000
|
||||
};
|
||||
|
||||
if (i2c_param_config(TOUCH_I2C_PORT, &i2c_conf) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "i2c config failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (i2c_driver_install(TOUCH_I2C_PORT, i2c_conf.mode, 0, 0, 0) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "i2c driver install failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
const esp_lcd_panel_io_i2c_config_t touch_io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG();
|
||||
|
||||
if (esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TOUCH_I2C_PORT, &touch_io_config, io_handle) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "touch I2C IO init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "create_touch");
|
||||
esp_lcd_touch_config_t config = {
|
||||
.x_max = 240,
|
||||
.y_max = 320,
|
||||
.rst_gpio_num = GPIO_NUM_25,
|
||||
.int_gpio_num = GPIO_NUM_21,
|
||||
.levels = {
|
||||
.reset = 0,
|
||||
.interrupt = 0,
|
||||
},
|
||||
.flags = {
|
||||
.swap_xy = 0,
|
||||
.mirror_x = 0,
|
||||
.mirror_y = 0,
|
||||
},
|
||||
.process_coordinates = NULL,
|
||||
.interrupt_callback = NULL,
|
||||
.user_data = NULL
|
||||
};
|
||||
|
||||
if (esp_lcd_touch_new_i2c_cst816s(*io_handle, &config, touch_handle) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "esp_lcd_touch_new_i2c_cst816s failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TouchDriver board_2432s024_create_touch_driver() {
|
||||
return (TouchDriver) {
|
||||
.name = "cst816s_2432s024",
|
||||
.create_touch_device = &create_touch_device
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "yellow_board.h"
|
||||
|
||||
DisplayDriver board_2432s024_create_display_driver();
|
||||
TouchDriver board_2432s024_create_touch_driver();
|
||||
|
||||
const HardwareConfig yellow_board_24inch_cap = {
|
||||
.bootstrap = NULL,
|
||||
.display_driver = &board_2432s024_create_display_driver,
|
||||
.touch_driver = &board_2432s024_create_touch_driver
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "nanobake.h"
|
||||
|
||||
// Capacitive touch version of the 2.4" yellow board
|
||||
extern const HardwareConfig yellow_board_24inch_cap;
|
||||
Reference in New Issue
Block a user