Migrate devices, create drivers, other improvements & fixes (#574)

Migrated devices to kernel drivers:

- guition-jc3248w535c
- m5stack-core2
- m5stack-cores3
- m5stack-papers3

New drivers:

- axp192-module
- axp2101-module

Fixes:

- Fix SD card LDO for P4 devices
- Updated PowerOff app to work with kernel displays
- Fix for `lvgl_try_lock()` timing
- Fix for touch events with slow updating displays

Improvements:

- `GuiService` now keeps trying to lock to prevent silent failures caused by drivers.
- `GuiService` now uses lvgl-module calls for locking/unlocking
- display driver now has capability `DISPLAY_CAPABILITY_SLOW_REFRESH`
This commit is contained in:
Ken Van Hoeylandt
2026-07-19 00:39:26 +02:00
committed by GitHub
parent 5f54f7ca3d
commit f9453d8956
119 changed files with 3327 additions and 3994 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 esp_lvgl_port esp_lcd AXP192 ILI934x FT6x36 driver vfs fatfs
REQUIRES TactilityKernel axp192-module
)
@@ -1,22 +0,0 @@
#include "devices/Display.h"
#include "devices/Power.h"
#include <Tactility/hal/Configuration.h>
using namespace tt::hal;
static bool initBoot() {
return initAxp();
}
static DeviceVector createDevices() {
return {
getAxp192(),
createDisplay()
};
}
extern const Configuration hardwareConfiguration = {
.initBoot = initBoot,
.createDevices = createDevices
};
@@ -1,48 +0,0 @@
#include "Display.h"
#include <Ft6x36Touch.h>
#include <Ili934xDisplay.h>
std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto configuration = std::make_unique<Ft6x36Touch::Configuration>(
I2C_NUM_0,
LCD_HORIZONTAL_RESOLUTION,
LCD_VERTICAL_RESOLUTION,
false,
false,
false,
GPIO_NUM_NC,
GPIO_NUM_39
);
return std::make_shared<Ft6x36Touch>(std::move(configuration));
}
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
Ili934xDisplay::Configuration panel_configuration = {
.horizontalResolution = LCD_HORIZONTAL_RESOLUTION,
.verticalResolution = LCD_VERTICAL_RESOLUTION,
.gapX = 0,
.gapY = 0,
.swapXY = false,
.mirrorX = false,
.mirrorY = false,
.invertColor = true,
.swapBytes = true,
.bufferSize = LCD_BUFFER_SIZE,
.touch = createTouch(),
.backlightDutyFunction = nullptr,
.resetPin = GPIO_NUM_NC,
.rgbElementOrder = LCD_RGB_ELEMENT_ORDER_BGR
};
auto spi_configuration = std::make_shared<Ili934xDisplay::SpiConfiguration>(Ili934xDisplay::SpiConfiguration {
.spiHostDevice = LCD_SPI_HOST,
.csPin = LCD_PIN_CS,
.dcPin = LCD_PIN_DC,
.pixelClockFrequency = 40'000'000,
.transactionQueueDepth = 10
});
return std::make_shared<Ili934xDisplay>(panel_configuration, spi_configuration, true);
}
@@ -1,16 +0,0 @@
#pragma once
#include <Tactility/hal/display/DisplayDevice.h>
#include <driver/gpio.h>
#include <driver/spi_common.h>
#include <memory>
constexpr auto LCD_SPI_HOST = SPI2_HOST;
constexpr auto LCD_PIN_CS = GPIO_NUM_5;
constexpr auto LCD_PIN_DC = GPIO_NUM_15;
constexpr auto LCD_HORIZONTAL_RESOLUTION = 320;
constexpr auto LCD_VERTICAL_RESOLUTION = 240;
constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 10;
constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT;
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,36 +0,0 @@
#include <Axp192.h>
#include <tactility/device.h>
static std::shared_ptr<Axp192> axp192 = nullptr;
std::shared_ptr<Axp192> createAxp192() {
assert(axp192 == nullptr);
auto configuration = std::make_unique<Axp192::Configuration>(device_find_by_name("i2c_internal"));
axp192 = std::make_shared<Axp192>(std::move(configuration));
return axp192;
}
std::shared_ptr<Axp192> getAxp192() {
assert(axp192 != nullptr);
return axp192;
}
bool initAxp() {
const auto axp = createAxp192();
return axp->init([](auto* driver) {
axp192_ioctl(driver, AXP192_LDO2_SET_VOLTAGE, 3300); // LCD + SD
axp192_ioctl(driver, AXP192_LDO3_SET_VOLTAGE, 0); // VIB_MOTOR STOP
axp192_ioctl(driver, AXP192_DCDC3_SET_VOLTAGE, 3300);
axp192_ioctl(driver, AXP192_LDO2_ENABLE);
axp192_ioctl(driver, AXP192_LDO3_DISABLE);
axp192_ioctl(driver, AXP192_DCDC3_ENABLE);
axp192_write(driver, AXP192_PWM1_DUTY_CYCLE_2, 255); // PWM 255 (LED OFF)
axp192_write(driver, AXP192_GPIO1_CONTROL, 0x02); // GPIO1 PWM
// TODO: We could charge at 390mA according to the M5Unified code, but the AXP driver in M5Unified limits to 132mA, so it's unclear what the AXP supports.
return true;
});
}
@@ -1,9 +0,0 @@
#pragma once
#include <Axp192.h>
bool initAxp();
// Must call initAxp() first before this returns a non-nullptr response
std::shared_ptr<Axp192> getAxp192();
-23
View File
@@ -1,23 +0,0 @@
#include <tactility/module.h>
extern "C" {
static error_t start() {
// Empty for now
return ERROR_NONE;
}
static error_t stop() {
// Empty for now
return ERROR_NONE;
}
struct Module m5stack_core2_module = {
.name = "m5stack-core2",
.start = start,
.stop = stop,
.symbols = nullptr,
.internal = nullptr
};
}
+2
View File
@@ -12,6 +12,8 @@ hardware.esptoolFlashFreq=80M
storage.userDataLocation=SD
dependencies.useDeprecatedHal=false
display.size=2"
display.shape=rectangle
display.dpi=200
+3
View File
@@ -2,4 +2,7 @@ dependencies:
- Platforms/platform-esp32
- Drivers/mpu6886-module
- Drivers/bm8563-module
- Drivers/axp192-module
- Drivers/ft6x36-module
- Drivers/ili9341-module
dts: m5stack,core2.dts
+23 -3
View File
@@ -10,8 +10,10 @@
#include <tactility/bindings/esp32_uart.h>
#include <bindings/mpu6886.h>
#include <bindings/bm8563.h>
#include <bindings/axp192.h>
#include <bindings/ft6x36.h>
#include <bindings/ili9341.h>
#include <tactility/bindings/esp32_sdspi.h>
#include <tactility/bindings/display_placeholder.h>
// Reference: https://docs.m5stack.com/en/core/Core2
/ {
@@ -44,6 +46,19 @@
compatible = "belling,bm8563";
reg = <0x51>;
};
axp192 {
compatible = "x-powers,axp192";
reg = <0x34>;
};
touch {
compatible = "focaltech,ft6x36";
reg = <0x38>;
x-max = <320>;
y-max = <240>;
pin-interrupt = <&gpio0 39 GPIO_FLAG_NONE>;
};
};
port_a: grove0 {
@@ -66,12 +81,17 @@
pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>;
display@0 {
compatible = "display-placeholder";
compatible = "ilitek,ili9341";
horizontal-resolution = <320>;
vertical-resolution = <240>;
invert-color;
bgr-order;
pixel-clock-hz = <40000000>;
pin-dc = <&gpio0 15 GPIO_FLAG_NONE>;
};
sdcard@1 {
compatible = "espressif,esp32-sdspi";
status = "disabled"; // Must be started after display
frequency-khz = <20000>;
};
};
+49
View File
@@ -0,0 +1,49 @@
#include <drivers/axp192.h>
#include <tactility/check.h>
#include <tactility/device.h>
#include <tactility/device_listener.h>
#include <tactility/module.h>
#include <cstring>
extern "C" {
static void configure_axp192(Device* axp192) {
check(axp192_set_rail_voltage(axp192, AXP192_RAIL_LDO2, 3300) == ERROR_NONE); // LCD + SD
check(axp192_set_rail_voltage(axp192, AXP192_RAIL_DCDC3, 3300) == ERROR_NONE); // LCD backlight
check(axp192_set_rail_enabled(axp192, AXP192_RAIL_LDO2, true) == ERROR_NONE);
check(axp192_set_rail_enabled(axp192, AXP192_RAIL_LDO3, false) == ERROR_NONE); // VIB_MOTOR stop
check(axp192_set_rail_enabled(axp192, AXP192_RAIL_DCDC3, true) == ERROR_NONE);
check(axp192_set_pwm1_duty_cycle(axp192, 255) == ERROR_NONE); // PWM 255 (LED off)
check(axp192_set_gpio1_pwm1_output(axp192) == ERROR_NONE); // GPIO1: PWM
}
static void on_device_event(Device* device, DeviceEvent event, void* context) {
(void)context;
if (event == DEVICE_EVENT_STARTED && strcmp(device->name, "axp192") == 0) {
configure_axp192(device);
}
}
static error_t start() {
device_listener_add(on_device_event, nullptr);
return ERROR_NONE;
}
static error_t stop() {
device_listener_remove(on_device_event);
return ERROR_NONE;
}
struct Module m5stack_core2_module = {
.name = "m5stack-core2",
.start = start,
.stop = stop,
.symbols = nullptr,
.internal = nullptr
};
}