Device migrations, drivers and fixes (#571)

Device migrations:

- cyd-4848S040c
- guition-jc1060p470ciwy
- guition-jc2432w328c
- guition-jc3248w535c (known issue with display and touch, Shadowtrance will look into it)
- guition-jc8048w550c
- heltec-wifi-lora-32-v3
- lilygo-tdeck-max (excluding graphics)
- lilygo-tdisplay
- lilygo-tdisplay-s3
- lilygo-tdongle-s3
- lilygo-tlora-pager

Driver migrations:

- Implemented haptic driver interface in kernel
- AXS15231b
- BQ25896
- BQ27220
- CST328
- CST6xx
- DRV2605
- JD9165
- Custom LilyGO driver for T-Lora Pager
- SSD1306
- ST7701
- ST7735
- SY6970
- TCA8418

Fixes/improvements:

- Boot app: support for multiple power devices, improved UI
- lvgl_devices and related code: fixes for mapping
- Support for arrays in dts parser
This commit is contained in:
Ken Van Hoeylandt
2026-07-18 15:01:42 +02:00
committed by GitHub
parent 3b5a401594
commit d896657bf9
290 changed files with 9113 additions and 6719 deletions
+2 -3
View File
@@ -1,7 +1,6 @@
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
file(GLOB_RECURSE SOURCE_FILES source/*.c*)
idf_component_register(
SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Source"
REQUIRES Tactility EspLcdCompat esp_lcd_st7701 esp_lcd_panel_io_additions GT911 PwmBacklight driver vfs fatfs
REQUIRES TactilityKernel driver
)
@@ -1,21 +0,0 @@
#include "devices/St7701Display.h"
#include <Tactility/hal/Configuration.h>
#include <PwmBacklight.h>
using namespace tt::hal;
static bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_38, 1000);
}
static DeviceVector createDevices() {
return {
std::make_shared<St7701Display>(),
};
}
extern const Configuration hardwareConfiguration = {
.initBoot = initBoot,
.createDevices = createDevices
};
@@ -1,260 +0,0 @@
#include "St7701Display.h"
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <tactility/check.h>
#include <tactility/device.h>
#include <tactility/log.h>
#include <driver/gpio.h>
#include <esp_err.h>
#include <esp_lcd_panel_rgb.h>
#include <esp_lcd_panel_ops.h>
#include <esp_lcd_panel_io_additions.h>
#include <esp_lcd_st7701.h>
#include <esp_rom_gpio.h>
#include <soc/spi_periph.h>
#include <driver/spi_master.h>
constexpr auto* TAG = "St7701Display";
// GPIO47/48 are physically shared between this bit-banged 3-wire command bus
// and the SD card's real SPI2 bus (no alternate pins exist on this PCB).
// esp_lcd_new_panel_io_3wire_spi() reconfigures them as plain GPIO via
// gpio_config(), severing their SPI2 matrix routing. Reconnect them here once
// the vendor init sequence is done, so SD card reads/writes keep working.
// Safe only because nothing else calls into the ST7701 IO handle after boot.
static void reclaimSpiPinsForSdCard() {
esp_rom_gpio_connect_out_signal(GPIO_NUM_47, spi_periph_signal[SPI2_HOST].spid_out, false, false);
esp_rom_gpio_connect_out_signal(GPIO_NUM_48, spi_periph_signal[SPI2_HOST].spiclk_out, false, false);
gpio_set_direction(GPIO_NUM_47, GPIO_MODE_OUTPUT);
gpio_set_direction(GPIO_NUM_48, GPIO_MODE_OUTPUT);
}
static const st7701_lcd_init_cmd_t st7701_lcd_init_cmds[] = {
// {cmd, { data }, data_size, delay_ms}
{0xFF, (uint8_t[]) {0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0},
{0xC0, (uint8_t[]) {0x3B, 0x00}, 2, 0},
{0xC1, (uint8_t[]) {0x0D, 0x02}, 2, 0},
{0xC2, (uint8_t[]) {0x31, 0x05}, 2, 0},
{0xCD, (uint8_t[]) {0x00}, 1, 0}, //0x08
//Positive Voltage Gamma Control
{0xB0, (uint8_t[]) {0x00, 0x11, 0x18, 0x0E, 0x11, 0x06, 0x07, 0x08, 0x07, 0x22, 0x04, 0x12, 0x0F, 0xAA, 0x31, 0x18}, 16, 0},
//Negative Voltage Gamma Control
{0xB1, (uint8_t[]) {0x00, 0x11, 0x19, 0x0E, 0x12, 0x07, 0x08, 0x08, 0x08, 0x22, 0x04, 0x11, 0x11, 0xA9, 0x32, 0x18}, 16, 0},
//Page1
{0xFF, (uint8_t[]) {0x77, 0x01, 0x00, 0x00, 0x11}, 5, 0},
{0xB0, (uint8_t[]) {0x60}, 1, 0}, //Vop=4.7375v
{0xB1, (uint8_t[]) {0x32}, 1, 0}, //VCOM=32
{0xB2, (uint8_t[]) {0x07}, 1, 0}, //VGH=15v
{0xB3, (uint8_t[]) {0x80}, 1, 0},
{0xB5, (uint8_t[]) {0x49}, 1, 0}, //VGL=-10.17v
{0xB7, (uint8_t[]) {0x85}, 1, 0},
{0xB8, (uint8_t[]) {0x21}, 1, 0}, //AVDD=6.6 & AVCL=-4.6
{0xC1, (uint8_t[]) {0x78}, 1, 0},
{0xC2, (uint8_t[]) {0x78}, 1, 0},
{0xE0, (uint8_t[]) {0x00, 0x1B, 0x02}, 3, 0},
{0xE1, (uint8_t[]) {0x08, 0xA0, 0x00, 0x00, 0x07, 0xA0, 0x00, 0x00, 0x00, 0x44, 0x44}, 11, 0},
{0xE2, (uint8_t[]) {0x11, 0x11, 0x44, 0x44, 0xED, 0xA0, 0x00, 0x00, 0xEC, 0xA0, 0x00, 0x00}, 12, 0},
{0xE3, (uint8_t[]) {0x00, 0x00, 0x11, 0x11}, 4, 0},
{0xE4, (uint8_t[]) {0x44, 0x44}, 2, 0},
{0xE5, (uint8_t[]) {0x0A, 0xE9, 0xD8, 0xA0, 0x0C, 0xEB, 0xD8, 0xA0, 0x0E, 0xED, 0xD8, 0xA0, 0x10, 0xEF, 0xD8, 0xA0}, 16, 0},
{0xE6, (uint8_t[]) {0x00, 0x00, 0x11, 0x11}, 4, 0},
{0xE7, (uint8_t[]) {0x44, 0x44}, 2, 0},
{0xE8, (uint8_t[]) {0x09, 0xE8, 0xD8, 0xA0, 0x0B, 0xEA, 0xD8, 0xA0, 0x0D, 0xEC, 0xD8, 0xA0, 0x0F, 0xEE, 0xD8, 0xA0}, 16, 0},
{0xEB, (uint8_t[]) {0x02, 0x00, 0xE4, 0xE4, 0x88, 0x00, 0x40}, 7, 0},
{0xEC, (uint8_t[]) {0x3C, 0x00}, 2, 0},
{0xED, (uint8_t[]) {0xAB, 0x89, 0x76, 0x54, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x45, 0x67, 0x98, 0xBA}, 16, 0},
//VAP & VAN
{0xFF, (uint8_t[]) {0x77, 0x01, 0x00, 0x00, 0x13}, 5, 0},
{0xE5, (uint8_t[]) {0xE4}, 1, 0},
{0xFF, (uint8_t[]) {0x77, 0x01, 0x00, 0x00, 0x00}, 5, 0},
{0x3A, (uint8_t[]) {0x60}, 1, 10}, //0x70 RGB888, 0x60 RGB666, 0x50 RGB565
{0x11, (uint8_t[]) {0x00}, 0, 120}, //Sleep Out
{0x29, (uint8_t[]) {0x00}, 0, 0}, //Display On
};
bool St7701Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
spi_line_config_t line_config = {
.cs_io_type = IO_TYPE_GPIO,
.cs_gpio_num = GPIO_NUM_39,
.scl_io_type = IO_TYPE_GPIO,
.scl_gpio_num = GPIO_NUM_48,
.sda_io_type = IO_TYPE_GPIO,
.sda_gpio_num = GPIO_NUM_47,
.io_expander = nullptr,
};
esp_lcd_panel_io_3wire_spi_config_t panel_io_config = ST7701_PANEL_IO_3WIRE_SPI_CONFIG(line_config, 0);
return esp_lcd_new_panel_io_3wire_spi(&panel_io_config, &outHandle) == ESP_OK;
}
bool St7701Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle) {
const esp_lcd_rgb_panel_config_t rgb_config = {
.clk_src = LCD_CLK_SRC_DEFAULT,
.timings = {
.pclk_hz = 14000000,
.h_res = 480,
.v_res = 480,
.hsync_pulse_width = 10,
.hsync_back_porch = 10,
.hsync_front_porch = 20,
.vsync_pulse_width = 10,
.vsync_back_porch = 10,
.vsync_front_porch = 10,
.flags = {
.hsync_idle_low = false,
.vsync_idle_low = false,
.de_idle_high = false,
.pclk_active_neg = false,
.pclk_idle_high = false
}
},
.data_width = 16,
.bits_per_pixel = 16,
.num_fbs = 2,
.bounce_buffer_size_px = 480 * 10,
.sram_trans_align = 8,
.psram_trans_align = 64,
.hsync_gpio_num = GPIO_NUM_16,
.vsync_gpio_num = GPIO_NUM_17,
.de_gpio_num = GPIO_NUM_18,
.pclk_gpio_num = GPIO_NUM_21,
.disp_gpio_num = GPIO_NUM_NC,
.data_gpio_nums = {
GPIO_NUM_4, // B1
GPIO_NUM_5, // B2
GPIO_NUM_6, // B3
GPIO_NUM_7, // B4
GPIO_NUM_15, // B5
GPIO_NUM_8, // G1
GPIO_NUM_20, // G2
GPIO_NUM_3, // G3
GPIO_NUM_46, // G4
GPIO_NUM_9, // G5
GPIO_NUM_10, // G6
GPIO_NUM_11, // R1
GPIO_NUM_12, // R2
GPIO_NUM_13, // R3
GPIO_NUM_14, // R4
GPIO_NUM_0 // R5
},
.flags = {
.disp_active_low = false,
.refresh_on_demand = false,
.fb_in_psram = true,
.double_fb = true,
.no_fb = false,
.bb_invalidate_cache = true
}
};
st7701_vendor_config_t vendor_config = {
.init_cmds = st7701_lcd_init_cmds,
.init_cmds_size = sizeof(st7701_lcd_init_cmds) / sizeof(st7701_lcd_init_cmd_t),
.rgb_config = &rgb_config,
.flags = {
.use_mipi_interface = 0,
.mirror_by_cmd = 1,
.auto_del_panel_io = 0,
},
};
const esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = GPIO_NUM_NC,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
.bits_per_pixel = 16,
.flags = {
.reset_active_high = false,
},
.vendor_config = &vendor_config,
};
if (esp_lcd_new_panel_st7701(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
LOG_E(TAG, "Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOG_E(TAG, "Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOG_E(TAG, "Failed to init panel");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, false) != ESP_OK) {
LOG_E(TAG, "Failed to invert color");
return false;
}
esp_lcd_panel_set_gap(panelHandle, 0, 0);
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOG_E(TAG, "Failed to turn display on");
return false;
}
reclaimSpiPinsForSdCard();
return true;
}
lvgl_port_display_cfg_t St7701Display::getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) {
return {
.io_handle = ioHandle,
.panel_handle = panelHandle,
.control_handle = nullptr,
.buffer_size = (480 * 480),
.double_buffer = true,
.trans_size = 0,
.hres = 480,
.vres = 480,
.monochrome = false,
.rotation = {
.swap_xy = false,
.mirror_x = false,
.mirror_y = false,
},
.color_format = LV_COLOR_FORMAT_RGB565,
.flags = {
.buff_dma = false,
.buff_spiram = true,
.sw_rotate = false,
.swap_bytes = false,
.full_refresh = false,
.direct_mode = false
}
};
}
lvgl_port_display_rgb_cfg_t St7701Display::getLvglPortDisplayRgbConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) {
return {
.flags = {
.bb_mode = true,
.avoid_tearing = false
}
};
}
std::shared_ptr<tt::hal::touch::TouchDevice> St7701Display::getTouchDevice() {
if (touchDevice == nullptr) {
auto* i2c = device_find_by_name("i2c0");
check(i2c);
auto configuration = std::make_unique<Gt911Touch::Configuration>(
i2c,
480,
480
);
touchDevice = std::make_shared<Gt911Touch>(std::move(configuration));
}
return touchDevice;
}
void St7701Display::setBacklightDuty(uint8_t backlightDuty) {
driver::pwmbacklight::setBacklightDuty(backlightDuty);
}
@@ -1,36 +0,0 @@
#pragma once
#include <EspLcdDisplay.h>
#include <lvgl.h>
class St7701Display final : public EspLcdDisplay {
std::shared_ptr<tt::hal::touch::TouchDevice> touchDevice;
bool createIoHandle(esp_lcd_panel_io_handle_t& outHandle) override;
bool createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle) override;
lvgl_port_display_cfg_t getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) override;
bool isRgbPanel() const override { return true; }
lvgl_port_display_rgb_cfg_t getLvglPortDisplayRgbConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) override;
public:
St7701Display() : EspLcdDisplay() {}
std::string getName() const override { return "ST7701S"; }
std::string getDescription() const override { return "ST7701S RGB display"; }
std::shared_ptr<tt::hal::touch::TouchDevice> getTouchDevice() override;
void setBacklightDuty(uint8_t backlightDuty) override;
bool supportsBacklightDuty() const override { return true; }
// TODO: Find out why it crashes
bool supportsDisplayDriver() const override { return false; }
};
+137 -1
View File
@@ -5,8 +5,12 @@
#include <tactility/bindings/esp32_wifi_pinned.h>
#include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_pwm_ledc.h>
#include <tactility/bindings/pwm_backlight.h>
#include <bindings/st7701.h>
#include <bindings/gt911.h>
/ {
compatible = "root";
@@ -33,5 +37,137 @@
clock-frequency = <400000>;
pin-sda = <&gpio0 19 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 45 GPIO_FLAG_NONE>;
touch0 {
// No reset/interrupt pin wired up here, matching the original deprecated-HAL
// config (Gt911Touch::Configuration was constructed with no reset/interrupt pin
// arguments on this board).
compatible = "goodix,gt911";
reg = <0x5D>;
x-max = <480>;
y-max = <480>;
};
};
display_backlight_pwm {
compatible = "espressif,esp32-pwm-ledc";
pin = <&gpio0 38 GPIO_FLAG_NONE>;
period-ns = <1000000>;
ledc-timer = <0>;
ledc-channel = <0>;
};
display_backlight {
compatible = "pwm-backlight";
pwm = <&display_backlight_pwm>;
};
display0 {
compatible = "sitronix,st7701";
horizontal-resolution = <480>;
vertical-resolution = <480>;
pixel-clock-hz = <14000000>;
hsync-pulse-width = <10>;
hsync-back-porch = <10>;
hsync-front-porch = <20>;
vsync-pulse-width = <10>;
vsync-back-porch = <10>;
vsync-front-porch = <10>;
num-fbs = <2>;
double-fb;
bounce-buffer-size-px = <4800>;
bb-invalidate-cache;
pin-hsync = <&gpio0 16 GPIO_FLAG_NONE>;
pin-vsync = <&gpio0 17 GPIO_FLAG_NONE>;
pin-de = <&gpio0 18 GPIO_FLAG_NONE>;
pin-pclk = <&gpio0 21 GPIO_FLAG_NONE>;
pin-data0 = <&gpio0 4 GPIO_FLAG_NONE>; // B1
pin-data1 = <&gpio0 5 GPIO_FLAG_NONE>; // B2
pin-data2 = <&gpio0 6 GPIO_FLAG_NONE>; // B3
pin-data3 = <&gpio0 7 GPIO_FLAG_NONE>; // B4
pin-data4 = <&gpio0 15 GPIO_FLAG_NONE>; // B5
pin-data5 = <&gpio0 8 GPIO_FLAG_NONE>; // G1
pin-data6 = <&gpio0 20 GPIO_FLAG_NONE>; // G2
pin-data7 = <&gpio0 3 GPIO_FLAG_NONE>; // G3
pin-data8 = <&gpio0 46 GPIO_FLAG_NONE>; // G4
pin-data9 = <&gpio0 9 GPIO_FLAG_NONE>; // G5
pin-data10 = <&gpio0 10 GPIO_FLAG_NONE>; // G6
pin-data11 = <&gpio0 11 GPIO_FLAG_NONE>; // R1
pin-data12 = <&gpio0 12 GPIO_FLAG_NONE>; // R2
pin-data13 = <&gpio0 13 GPIO_FLAG_NONE>; // R3
pin-data14 = <&gpio0 14 GPIO_FLAG_NONE>; // R4
pin-data15 = <&gpio0 0 GPIO_FLAG_NONE>; // R5
// 3-wire bit-banged command bus. GPIO47/48 are physically shared with this board's SD
// card SPI2 bus (MOSI/SCLK) - no alternate pins exist on this PCB. No SD card device is
// declared in this devicetree yet (CS/MISO pins are unverified), but if one is added on
// SPI2_HOST later, declare it *after* this node: starting that SPI bus unconditionally
// reprograms the GPIO matrix for its MOSI/SCLK pins (see esp32_spi.cpp's start()),
// which reclaims them from this display's bit-banged use without any extra code.
pin-cs = <&gpio0 39 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 48 GPIO_FLAG_NONE>;
pin-sda = <&gpio0 47 GPIO_FLAG_NONE>;
mirror-by-cmd;
init-sequence = [
// Vendor bring-up sequence for this panel. Framing is
// [cmd, data-len, delay-ms, data-len bytes of data...] - see st7701-module's
// init-sequence binding property for the encoding.
0xFF 5 0 0x77 0x01 0x00 0x00 0x10
0xC0 2 0 0x3B 0x00
0xC1 2 0 0x0D 0x02
0xC2 2 0 0x31 0x05
0xCD 1 0 0x00
// Positive Voltage Gamma Control
0xB0 16 0 0x00 0x11 0x18 0x0E 0x11 0x06 0x07 0x08 0x07 0x22 0x04 0x12 0x0F 0xAA 0x31 0x18
// Negative Voltage Gamma Control
0xB1 16 0 0x00 0x11 0x19 0x0E 0x12 0x07 0x08 0x08 0x08 0x22 0x04 0x11 0x11 0xA9 0x32 0x18
// Page1
0xFF 5 0 0x77 0x01 0x00 0x00 0x11
0xB0 1 0 0x60 // Vop=4.7375v
0xB1 1 0 0x32 // VCOM=32
0xB2 1 0 0x07 // VGH=15v
0xB3 1 0 0x80
0xB5 1 0 0x49 // VGL=-10.17v
0xB7 1 0 0x85
0xB8 1 0 0x21 // AVDD=6.6 & AVCL=-4.6
0xC1 1 0 0x78
0xC2 1 0 0x78
0xE0 3 0 0x00 0x1B 0x02
0xE1 11 0 0x08 0xA0 0x00 0x00 0x07 0xA0 0x00 0x00 0x00 0x44 0x44
0xE2 12 0 0x11 0x11 0x44 0x44 0xED 0xA0 0x00 0x00 0xEC 0xA0 0x00 0x00
0xE3 4 0 0x00 0x00 0x11 0x11
0xE4 2 0 0x44 0x44
0xE5 16 0 0x0A 0xE9 0xD8 0xA0 0x0C 0xEB 0xD8 0xA0 0x0E 0xED 0xD8 0xA0 0x10 0xEF 0xD8 0xA0
0xE6 4 0 0x00 0x00 0x11 0x11
0xE7 2 0 0x44 0x44
0xE8 16 0 0x09 0xE8 0xD8 0xA0 0x0B 0xEA 0xD8 0xA0 0x0D 0xEC 0xD8 0xA0 0x0F 0xEE 0xD8 0xA0
0xEB 7 0 0x02 0x00 0xE4 0xE4 0x88 0x00 0x40
0xEC 2 0 0x3C 0x00
0xED 16 0 0xAB 0x89 0x76 0x54 0x02 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x20 0x45 0x67 0x98 0xBA
// VAP & VAN
0xFF 5 0 0x77 0x01 0x00 0x00 0x13
0xE5 1 0 0xE4
0xFF 5 0 0x77 0x01 0x00 0x00 0x00
0x3A 1 10 0x60 // 0x70 RGB888, 0x60 RGB666, 0x50 RGB565
0x11 0 120 // Sleep Out
0x29 0 0 // Display On
];
backlight = <&display_backlight>;
};
spi0 {
compatible = "espressif,esp32-spi";
host = <SPI2_HOST>;
cs-gpios = <&gpio0 42 GPIO_FLAG_NONE>;
pin-mosi = <&gpio0 47 GPIO_FLAG_NONE>;
pin-miso = <&gpio0 41 GPIO_FLAG_NONE>;
pin-sclk = <&gpio0 48 GPIO_FLAG_NONE>;
sdcard@0 {
compatible = "espressif,esp32-sdspi";
frequency-khz = <20000>;
};
};
};
+2
View File
@@ -10,6 +10,8 @@ hardware.spiRamMode=OCT
hardware.spiRamSpeed=80M
hardware.bluetooth=true
dependencies.useDeprecatedHal=false
storage.userDataLocation=SD
display.size=4"
+2
View File
@@ -1,3 +1,5 @@
dependencies:
- Platforms/platform-esp32
- Drivers/st7701-module
- Drivers/gt911-module
dts: cyd,4848s040c.dts
@@ -3,16 +3,14 @@
extern "C" {
static error_t start() {
// Empty for now
return ERROR_NONE;
}
static error_t stop() {
// Empty for now
return ERROR_NONE;
}
Module cyd_4848s040c_module = {
struct Module cyd_4848s040c_module = {
.name = "cyd-4848s040c",
.start = start,
.stop = stop,