various improvements

stopped using private header folder (for ease of development - for now)
implemented basic gui service (WIP)
added sdkconfig.defaults to the repo
updated docs
This commit is contained in:
Ken Van Hoeylandt
2023-12-27 13:57:20 +01:00
parent aa24b84eb6
commit f4088f5762
22 changed files with 202 additions and 50 deletions
@@ -14,17 +14,17 @@ static const char* TAG = "2432s024_ili9341";
static SemaphoreHandle_t refresh_finish = NULL;
#define SELECTED_SPI_HOST SPI2_HOST
#define PIN_SCLK GPIO_NUM_14
#define PIN_MOSI GPIO_NUM_13
#define PIN_CS GPIO_NUM_15
#define PIN_DC GPIO_NUM_2
#define PIN_BACKLIGHT GPIO_NUM_27
#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 HORIZONTAL_RESOLUTION 240
#define VERTICAL_RESOLUTION 320
#define BITS_PER_PIXEL 16
#define DRAW_BUFFER_HEIGHT 80
#define LCD_HORIZONTAL_RESOLUTION 240
#define LCD_VERTICAL_RESOLUTION 320
#define LCD_BITS_PER_PIXEL 16
#define LCD_DRAW_BUFFER_HEIGHT 80
IRAM_ATTR static bool prv_on_color_trans_done(esp_lcd_panel_io_handle_t io_handle, esp_lcd_panel_io_event_data_t* edata, void* user_ctx) {
BaseType_t need_yield = pdFALSE;
@@ -36,7 +36,7 @@ static bool prv_create_display(nb_display_t* display) {
ESP_LOGI(TAG, "creating display");
gpio_config_t io_conf = {
.pin_bit_mask = BIT64(PIN_BACKLIGHT),
.pin_bit_mask = BIT64(LCD_PIN_BACKLIGHT),
.mode = GPIO_MODE_OUTPUT,
.pull_up_en = GPIO_PULLUP_DISABLE,
.pull_down_en = GPIO_PULLDOWN_DISABLE,
@@ -44,25 +44,26 @@ static bool prv_create_display(nb_display_t* display) {
};
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(
PIN_SCLK,
PIN_MOSI,
HORIZONTAL_RESOLUTION * DRAW_BUFFER_HEIGHT * (BITS_PER_PIXEL / 8)
LCD_PIN_SCLK,
LCD_PIN_MOSI,
draw_buffer_size
);
if (spi_bus_initialize(SELECTED_SPI_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
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(
PIN_CS,
PIN_DC,
LCD_PIN_CS,
LCD_PIN_DC,
prv_on_color_trans_done,
NULL
);
if (esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)SELECTED_SPI_HOST, &panel_io_config, &display->io_handle) != ESP_OK) {
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;
}
@@ -71,8 +72,9 @@ static bool prv_create_display(nb_display_t* display) {
const esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = GPIO_NUM_NC,
.rgb_endian = LCD_RGB_ENDIAN_RGB,
.bits_per_pixel = BITS_PER_PIXEL,
.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;
@@ -91,6 +93,14 @@ static bool prv_create_display(nb_display_t* display) {
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;
}
@@ -99,17 +109,15 @@ static bool prv_create_display(nb_display_t* display) {
return false;
}
if (gpio_set_level(PIN_BACKLIGHT, 1) != ESP_OK) {
if (gpio_set_level(LCD_PIN_BACKLIGHT, 1) != ESP_OK) {
ESP_LOGD(TAG, "failed to turn backlight on");
return false;
}
display->horizontal_resolution = HORIZONTAL_RESOLUTION;
display->vertical_resolution = VERTICAL_RESOLUTION;
display->draw_buffer_height = DRAW_BUFFER_HEIGHT;
display->bits_per_pixel = BITS_PER_PIXEL;
display->mirror_x = true;
display->mirror_y = 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;
return true;
}