New kernel drivers and more (#560)

- Added kernel base drivers for: display, pointer (touch, mouse, etc.), keyboard, adc, power supply and backlight
- Implement new kernel driver modules: `st7789-module` and `gt911-module`
- Implement ESP32 ADC "oneshot" kernel driver
- Implement ESP32  backlight kernel driver with ledc API
- Implemented `battery-sense` driver that allows for voltage measurement and creates a power supply child device
- Updated github actions
- Updated flash scripts
- Fix for esp32 legacy driver conflict with ADC
- Created separate `lilygo-tdeck` and `lilygo-tdeck-plus` devices
- Created `lilygo-module` with LilyGO kernel drivers
- Fix for intermittent errors in build related to code generation of `devicetree.c`
- `lvgl-module` can now map kernel drivers onto LVGL devices
- Created `KernelDisplayApp` as a mirror of `HalDisplayApp` (formerly `DisplayApp`)
- Removed `struct` and `enum` prefix in a lot of kernel driver cpp source files
- `lilygo-tdeck` and `lilygo-tdeck-plus` are now fully relying on kernel drivers and don't use any of the old HAL
This commit is contained in:
Ken Van Hoeylandt
2026-07-12 00:29:12 +02:00
committed by GitHub
parent c4406b24ba
commit 50c0a14a93
149 changed files with 5274 additions and 1266 deletions
+6
View File
@@ -0,0 +1,6 @@
file(GLOB_RECURSE SOURCE_FILES source/*.c*)
idf_component_register(
SRCS ${SOURCE_FILES}
REQUIRES Tactility driver lilygo-module
)
@@ -0,0 +1,23 @@
general.vendor=LilyGO
general.name=T-Deck Plus
apps.launcherAppId=Launcher
hardware.target=ESP32S3
hardware.flashSize=16MB
hardware.spiRam=true
hardware.spiRamMode=OCT
hardware.spiRamSpeed=120M
hardware.tinyUsb=true
hardware.esptoolFlashFreq=120M
hardware.bluetooth=true
storage.userDataLocation=SD
display.size=2.8"
display.shape=rectangle
display.dpi=143
cdn.infoMessage=To put the device into bootloader mode: <br/>1. Press the trackball and then the reset button at the same time,<br/>2. Let go of the reset button, then the trackball.<br/><br/>When this website reports that flashing is finished, you likely have to press the reset button.
lvgl.colorDepth=16
@@ -0,0 +1,6 @@
dependencies:
- Platforms/platform-esp32
- Drivers/st7789-module
- Drivers/gt911-module
- Drivers/lilygo-module
dts: lilygo,tdeck-plus.dts
@@ -0,0 +1,150 @@
/dts-v1/;
#include <tactility/bindings/battery_sense.h>
#include <tactility/bindings/root.h>
#include <tactility/bindings/esp32_adc_oneshot.h>
#include <tactility/bindings/esp32_ble.h>
#include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_grove.h>
#include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_i2s.h>
#include <tactility/bindings/esp32_ledc_backlight.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_wifi_pinned.h>
#include <tactility/bindings/esp32_uart.h>
#include <bindings/gt911.h>
#include <bindings/st7789.h>
#include <lilygo/bindings/tdeck_keyboard.h>
#include <lilygo/bindings/tdeck_keyboard_backlight.h>
#include <lilygo/bindings/tdeck_trackball.h>
// Reference: https://wiki.lilygo.cc/products/t-deck-series/t-deck-plus/
/ {
compatible = "root";
model = "LilyGO T-Deck Plus";
adc0 {
compatible = "espressif,esp32-adc-oneshot";
unit-id = <ADC_UNIT_1>;
clk-src = <ADC_RTC_CLK_SRC_DEFAULT>;
channels = <ADC_CHANNEL_3 ADC_ATTEN_DB_12 ADC_BITWIDTH_DEFAULT>;
};
battery-sense {
compatible = "battery-sense";
io-channel = <&adc0 0>;
reference-voltage-mv = <3300>;
multiplier = <2110>;
};
wifi0 {
compatible = "espressif,esp32-wifi-pinned";
status = "disabled";
};
ble0 {
compatible = "espressif,esp32-ble";
status = "disabled";
};
gpio0 {
compatible = "espressif,esp32-gpio";
gpio-count = <49>;
};
trackball {
compatible = "lilygo,tdeck-trackball";
pin-right = <&gpio0 2 GPIO_FLAG_NONE>;
pin-up = <&gpio0 3 GPIO_FLAG_NONE>;
pin-left = <&gpio0 1 GPIO_FLAG_NONE>;
pin-down = <&gpio0 15 GPIO_FLAG_NONE>;
pin-click = <&gpio0 0 GPIO_FLAG_NONE>;
};
i2c_internal: i2c0 {
compatible = "espressif,esp32-i2c";
port = <I2C_NUM_0>;
clock-frequency = <100000>;
pin-sda = <&gpio0 18 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 8 GPIO_FLAG_NONE>;
touch {
compatible = "goodix,gt911";
reg = <0x5D>;
x-max = <240>;
y-max = <320>;
swap-xy;
mirror-x;
pin-interrupt = <&gpio0 16 GPIO_FLAG_NONE>;
};
keyboard {
compatible = "lilygo,tdeck-keyboard";
reg = <0x55>;
};
keyboard_backlight {
compatible = "lilygo,tdeck-keyboard-backlight";
reg = <0x55>;
};
};
i2s0 {
compatible = "espressif,esp32-i2s";
port = <I2S_NUM_0>;
pin-bclk = <&gpio0 7 GPIO_FLAG_NONE>;
pin-ws = <&gpio0 5 GPIO_FLAG_NONE>;
pin-data-out = <&gpio0 6 GPIO_FLAG_NONE>;
};
display_backlight {
compatible = "espressif,esp32-ledc-backlight";
// Off by default so dispaly power-on won't show the screen from before the last power loss.
// The display backlight is turned on during the boot process.
status = "disabled";
pin-backlight = <&gpio0 42 GPIO_FLAG_NONE>;
// 32 KHz and higher causes the screen to start dimming again above 80% brightness
// when moving the brightness slider rapidly from a lower setting to 100% (debug-traced, not a slider bug).
frequency-hz = <30000>;
};
spi0 {
compatible = "espressif,esp32-spi";
host = <SPI2_HOST>;
cs-gpios = <&gpio0 12 GPIO_FLAG_NONE>, // Display
<&gpio0 39 GPIO_FLAG_NONE>, // SD card
<&gpio0 9 GPIO_FLAG_NONE>; // Radio
pin-mosi = <&gpio0 41 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 38 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 40 GPIO_FLAG_NONE>;
display@0 {
compatible = "sitronix,st7789";
horizontal-resolution = <320>;
vertical-resolution = <240>;
swap-xy;
mirror-x;
invert-color;
pixel-clock-hz = <62500000>;
pin-dc = <&gpio0 11 GPIO_FLAG_NONE>;
backlight = <&display_backlight>;
};
// Must be started after display
sdcard@1 {
compatible = "espressif,esp32-sdspi";
status = "disabled";
frequency-khz = <20000>;
};
};
uart0 {
compatible = "espressif,esp32-uart";
port = <UART_NUM_1>;
pin-tx = <&gpio0 43 GPIO_FLAG_NONE>;
pin-rx = <&gpio0 44 GPIO_FLAG_NONE>;
};
};
@@ -0,0 +1,87 @@
#include <tactility/module.h>
#include <tactility/error.h>
#include <tactility/log.h>
#include <tactility/lvgl_module.h>
#include <Tactility/SystemEvents.h>
#include <Tactility/LogMessages.h>
#include <Tactility/hal/Configuration.h>
#include <Tactility/hal/gps/GpsConfiguration.h>
#include <Tactility/kernel/Kernel.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/service/gps/GpsService.h>
#include <Tactility/settings/TrackballSettings.h>
#include <lilygo/drivers/trackball.h>
#include <lilygo/drivers/tdeck_power_on.h>
#include <driver/gpio.h>
constexpr auto* TAG = "tdeck-plus";
// Legacy placeholder (required until legacy HAL is cleaned up everywhere)
extern const tt::hal::Configuration hardwareConfiguration = {};
extern "C" {
void subscribe_events() {
tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](tt::kernel::SystemEvent event) {
auto gps_service = tt::service::gps::findGpsService();
if (gps_service != nullptr) {
std::vector<tt::hal::gps::GpsConfiguration> gps_configurations;
gps_service->getGpsConfigurations(gps_configurations);
if (gps_configurations.empty()) {
if (gps_service->addGpsConfiguration(tt::hal::gps::GpsConfiguration {.uartName = "uart0", .baudRate = 38400, .model = tt::hal::gps::GpsModel::UBLOX10})) {
LOG_I(TAG, "Configured internal GPS");
} else {
LOG_E(TAG, "Failed to configure internal GPS");
}
}
}
});
// The kernel trackball device is already started by kernel_init(); this just registers it as an
// LVGL input device and applies persisted settings, both of which require LVGL to be up first.
tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](tt::kernel::SystemEvent event) {
auto tbSettings = tt::settings::trackball::loadOrGetDefault();
lvgl_lock();
if (trackball::init() != nullptr) {
trackball::setMode(tbSettings.trackballMode == tt::settings::trackball::TrackballMode::Pointer
? trackball::Mode::Pointer
: trackball::Mode::Encoder);
trackball::setEncoderSensitivity(tbSettings.encoderSensitivity);
trackball::setPointerSensitivity(tbSettings.pointerSensitivity);
trackball::setEnabled(tbSettings.trackballEnabled);
}
lvgl_unlock();
});
}
static error_t start() {
LOG_I(TAG, LOG_MESSAGE_POWER_ON_START);
if (!tdeck_power_on()) {
LOG_E(TAG, LOG_MESSAGE_POWER_ON_FAILED);
return ERROR_RESOURCE;
}
// Avoids crash when no SD card is inserted. It's unknown why, but likely is related to power draw.
tt::kernel::delayMillis(100);
subscribe_events();
return ERROR_NONE;
}
static error_t stop() {
return ERROR_NONE;
}
Module lilygo_tdeck_plus_module = {
.name = "lilygo-tdeck-plus",
.start = start,
.stop = stop,
.symbols = nullptr,
.internal = nullptr
};
}