LilyGo T-Deck keyboard support & display driver improvements (#19)
* LilyGo T-Deck keyboard support * reverse logic * docs and readability * cleanup * optimize driver buffer * cleanup
This commit is contained in:
committed by
GitHub
parent
14eb43211d
commit
ccbe6b7ab8
@@ -1,29 +1,61 @@
|
||||
#include "esp_log.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "config.h"
|
||||
#include "keyboard.h"
|
||||
#include "kernel.h"
|
||||
#include "esp_lvgl_port.h"
|
||||
#include "log.h"
|
||||
|
||||
#define TAG "lilygo_tdeck_bootstrap"
|
||||
#define TDECK_PERI_POWERON GPIO_NUM_10
|
||||
#define TAG "tdeck_bootstrap"
|
||||
|
||||
lv_disp_t* lilygo_tdeck_init_display();
|
||||
|
||||
static void tdeck_power_on() {
|
||||
static bool tdeck_power_on() {
|
||||
ESP_LOGI(TAG, "power on");
|
||||
gpio_config_t device_power_signal_config = {
|
||||
.pin_bit_mask = BIT64(TDECK_PERI_POWERON),
|
||||
.pin_bit_mask = BIT64(TDECK_POWERON_GPIO),
|
||||
.mode = GPIO_MODE_OUTPUT,
|
||||
.pull_up_en = GPIO_PULLUP_DISABLE,
|
||||
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
||||
.intr_type = GPIO_INTR_DISABLE,
|
||||
};
|
||||
gpio_config(&device_power_signal_config);
|
||||
gpio_set_level(TDECK_PERI_POWERON, 1);
|
||||
|
||||
if (gpio_config(&device_power_signal_config) != ESP_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gpio_set_level(TDECK_POWERON_GPIO, 1) != ESP_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void lilygo_tdeck_bootstrap() {
|
||||
tdeck_power_on();
|
||||
static bool init_i2c() {
|
||||
const i2c_config_t i2c_conf = {
|
||||
.mode = I2C_MODE_MASTER,
|
||||
.sda_io_num = GPIO_NUM_18,
|
||||
.sda_pullup_en = GPIO_PULLUP_DISABLE,
|
||||
.scl_io_num = GPIO_NUM_8,
|
||||
.scl_pullup_en = GPIO_PULLUP_DISABLE,
|
||||
.master.clk_speed = 400000
|
||||
};
|
||||
|
||||
return i2c_param_config(TDECK_I2C_BUS_HANDLE, &i2c_conf) == ESP_OK
|
||||
&& i2c_driver_install(TDECK_I2C_BUS_HANDLE, i2c_conf.mode, 0, 0, 0) == ESP_OK;
|
||||
}
|
||||
|
||||
bool lilygo_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);
|
||||
|
||||
if (!init_i2c()) {
|
||||
TT_LOG_E(TAG, "failed to init I2C");
|
||||
}
|
||||
|
||||
keyboard_wait_for_response();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user