Various improvements (#21)
* T-Deck stability and naming improvements * allow main task to clean itself up * remove unused includes * various lvgl improvements * added docs
This commit is contained in:
committed by
GitHub
parent
a2f0399c9f
commit
7a7b31e426
@@ -5,7 +5,7 @@
|
||||
|
||||
#define TAG "tdeck_bootstrap"
|
||||
|
||||
lv_disp_t* lilygo_tdeck_init_display();
|
||||
lv_disp_t* tdeck_init_display();
|
||||
|
||||
static bool tdeck_power_on() {
|
||||
ESP_LOGI(TAG, "power on");
|
||||
@@ -42,14 +42,22 @@ static bool init_i2c() {
|
||||
&& i2c_driver_install(TDECK_I2C_BUS_HANDLE, i2c_conf.mode, 0, 0, 0) == ESP_OK;
|
||||
}
|
||||
|
||||
bool lilygo_tdeck_bootstrap() {
|
||||
bool tdeck_bootstrap() {
|
||||
if (!tdeck_power_on()) {
|
||||
TT_LOG_E(TAG, "failed to power on device");
|
||||
}
|
||||
|
||||
// Give keyboard's ESP time to boot
|
||||
// It uses I2C and seems to interfere with the touch driver
|
||||
tt_delay_ms(500);
|
||||
/**
|
||||
* Without this delay, the touch driver randomly fails when the device is USB-powered:
|
||||
* > lcd_panel.io.i2c: panel_io_i2c_rx_buffer(135): i2c transaction failed
|
||||
* > GT911: touch_gt911_read_cfg(352): GT911 read error!
|
||||
* This might not be a problem with a lipo, but I haven't been able to test that.
|
||||
* I tried to solve it just like I did with the keyboard:
|
||||
* By reading from I2C until it succeeds and to then init the driver.
|
||||
* It doesn't work, because it never recovers from the error.
|
||||
*/
|
||||
TT_LOG_I(TAG, "waiting after power-on");
|
||||
tt_delay_ms(2000);
|
||||
|
||||
if (!init_i2c()) {
|
||||
TT_LOG_E(TAG, "failed to init I2C");
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#define LCD_BACKLIGHT_LEDC_DUTY (191)
|
||||
#define LCD_BACKLIGHT_LEDC_FREQUENCY (1000)
|
||||
|
||||
static void tdeck_backlight() {
|
||||
void tdeck_enable_backlight() {
|
||||
ESP_LOGI(TAG, "enable backlight");
|
||||
|
||||
ledc_timer_config_t ledc_timer = {
|
||||
@@ -58,7 +58,7 @@ static void tdeck_backlight() {
|
||||
ESP_ERROR_CHECK(ledc_set_duty(LCD_BACKLIGHT_LEDC_MODE, LCD_BACKLIGHT_LEDC_CHANNEL, LCD_BACKLIGHT_LEDC_DUTY));
|
||||
}
|
||||
|
||||
lv_disp_t* lilygo_tdeck_init_display() {
|
||||
lv_disp_t* tdeck_init_display() {
|
||||
ESP_LOGI(TAG, "creating display");
|
||||
|
||||
int max_transfer_size = LCD_HORIZONTAL_RESOLUTION * LCD_SPI_TRANSFER_HEIGHT * (LCD_BITS_PER_PIXEL / 8);
|
||||
@@ -170,7 +170,7 @@ lv_disp_t* lilygo_tdeck_init_display() {
|
||||
}
|
||||
};
|
||||
|
||||
tdeck_backlight();
|
||||
lv_disp_t* display = lvgl_port_add_disp(&disp_cfg);
|
||||
|
||||
return lvgl_port_add_disp(&disp_cfg);
|
||||
return display;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "lilygo_tdeck.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
bool lilygo_tdeck_bootstrap();
|
||||
bool lilygo_init_lvgl();
|
||||
bool tdeck_bootstrap();
|
||||
bool tdeck_init_lvgl();
|
||||
|
||||
const HardwareConfig lilygo_tdeck = {
|
||||
.bootstrap = &lilygo_tdeck_bootstrap,
|
||||
.init_lvgl = &lilygo_init_lvgl
|
||||
.bootstrap = &tdeck_bootstrap,
|
||||
.init_lvgl = &tdeck_init_lvgl
|
||||
};
|
||||
|
||||
@@ -6,14 +6,17 @@
|
||||
|
||||
#define TAG "tdeck_lvgl"
|
||||
|
||||
lv_disp_t* lilygo_tdeck_init_display();
|
||||
bool lilygo_tdeck_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle);
|
||||
lv_disp_t* tdeck_init_display();
|
||||
void tdeck_enable_backlight();
|
||||
bool tdeck_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle);
|
||||
|
||||
bool lilygo_init_lvgl() {
|
||||
bool tdeck_init_lvgl() {
|
||||
static lv_disp_t* display = NULL;
|
||||
static esp_lcd_panel_io_handle_t touch_io_handle;
|
||||
static esp_lcd_touch_handle_t touch_handle;
|
||||
|
||||
// Init LVGL Port library
|
||||
|
||||
const lvgl_port_cfg_t lvgl_cfg = {
|
||||
.task_priority = ThreadPriorityHigh,
|
||||
.task_stack = 8096,
|
||||
@@ -28,14 +31,16 @@ bool lilygo_init_lvgl() {
|
||||
}
|
||||
|
||||
// Add display
|
||||
display = lilygo_tdeck_init_display();
|
||||
|
||||
display = tdeck_init_display();
|
||||
if (display == NULL) {
|
||||
TT_LOG_E(TAG, "failed to add display");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add touch
|
||||
if (!lilygo_tdeck_init_touch(&touch_io_handle, &touch_handle)) {
|
||||
|
||||
if (!tdeck_init_touch(&touch_io_handle, &touch_handle)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -55,5 +60,7 @@ bool lilygo_init_lvgl() {
|
||||
|
||||
keyboard_alloc(display);
|
||||
|
||||
tdeck_enable_backlight();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
#include "config.h"
|
||||
#include "driver/i2c.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_lcd_touch_gt911.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_lcd_panel_io_interface.h"
|
||||
#include "log.h"
|
||||
#include <kernel.h>
|
||||
|
||||
#define TAG "tdeck_touch"
|
||||
|
||||
bool lilygo_tdeck_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle) {
|
||||
ESP_LOGI(TAG, "creating touch");
|
||||
bool tdeck_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle) {
|
||||
TT_LOG_I(TAG, "creating touch");
|
||||
|
||||
const esp_lcd_panel_io_i2c_config_t touch_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
|
||||
if (esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TDECK_I2C_BUS_HANDLE, &touch_io_config, io_handle) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "touch io i2c creation failed");
|
||||
TT_LOG_E(TAG, "touch io i2c creation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "create_touch");
|
||||
TT_LOG_I(TAG, "create_touch");
|
||||
esp_lcd_touch_config_t config = {
|
||||
.x_max = 240,
|
||||
.y_max = 320,
|
||||
@@ -36,7 +37,7 @@ bool lilygo_tdeck_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch
|
||||
};
|
||||
|
||||
if (esp_lcd_touch_new_i2c_gt911(*io_handle, &config, touch_handle) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "gt911 driver creation failed");
|
||||
TT_LOG_E(TAG, "gt911 driver creation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user