Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2dc216fb7b | |||
| 81f289fc24 | |||
| d3919344b3 | |||
| 4ea29c0fe9 | |||
| e72d3998f9 | |||
| e423b28930 | |||
| 9ffd2051fe | |||
| bd8fea0436 | |||
| 301fed7f2e | |||
| da28b93f24 | |||
| b5f0575c5c | |||
| c4ec7ead55 | |||
| df93252281 | |||
| e4b95396dd | |||
| 4003065074 | |||
| 300ddb3a7f | |||
| b8bf59fedf | |||
| 68a6ca0ce3 | |||
| 430f8889ac | |||
| e0a92ea50e | |||
| 0ae9b43f87 | |||
| 598af546fd | |||
| cd921e1aa9 | |||
| 41004a3c6f | |||
| 28ff01561a | |||
| 68bf8f5a01 | |||
| bf7e40f0f1 | |||
| 71cc05e276 | |||
| 94b5cdbfc4 | |||
| 5c535490ea |
@@ -2,6 +2,8 @@
|
||||
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=3072
|
||||
# Ensure large enough stack for network operations
|
||||
CONFIG_ESP_MAIN_TASK_STACK_SIZE=6144
|
||||
# HTTP server: need enough URI handler slots for WebServer (7 + internal) + DevServer
|
||||
CONFIG_HTTPD_MAX_URI_HANDLERS=20
|
||||
# Fixes static assertion: FLASH and PSRAM Mode configuration are not supported
|
||||
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
|
||||
# Free up IRAM
|
||||
|
||||
+5
-2
@@ -54,6 +54,8 @@ if (DEFINED ENV{ESP_IDF_VERSION})
|
||||
|
||||
set(EXCLUDE_COMPONENTS "Simulator")
|
||||
|
||||
idf_build_set_property(LINK_OPTIONS "-Wl,--allow-multiple-definition" APPEND)
|
||||
|
||||
# Panic handler wrapping is only available on Xtensa architecture
|
||||
if (CONFIG_IDF_TARGET_ARCH_XTENSA)
|
||||
idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_panic_handler" APPEND)
|
||||
@@ -104,8 +106,9 @@ if (NOT DEFINED ENV{ESP_IDF_VERSION})
|
||||
target_compile_definitions(freertos_kernel PUBLIC "projCOVERAGE_TEST=0")
|
||||
|
||||
# EmbedTLS
|
||||
set(ENABLE_TESTING OFF)
|
||||
set(ENABLE_PROGRAMS OFF)
|
||||
set(ENABLE_TESTING OFF CACHE BOOL "" FORCE)
|
||||
set(ENABLE_PROGRAMS OFF CACHE BOOL "" FORCE)
|
||||
set(MBEDTLS_FATAL_WARNINGS OFF CACHE BOOL "" FORCE)
|
||||
add_subdirectory(Libraries/mbedtls)
|
||||
|
||||
# SDL
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
|
||||
|
||||
idf_component_register(
|
||||
SRCS ${SOURCE_FILES}
|
||||
INCLUDE_DIRS "Source"
|
||||
REQUIRES Tactility esp_lvgl_port ILI934x FT6x36 PwmBacklight driver vfs fatfs esp_adc
|
||||
)
|
||||
@@ -0,0 +1,94 @@
|
||||
#include "PwmBacklight.h"
|
||||
#include "devices/Display.h"
|
||||
#include "devices/Power.h"
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/i2c_controller.h>
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/error.h>
|
||||
#include <tactility/freertos/freertos.h>
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
|
||||
using namespace tt::hal;
|
||||
|
||||
static constexpr auto* TAG = "ES3C28P";
|
||||
static constexpr uint8_t ES8311_I2C_ADDR = 0x18;
|
||||
|
||||
static error_t initCodec(::Device* i2c_controller) {
|
||||
static constexpr uint8_t ENABLED_BULK_DATA[] = {
|
||||
0x00, 0x80, // RESET/CSM POWER ON
|
||||
0x01, 0x3F, // CLOCK_MANAGER/ use MCLK pin (external), all clocks on
|
||||
0x02, 0x00, // CLOCK_MANAGER/ pre_div=1 pre_multi=1 (256x MCLK is correct ratio)
|
||||
0x03, 0x10, // CLOCK_MANAGER/ fs_mode=0, adc_osr=16
|
||||
0x04, 0x10, // CLOCK_MANAGER/ dac_osr=16
|
||||
0x05, 0x00, // CLOCK_MANAGER/ adc_div=1, dac_div=1
|
||||
0x06, 0x03, // CLOCK_MANAGER/ bclk_div=4
|
||||
0x07, 0x00, // CLOCK_MANAGER/ lrck_h=0
|
||||
0x08, 0xFF, // CLOCK_MANAGER/ lrck_l=255 (div=256)
|
||||
0x09, 0x0C, // SDPIN_REG09/ DAC SDP format = standard I2S, word length = 16-bit
|
||||
0x0A, 0x0C, // SDPOUT_REG0A/ ADC SDP format = standard I2S, word length = 16-bit
|
||||
0x0D, 0x01, // SYSTEM/ Power up analog circuitry
|
||||
0x0E, 0x02, // SYSTEM/ Enable analog PGA, enable ADC modulator
|
||||
0x12, 0x00, // SYSTEM/ power-up DAC
|
||||
0x13, 0x10, // SYSTEM/ Enable output to HP drive (headphone/speaker)
|
||||
0x14, 0x1A, // SYSTEM/ Select Mic1p-Mic1n / max PGA gain (+30dB)
|
||||
0x17, 0xFF, // ADC_REG17/ ADC Volume (MAXGAIN)
|
||||
0x1C, 0x6A, // ADC_REG1C/ ADC Equalizer bypass, cancel DC offset in digital
|
||||
0x32, 0xBF, // DAC_REG32/ DAC Volume (0xBF = 191)
|
||||
0x37, 0x08, // DAC_REG37/ Bypass DAC equalizer
|
||||
};
|
||||
|
||||
return i2c_controller_write_register_array(
|
||||
i2c_controller,
|
||||
ES8311_I2C_ADDR,
|
||||
ENABLED_BULK_DATA,
|
||||
sizeof(ENABLED_BULK_DATA),
|
||||
pdMS_TO_TICKS(1000)
|
||||
);
|
||||
}
|
||||
|
||||
static bool initBoot() {
|
||||
// 1. Initialize display backlight
|
||||
if (!driver::pwmbacklight::init(LCD_PIN_BACKLIGHT)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 2. Initialize and power on the FM8002E Audio Amplifier (GPIO 1, Active LOW)
|
||||
gpio_config_t io_conf = {};
|
||||
io_conf.intr_type = GPIO_INTR_DISABLE;
|
||||
io_conf.mode = GPIO_MODE_OUTPUT;
|
||||
io_conf.pin_bit_mask = (1ULL << GPIO_NUM_1);
|
||||
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
||||
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
|
||||
gpio_config(&io_conf);
|
||||
|
||||
// Drive LOW to enable the speaker amplifier
|
||||
gpio_set_level(GPIO_NUM_1, 0);
|
||||
|
||||
// 3. Configure the ES8311 Codec over the I2C bus
|
||||
auto* i2c_bus = device_find_by_name("i2c0");
|
||||
if (i2c_bus != nullptr) {
|
||||
error_t error = initCodec(i2c_bus);
|
||||
if (error != ERROR_NONE) {
|
||||
LOG_E(TAG, "Failed to initialize ES8311 codec: %s", error_to_string(error));
|
||||
}
|
||||
} else {
|
||||
LOG_E(TAG, "i2c0 bus not found, skipping ES8311 initialization");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static DeviceVector createDevices() {
|
||||
return {
|
||||
createDisplay(),
|
||||
createPower()
|
||||
};
|
||||
}
|
||||
|
||||
extern const Configuration hardwareConfiguration = {
|
||||
.initBoot = initBoot,
|
||||
.createDevices = createDevices
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "Display.h"
|
||||
|
||||
#include <Ft6x36Touch.h>
|
||||
#include <Ili934xDisplay.h>
|
||||
#include <PwmBacklight.h>
|
||||
|
||||
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
|
||||
auto configuration = std::make_unique<Ft6x36Touch::Configuration>(
|
||||
I2C_NUM_0,
|
||||
240, // xMax (native portrait width)
|
||||
320, // yMax (native portrait height)
|
||||
true, // swapXy
|
||||
true, // mirrorX
|
||||
false, // mirrorY
|
||||
GPIO_NUM_18, // Touch Reset (RST)
|
||||
GPIO_NUM_17 // Touch Interrupt (INT)
|
||||
);
|
||||
|
||||
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 = true,
|
||||
.mirrorX = false,
|
||||
.mirrorY = false,
|
||||
.invertColor = true,
|
||||
.swapBytes = true,
|
||||
.bufferSize = LCD_BUFFER_SIZE,
|
||||
.touch = createTouch(),
|
||||
.backlightDutyFunction = driver::pwmbacklight::setBacklightDuty,
|
||||
.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);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
#include <driver/gpio.h>
|
||||
#include <driver/spi_common.h>
|
||||
#include <memory>
|
||||
|
||||
// Display
|
||||
constexpr auto LCD_SPI_HOST = SPI2_HOST;
|
||||
constexpr auto LCD_PIN_CS = GPIO_NUM_10;
|
||||
constexpr auto LCD_PIN_DC = GPIO_NUM_46;
|
||||
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;
|
||||
|
||||
// Backlight pin
|
||||
constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_45;
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
@@ -0,0 +1,156 @@
|
||||
#include "Power.h"
|
||||
#include <Tactility/Logger.h>
|
||||
#include <esp_adc/adc_oneshot.h>
|
||||
#include <esp_adc/adc_cali.h>
|
||||
#include <esp_adc/adc_cali_scheme.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
|
||||
static const auto* TAG = "ES3C28P_Power";
|
||||
|
||||
// HW: BAT+ -> R14 200K + R15 200K -> GND => BAT_ADC middle, 2x divider, to GPIO9 ADC1_CH8
|
||||
// Charger TP4054 CHRG pin only drives LED, not connected to ESP32 GPIO.
|
||||
// So we infer charging by voltage behavior: rising trend and high voltage.
|
||||
|
||||
class Es3c28pPower final : public tt::hal::power::PowerDevice {
|
||||
public:
|
||||
Es3c28pPower() {
|
||||
adc_oneshot_unit_init_cfg_t init_cfg = {
|
||||
.unit_id = ADC_UNIT_1,
|
||||
.clk_src = ADC_RTC_CLK_SRC_DEFAULT,
|
||||
.ulp_mode = ADC_ULP_MODE_DISABLE,
|
||||
};
|
||||
if (adc_oneshot_new_unit(&init_cfg, &adc_handle) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "ADC unit init failed");
|
||||
return;
|
||||
}
|
||||
adc_oneshot_chan_cfg_t chan_cfg = {
|
||||
.atten = ADC_ATTEN_DB_12,
|
||||
.bitwidth = ADC_BITWIDTH_12,
|
||||
};
|
||||
if (adc_oneshot_config_channel(adc_handle, ADC_CHANNEL_8, &chan_cfg) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "ADC channel config failed");
|
||||
adc_oneshot_del_unit(adc_handle);
|
||||
adc_handle = nullptr;
|
||||
return;
|
||||
}
|
||||
adc_cali_curve_fitting_config_t cali_cfg = {
|
||||
.unit_id = ADC_UNIT_1,
|
||||
.atten = ADC_ATTEN_DB_12,
|
||||
.bitwidth = ADC_BITWIDTH_12,
|
||||
};
|
||||
if (adc_cali_create_scheme_curve_fitting(&cali_cfg, &cali_handle) != ESP_OK) {
|
||||
ESP_LOGW(TAG, "ADC cali scheme failed");
|
||||
cali_handle = nullptr;
|
||||
}
|
||||
ESP_LOGI(TAG, "Battery ADC GPIO9 ADC1_CH8, 2x divider, cali %s", cali_handle ? "OK" : "none");
|
||||
}
|
||||
|
||||
~Es3c28pPower() override {
|
||||
if (cali_handle) adc_cali_delete_scheme_curve_fitting(cali_handle);
|
||||
if (adc_handle) adc_oneshot_del_unit(adc_handle);
|
||||
}
|
||||
|
||||
std::string getName() const override { return "ES3C28P Power"; }
|
||||
std::string getDescription() const override { return "Battery GPIO9 ADC1_CH8 + TP4054 inferred charging"; }
|
||||
|
||||
bool supportsMetric(MetricType type) const override {
|
||||
switch (type) {
|
||||
case MetricType::BatteryVoltage:
|
||||
case MetricType::ChargeLevel:
|
||||
case MetricType::IsCharging:
|
||||
return adc_handle != nullptr;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool getMetric(MetricType type, MetricData& data) override {
|
||||
if (!adc_handle) return false;
|
||||
|
||||
int raw = 0;
|
||||
int mv = 0;
|
||||
if (adc_oneshot_read(adc_handle, ADC_CHANNEL_8, &raw) != ESP_OK) return false;
|
||||
if (cali_handle) {
|
||||
if (adc_cali_raw_to_voltage(cali_handle, raw, &mv) != ESP_OK) return false;
|
||||
} else {
|
||||
mv = (raw * 3300) / 4095;
|
||||
}
|
||||
int vbat_mv = mv * 2; // 200K/200K divider
|
||||
|
||||
// Track voltage trend for charging detection
|
||||
const int now_ms = xTaskGetTickCount() * portTICK_PERIOD_MS;
|
||||
if (last_read_ms == 0) {
|
||||
last_vbat_mv = vbat_mv;
|
||||
last_read_ms = now_ms;
|
||||
}
|
||||
|
||||
// Update trend every 2 seconds to avoid noise
|
||||
if (now_ms - last_read_ms > 2000) {
|
||||
// If voltage increased by at least 10mV in 2s, likely charging
|
||||
if (vbat_mv > last_vbat_mv + 10) {
|
||||
rising_count++;
|
||||
falling_count = 0;
|
||||
} else if (vbat_mv < last_vbat_mv - 10) {
|
||||
falling_count++;
|
||||
rising_count = 0;
|
||||
if (falling_count > 3) is_charging_trend = false;
|
||||
}
|
||||
last_vbat_mv = vbat_mv;
|
||||
last_read_ms = now_ms;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case MetricType::BatteryVoltage:
|
||||
data.valueAsUint32 = (uint32_t)vbat_mv;
|
||||
return true;
|
||||
case MetricType::ChargeLevel: {
|
||||
uint8_t pct;
|
||||
if (vbat_mv <= 2500) pct = 0;
|
||||
else if (vbat_mv >= 4200) pct = 100;
|
||||
else pct = (uint8_t)((vbat_mv - 2500) / 17);
|
||||
data.valueAsUint8 = pct;
|
||||
return true;
|
||||
}
|
||||
case MetricType::IsCharging: {
|
||||
// Cases:
|
||||
// 1. No battery / wall powered: vbat <500mV or >5000mV (VBUS via MOSFET) => charging true
|
||||
if (vbat_mv < 500 || vbat_mv > 5000) {
|
||||
data.valueAsBool = true;
|
||||
is_charging_trend = true;
|
||||
return true;
|
||||
}
|
||||
// 2. High voltage near full with charger attached: >=4150mV => charging (charger holds at 4.2V)
|
||||
if (vbat_mv >= 4150) {
|
||||
data.valueAsBool = true;
|
||||
is_charging_trend = true;
|
||||
return true;
|
||||
}
|
||||
// 3. Rising trend indicates charging
|
||||
if (rising_count >= 2) {
|
||||
is_charging_trend = true;
|
||||
}
|
||||
// 4. If previously charging and voltage still >=4000, keep charging until drop
|
||||
if (is_charging_trend && vbat_mv >= 4000) {
|
||||
data.valueAsBool = true;
|
||||
return true;
|
||||
}
|
||||
data.valueAsBool = is_charging_trend;
|
||||
return true;
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
adc_oneshot_unit_handle_t adc_handle = nullptr;
|
||||
adc_cali_handle_t cali_handle = nullptr;
|
||||
int last_vbat_mv = 0;
|
||||
int last_read_ms = 0;
|
||||
int rising_count = 0;
|
||||
int falling_count = 0;
|
||||
bool is_charging_trend = false;
|
||||
};
|
||||
|
||||
std::shared_ptr<tt::hal::power::PowerDevice> createPower() {
|
||||
return std::make_shared<Es3c28pPower>();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
#include <Tactility/hal/power/PowerDevice.h>
|
||||
#include <memory>
|
||||
|
||||
std::shared_ptr<tt::hal::power::PowerDevice> createPower();
|
||||
@@ -0,0 +1,23 @@
|
||||
#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 es3c28p_module = {
|
||||
.name = "es3c28p",
|
||||
.start = start,
|
||||
.stop = stop,
|
||||
.symbols = nullptr,
|
||||
.internal = nullptr
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
general.vendor=LCDWIKI
|
||||
general.name=ES3C28P
|
||||
|
||||
apps.launcherAppId=Launcher
|
||||
|
||||
hardware.target=ESP32S3
|
||||
hardware.flashSize=16MB
|
||||
hardware.spiRam=true
|
||||
hardware.spiRamMode=OCT
|
||||
hardware.spiRamSpeed=120M
|
||||
hardware.tinyUsb=true
|
||||
hardware.usbHostEnabled=false
|
||||
hardware.esptoolFlashFreq=120M
|
||||
hardware.bluetooth=true
|
||||
|
||||
display.size=2.8"
|
||||
display.shape=rectangle
|
||||
display.dpi=143
|
||||
|
||||
lvgl.colorDepth=16
|
||||
|
||||
storage.userDataLocation=SD
|
||||
|
||||
sdkconfig.CONFIG_LV_CACHE_DEF_SIZE=524288
|
||||
sdkconfig.CONFIG_LV_IMAGE_HEADER_CACHE_DEF_CNT=16
|
||||
@@ -0,0 +1,3 @@
|
||||
dependencies:
|
||||
- Platforms/platform-esp32
|
||||
dts: es3c28p.dts
|
||||
@@ -0,0 +1,81 @@
|
||||
/dts-v1/;
|
||||
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_ble.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_sdmmc.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_i2s.h>
|
||||
#include <tactility/bindings/esp32_usbhost.h>
|
||||
|
||||
/ {
|
||||
compatible = "root";
|
||||
model = "LCDWIKI ES3C28P";
|
||||
|
||||
ble0 {
|
||||
compatible = "espressif,esp32-ble";
|
||||
};
|
||||
|
||||
gpio0 {
|
||||
compatible = "espressif,esp32-gpio";
|
||||
gpio-count = <49>;
|
||||
};
|
||||
|
||||
i2c0 {
|
||||
compatible = "espressif,esp32-i2c";
|
||||
port = <I2C_NUM_0>;
|
||||
clock-frequency = <100000>;
|
||||
pin-sda = <&gpio0 16 GPIO_FLAG_NONE>;
|
||||
pin-scl = <&gpio0 15 GPIO_FLAG_NONE>;
|
||||
};
|
||||
|
||||
i2s0 {
|
||||
compatible = "espressif,esp32-i2s";
|
||||
port = <I2S_NUM_0>;
|
||||
pin-bclk = <&gpio0 5 GPIO_FLAG_NONE>;
|
||||
pin-ws = <&gpio0 7 GPIO_FLAG_NONE>;
|
||||
pin-data-out = <&gpio0 8 GPIO_FLAG_NONE>;
|
||||
pin-data-in = <&gpio0 6 GPIO_FLAG_NONE>;
|
||||
pin-mclk = <&gpio0 4 GPIO_FLAG_NONE>;
|
||||
};
|
||||
|
||||
display_spi: spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>;
|
||||
pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>;
|
||||
};
|
||||
|
||||
sdmmc0 {
|
||||
compatible = "espressif,esp32-sdmmc";
|
||||
pin-clk = <&gpio0 38 GPIO_FLAG_NONE>;
|
||||
pin-cmd = <&gpio0 40 GPIO_FLAG_NONE>;
|
||||
pin-d0 = <&gpio0 39 GPIO_FLAG_NONE>;
|
||||
pin-d1 = <&gpio0 41 GPIO_FLAG_NONE>;
|
||||
pin-d2 = <&gpio0 48 GPIO_FLAG_NONE>;
|
||||
pin-d3 = <&gpio0 47 GPIO_FLAG_NONE>;
|
||||
slot = <SDMMC_HOST_SLOT_1>;
|
||||
bus-width = <4>;
|
||||
};
|
||||
|
||||
usbhost0 {
|
||||
compatible = "espressif,esp32-usbhost";
|
||||
status = "disabled";
|
||||
|
||||
usbhosthid0 {
|
||||
compatible = "espressif,esp32-usbhost-hid";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
usbhostmidi0 {
|
||||
compatible = "espressif,esp32-usbhost-midi";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
usbhostmsc0 {
|
||||
compatible = "espressif,esp32-usbhost-msc";
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -3,5 +3,5 @@ file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
|
||||
idf_component_register(
|
||||
SRCS ${SOURCE_FILES}
|
||||
INCLUDE_DIRS "Source"
|
||||
REQUIRES Tactility esp_lvgl_port esp_lcd EspLcdCompat esp_lcd_ili9881c esp_lcd_st7123 esp_lcd_touch_st7123 GT911 PwmBacklight driver esp_driver_i2c vfs fatfs ina226-module
|
||||
REQUIRES Tactility esp_lvgl_port esp_lcd EspLcdCompat esp_lcd_ili9881c esp_lcd_st7123 esp_lcd_touch_st7123 GT911 PwmBacklight driver vfs fatfs ina226-module
|
||||
)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# Force CMake reload to detect new files module.cpp and Configuration.cpp
|
||||
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
|
||||
|
||||
idf_component_register(
|
||||
SRCS ${SOURCE_FILES}
|
||||
INCLUDE_DIRS "Source"
|
||||
REQUIRES Tactility ButtonControl ST7305 PwmBacklight driver
|
||||
)
|
||||
@@ -0,0 +1,88 @@
|
||||
#include "devices/Display.h"
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/i2c_controller.h>
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/error.h>
|
||||
#include <tactility/freertos/freertos.h>
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <ButtonControl.h>
|
||||
|
||||
using namespace tt::hal;
|
||||
|
||||
static constexpr auto* TAG = "WaveshareRLCD";
|
||||
static constexpr uint8_t ES8311_I2C_ADDR = 0x18;
|
||||
|
||||
static error_t initCodec(::Device* i2c_controller) {
|
||||
static constexpr uint8_t ENABLED_BULK_DATA[] = {
|
||||
0x00, 0x80, // RESET/CSM POWER ON
|
||||
0x01, 0x3F, // CLOCK_MANAGER/ use MCLK pin (external), all clocks on
|
||||
0x02, 0x00, // CLOCK_MANAGER/ pre_div=1 pre_multi=1 (256x MCLK is correct ratio)
|
||||
0x03, 0x10, // CLOCK_MANAGER/ fs_mode=0, adc_osr=16
|
||||
0x04, 0x10, // CLOCK_MANAGER/ dac_osr=16
|
||||
0x05, 0x00, // CLOCK_MANAGER/ adc_div=1, dac_div=1
|
||||
0x06, 0x03, // CLOCK_MANAGER/ bclk_div=4
|
||||
0x07, 0x00, // CLOCK_MANAGER/ lrck_h=0
|
||||
0x08, 0xFF, // CLOCK_MANAGER/ lrck_l=255 (div=256)
|
||||
0x09, 0x0C, // SDPIN_REG09/ DAC SDP format = standard I2S, word length = 16-bit
|
||||
0x0A, 0x0C, // SDPOUT_REG0A/ ADC SDP format = standard I2S, word length = 16-bit
|
||||
0x0D, 0x01, // SYSTEM/ Power up analog circuitry
|
||||
0x0E, 0x02, // SYSTEM/ Enable analog PGA, enable ADC modulator
|
||||
0x12, 0x00, // SYSTEM/ power-up DAC
|
||||
0x13, 0x10, // SYSTEM/ Enable output to HP drive (headphone/speaker)
|
||||
0x14, 0x1A, // SYSTEM/ Select Mic1p-Mic1n / max PGA gain (+30dB)
|
||||
0x17, 0xFF, // ADC_REG17/ ADC Volume (MAXGAIN)
|
||||
0x1C, 0x6A, // ADC_REG1C/ ADC Equalizer bypass, cancel DC offset in digital
|
||||
0x32, 0xBF, // DAC_REG32/ DAC Volume (0xBF = 191)
|
||||
0x37, 0x08, // DAC_REG37/ Bypass DAC equalizer
|
||||
};
|
||||
|
||||
return i2c_controller_write_register_array(
|
||||
i2c_controller,
|
||||
ES8311_I2C_ADDR,
|
||||
ENABLED_BULK_DATA,
|
||||
sizeof(ENABLED_BULK_DATA),
|
||||
pdMS_TO_TICKS(1000)
|
||||
);
|
||||
}
|
||||
|
||||
static bool initBoot() {
|
||||
// 1. Initialize and power on the Speaker Amplifier (GPIO 46, Active HIGH)
|
||||
gpio_config_t io_conf = {};
|
||||
io_conf.intr_type = GPIO_INTR_DISABLE;
|
||||
io_conf.mode = GPIO_MODE_OUTPUT;
|
||||
io_conf.pin_bit_mask = (1ULL << GPIO_NUM_46);
|
||||
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
||||
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
|
||||
gpio_config(&io_conf);
|
||||
|
||||
// Drive HIGH to enable the speaker amplifier
|
||||
gpio_set_level(GPIO_NUM_46, 1);
|
||||
|
||||
// 2. Configure the ES8311 Codec over the I2C bus
|
||||
auto* i2c_bus = device_find_by_name("i2c0");
|
||||
if (i2c_bus != nullptr) {
|
||||
error_t error = initCodec(i2c_bus);
|
||||
if (error != ERROR_NONE) {
|
||||
LOG_E(TAG, "Failed to initialize ES8311 codec: %s", error_to_string(error));
|
||||
}
|
||||
} else {
|
||||
LOG_E(TAG, "i2c0 bus not found, skipping ES8311 initialization");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static DeviceVector createDevices() {
|
||||
return {
|
||||
createDisplay(),
|
||||
ButtonControl::createTwoButtonControl(GPIO_NUM_18, GPIO_NUM_0) // KEY=18 (primary), BOOT=0 (secondary)
|
||||
};
|
||||
}
|
||||
|
||||
extern const Configuration hardwareConfiguration = {
|
||||
.initBoot = initBoot,
|
||||
.createDevices = createDevices
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "Display.h"
|
||||
#include <St7305Display.h>
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
auto configuration = std::make_unique<St7305Display::Configuration>(
|
||||
SPI2_HOST,
|
||||
GPIO_NUM_40, // CS
|
||||
GPIO_NUM_5, // DC
|
||||
400, // Width
|
||||
300, // Height
|
||||
nullptr, // Touch device
|
||||
false, // swapXY
|
||||
false, // mirrorX
|
||||
false, // mirrorY
|
||||
false, // invertColor
|
||||
0 // bufferSize (0 = default, which is full screen = 120,000 pixels)
|
||||
);
|
||||
|
||||
configuration->resetPin = GPIO_NUM_41;
|
||||
|
||||
auto display = std::make_shared<St7305Display>(std::move(configuration));
|
||||
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
#include <memory>
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <tactility/module.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
static error_t start() {
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
static error_t stop() {
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
struct Module waveshare_esp32_s3_rlcd_module = {
|
||||
.name = "waveshare-esp32-s3-rlcd",
|
||||
.start = start,
|
||||
.stop = stop,
|
||||
.symbols = nullptr,
|
||||
.internal = nullptr
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
general.vendor=WaveShare
|
||||
general.name=ESP32-S3-RLCD-4.2
|
||||
general.incubating=true
|
||||
|
||||
apps.launcherAppId=Launcher
|
||||
# apps.autoStartAppId=ApWebServer
|
||||
|
||||
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=4.2"
|
||||
display.shape=rectangle
|
||||
display.dpi=120
|
||||
|
||||
lvgl.colorDepth=16
|
||||
lvgl.uiDensity=compact
|
||||
@@ -0,0 +1,3 @@
|
||||
dependencies:
|
||||
- Platforms/platform-esp32
|
||||
dts: waveshare,esp32-s3-rlcd.dts
|
||||
@@ -0,0 +1,74 @@
|
||||
/dts-v1/;
|
||||
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_ble.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_sdmmc.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_i2s.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
#include <tactility/bindings/display_placeholder.h>
|
||||
|
||||
/ {
|
||||
compatible = "root";
|
||||
model = "Waveshare ESP32-S3-RLCD-4.2";
|
||||
|
||||
ble0 {
|
||||
compatible = "espressif,esp32-ble";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
gpio0 {
|
||||
compatible = "espressif,esp32-gpio";
|
||||
gpio-count = <49>;
|
||||
};
|
||||
|
||||
i2s0 {
|
||||
compatible = "espressif,esp32-i2s";
|
||||
port = <I2S_NUM_0>;
|
||||
pin-bclk = <&gpio0 5 GPIO_FLAG_NONE>;
|
||||
pin-ws = <&gpio0 7 GPIO_FLAG_NONE>;
|
||||
pin-data-out = <&gpio0 8 GPIO_FLAG_NONE>;
|
||||
pin-data-in = <&gpio0 6 GPIO_FLAG_NONE>;
|
||||
pin-mclk = <&gpio0 4 GPIO_FLAG_NONE>;
|
||||
};
|
||||
|
||||
i2c0 {
|
||||
compatible = "espressif,esp32-i2c";
|
||||
port = <I2C_NUM_0>;
|
||||
clock-frequency = <400000>;
|
||||
pin-sda = <&gpio0 13 GPIO_FLAG_NONE>;
|
||||
pin-scl = <&gpio0 14 GPIO_FLAG_NONE>;
|
||||
};
|
||||
|
||||
spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
cs-gpios = <&gpio0 40 GPIO_FLAG_NONE>;
|
||||
pin-mosi = <&gpio0 12 GPIO_FLAG_NONE>;
|
||||
pin-sclk = <&gpio0 11 GPIO_FLAG_NONE>;
|
||||
|
||||
display {
|
||||
compatible = "display-placeholder";
|
||||
};
|
||||
};
|
||||
|
||||
sdmmc0 {
|
||||
compatible = "espressif,esp32-sdmmc";
|
||||
pin-clk = <&gpio0 38 GPIO_FLAG_NONE>;
|
||||
pin-cmd = <&gpio0 21 GPIO_FLAG_NONE>;
|
||||
pin-d0 = <&gpio0 39 GPIO_FLAG_NONE>;
|
||||
pin-d3 = <&gpio0 17 GPIO_FLAG_NONE>;
|
||||
slot = <SDMMC_HOST_SLOT_1>;
|
||||
bus-width = <1>;
|
||||
pullups;
|
||||
};
|
||||
|
||||
uart0 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
port = <UART_NUM_0>;
|
||||
pin-tx = <&gpio0 43 GPIO_FLAG_NONE>;
|
||||
pin-rx = <&gpio0 44 GPIO_FLAG_NONE>;
|
||||
};
|
||||
};
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <esp_lcd_types.h>
|
||||
#include <esp_lvgl_port_disp.h>
|
||||
#include <hal/gpio_types.h>
|
||||
|
||||
constexpr auto DEFAULT_BUFFER_SIZE = 0;
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@ bool EspLcdSpiDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
|
||||
.user_ctx = nullptr,
|
||||
.lcd_cmd_bits = 8,
|
||||
.lcd_param_bits = 8,
|
||||
.cs_ena_pretrans = 0,
|
||||
.cs_ena_posttrans = 0,
|
||||
.flags = {
|
||||
.dc_high_on_cmd = 0,
|
||||
.dc_low_on_data = 0,
|
||||
|
||||
@@ -48,6 +48,11 @@ bool EspLcdTouch::startLvgl(lv_disp_t* display) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (touchHandle == nullptr) {
|
||||
LOGGER.error("Cannot start LVGL touch: touchHandle is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (touchDriver != nullptr && touchDriver.use_count() > 1) {
|
||||
LOGGER.warn("TouchDriver is still in use.");
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ bool init(gpio_num_t pin, uint32_t frequencyHz, ledc_timer_t timer, ledc_channel
|
||||
.timer_sel = backlightTimer,
|
||||
.duty = 0,
|
||||
.hpoint = 0,
|
||||
.sleep_mode = LEDC_SLEEP_MODE_NO_ALIVE_NO_PD,
|
||||
.flags = {
|
||||
.output_invert = 0
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
idf_component_register(
|
||||
SRC_DIRS "Source"
|
||||
INCLUDE_DIRS "Source"
|
||||
REQUIRES Tactility driver EspLcdCompat
|
||||
)
|
||||
@@ -0,0 +1,99 @@
|
||||
#include "St7305Display.h"
|
||||
#include "esp_lcd_st7305.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <esp_lcd_panel_ops.h>
|
||||
#include <esp_lvgl_port.h>
|
||||
|
||||
static const auto LOGGER = tt::Logger("ST7305");
|
||||
|
||||
bool St7305Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
|
||||
LOGGER.info("Starting ST7305 SPI panel IO creation");
|
||||
|
||||
const esp_lcd_panel_io_spi_config_t panel_io_config = {
|
||||
.cs_gpio_num = configuration->csPin,
|
||||
.dc_gpio_num = configuration->dcPin,
|
||||
.spi_mode = 0,
|
||||
.pclk_hz = configuration->pixelClockFrequency,
|
||||
.trans_queue_depth = configuration->transactionQueueDepth,
|
||||
.on_color_trans_done = nullptr,
|
||||
.user_ctx = nullptr,
|
||||
.lcd_cmd_bits = 8,
|
||||
.lcd_param_bits = 8,
|
||||
.flags = {
|
||||
.dc_high_on_cmd = 0,
|
||||
.dc_low_on_data = 0,
|
||||
.dc_low_on_param = 0,
|
||||
.octal_mode = 0,
|
||||
.quad_mode = 0,
|
||||
.sio_mode = 0,
|
||||
.lsb_first = 0,
|
||||
.cs_high_active = 0
|
||||
}
|
||||
};
|
||||
|
||||
if (esp_lcd_new_panel_io_spi(configuration->spiHostDevice, &panel_io_config, &outHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to create panel SPI IO");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool St7305Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle) {
|
||||
const esp_lcd_panel_dev_config_t panel_config = {
|
||||
.reset_gpio_num = configuration->resetPin,
|
||||
.color_space = ESP_LCD_COLOR_SPACE_MONOCHROME,
|
||||
.data_endian = LCD_RGB_DATA_ENDIAN_BIG,
|
||||
.bits_per_pixel = 1,
|
||||
.flags = {
|
||||
.reset_active_high = false
|
||||
},
|
||||
.vendor_config = nullptr
|
||||
};
|
||||
|
||||
if (esp_lcd_new_panel_st7305(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to create st7305 panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to reset st7305 panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
|
||||
LOGGER.error("Failed to init st7305 panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
lvgl_port_display_cfg_t St7305Display::getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) {
|
||||
return lvgl_port_display_cfg_t {
|
||||
.io_handle = ioHandle,
|
||||
.panel_handle = panelHandle,
|
||||
.control_handle = nullptr,
|
||||
.buffer_size = configuration->bufferSize,
|
||||
.double_buffer = false, // Monochrome displays usually use single buffering to save RAM
|
||||
.trans_size = 0,
|
||||
.hres = configuration->horizontalResolution,
|
||||
.vres = configuration->verticalResolution,
|
||||
.monochrome = true, // Enables esp_lvgl_port monochrome converter
|
||||
.rotation = {
|
||||
.swap_xy = false,
|
||||
.mirror_x = true,
|
||||
.mirror_y = false,
|
||||
},
|
||||
.color_format = LV_COLOR_FORMAT_RGB565, // Must be RGB565 for monochrome mode to trigger converter
|
||||
.flags = {
|
||||
.buff_dma = false,
|
||||
.buff_spiram = false,
|
||||
.sw_rotate = false,
|
||||
.swap_bytes = false,
|
||||
.full_refresh = true, // We want full refresh to rewrite the converted block format to ST7305
|
||||
.direct_mode = false
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
#pragma once
|
||||
|
||||
#include <EspLcdDisplay.h>
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
|
||||
#include <driver/gpio.h>
|
||||
#include <driver/spi_common.h>
|
||||
#include <esp_lcd_panel_io.h>
|
||||
#include <esp_lcd_types.h>
|
||||
#include <functional>
|
||||
#include <lvgl.h>
|
||||
|
||||
class St7305Display final : public EspLcdDisplay {
|
||||
|
||||
public:
|
||||
|
||||
class Configuration {
|
||||
|
||||
public:
|
||||
|
||||
Configuration(
|
||||
spi_host_device_t spiHostDevice,
|
||||
gpio_num_t csPin,
|
||||
gpio_num_t dcPin,
|
||||
unsigned int horizontalResolution,
|
||||
unsigned int verticalResolution,
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> touch = nullptr,
|
||||
bool swapXY = false,
|
||||
bool mirrorX = false,
|
||||
bool mirrorY = false,
|
||||
bool invertColor = false,
|
||||
uint32_t bufferSize = 0
|
||||
) : spiHostDevice(spiHostDevice),
|
||||
csPin(csPin),
|
||||
dcPin(dcPin),
|
||||
horizontalResolution(horizontalResolution),
|
||||
verticalResolution(verticalResolution),
|
||||
swapXY(swapXY),
|
||||
mirrorX(mirrorX),
|
||||
mirrorY(mirrorY),
|
||||
invertColor(invertColor),
|
||||
bufferSize(bufferSize),
|
||||
touch(std::move(touch))
|
||||
{
|
||||
if (this->bufferSize == 0) {
|
||||
// For monochrome display, full pixel count is expected for buffer size
|
||||
this->bufferSize = horizontalResolution * verticalResolution;
|
||||
}
|
||||
}
|
||||
|
||||
spi_host_device_t spiHostDevice;
|
||||
gpio_num_t csPin;
|
||||
gpio_num_t dcPin;
|
||||
gpio_num_t resetPin = GPIO_NUM_NC;
|
||||
unsigned int pixelClockFrequency = 10'000'000; // 10MHz SPI clock for ST7305
|
||||
size_t transactionQueueDepth = 10;
|
||||
unsigned int horizontalResolution;
|
||||
unsigned int verticalResolution;
|
||||
bool swapXY = false;
|
||||
bool mirrorX = false;
|
||||
bool mirrorY = false;
|
||||
bool invertColor = false;
|
||||
uint32_t bufferSize = 0;
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> touch;
|
||||
std::function<void(uint8_t)> _Nullable backlightDutyFunction = nullptr;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
std::unique_ptr<Configuration> configuration;
|
||||
|
||||
bool createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) 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;
|
||||
|
||||
public:
|
||||
|
||||
explicit St7305Display(std::unique_ptr<Configuration> inConfiguration) :
|
||||
configuration(std::move(inConfiguration))
|
||||
{}
|
||||
|
||||
std::string getName() const override { return "ST7305"; }
|
||||
|
||||
std::string getDescription() const override { return "ST7305 monochrome reflective LCD display"; }
|
||||
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable getTouchDevice() override { return configuration->touch; }
|
||||
|
||||
void setBacklightDuty(uint8_t backlightDuty) override {
|
||||
if (configuration->backlightDutyFunction != nullptr) {
|
||||
configuration->backlightDutyFunction(backlightDuty);
|
||||
}
|
||||
}
|
||||
|
||||
bool supportsBacklightDuty() const override { return configuration->backlightDutyFunction != nullptr; }
|
||||
};
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
@@ -0,0 +1,286 @@
|
||||
#include "esp_lcd_st7305.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "esp_check.h"
|
||||
#include "esp_lcd_types.h"
|
||||
#include <stdlib.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_lcd_panel_interface.h"
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include "esp_lcd_panel_commands.h"
|
||||
#include "driver/gpio.h"
|
||||
#include <string.h>
|
||||
#include "esp_log.h"
|
||||
|
||||
static const char *TAG = "st7305";
|
||||
|
||||
static esp_err_t panel_st7305_del(esp_lcd_panel_t *panel);
|
||||
static esp_err_t panel_st7305_reset(esp_lcd_panel_t *panel);
|
||||
static esp_err_t panel_st7305_init(esp_lcd_panel_t *panel);
|
||||
static esp_err_t panel_st7305_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data);
|
||||
static esp_err_t panel_st7305_invert_color(esp_lcd_panel_t *panel, bool invert_color_data);
|
||||
static esp_err_t panel_st7305_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y);
|
||||
static esp_err_t panel_st7305_swap_xy(esp_lcd_panel_t *panel, bool swap_axes);
|
||||
static esp_err_t panel_st7305_set_gap(esp_lcd_panel_t *panel, int x_gap, int y_gap);
|
||||
static esp_err_t panel_st7305_disp_on_off(esp_lcd_panel_t *panel, bool off);
|
||||
|
||||
typedef struct {
|
||||
esp_lcd_panel_t base;
|
||||
esp_lcd_panel_io_handle_t io;
|
||||
int reset_gpio_num;
|
||||
bool reset_level;
|
||||
int x_gap;
|
||||
int y_gap;
|
||||
int width;
|
||||
int height;
|
||||
uint8_t rotation;
|
||||
uint8_t madctl_val;
|
||||
const st7305_lcd_init_cmd_t *init_cmds;
|
||||
uint16_t init_cmds_size;
|
||||
} st7305_panel_t;
|
||||
|
||||
static const st7305_lcd_init_cmd_t st7305_init_cmds[] = {
|
||||
{0xD6, (uint8_t[]){0x17, 0x02}, 2, 0}, // NVM Load Control
|
||||
{0xD1, (uint8_t[]){0x01}, 1, 0}, // Booster Enable
|
||||
{0xC0, (uint8_t[]){0x11, 0x04}, 2, 0}, // Gate Voltage Setting
|
||||
{0xC1, (uint8_t[]){0x41, 0x41, 0x41, 0x41}, 4, 0}, // VSHP Setting
|
||||
{0xC2, (uint8_t[]){0x19, 0x19, 0x19, 0x19}, 4, 0}, // VSLP Setting
|
||||
{0xC4, (uint8_t[]){0x41, 0x41, 0x41, 0x41}, 4, 0}, // VSHN Setting
|
||||
{0xC5, (uint8_t[]){0x19, 0x13, 0x19, 0x19}, 4, 0}, // VSLN Setting
|
||||
{0xD8, (uint8_t[]){0xA6, 0xE9}, 2, 0}, // OSC Setting
|
||||
{0xB2, (uint8_t[]){0x05}, 1, 0}, // Frame Rate Control
|
||||
{0xB3, (uint8_t[]){0xE5, 0xF6, 0x05, 0x46, 0x77, 0x77, 0x77, 0x77, 0x76, 0x45}, 10, 0}, // Gate EQ HPM
|
||||
{0xB4, (uint8_t[]){0x05, 0x46, 0x77, 0x77, 0x77, 0x77, 0x76, 0x45}, 8, 0}, // Gate EQ LPM
|
||||
{0x62, (uint8_t[]){0x32, 0x03, 0x1F}, 3, 0}, // Gate Timing Control
|
||||
{0xB7, (uint8_t[]){0x13}, 1, 0}, // Source EQ Enable
|
||||
{0xB0, (uint8_t[]){0x64}, 1, 0}, // Gate Line Setting: 300 line (0x64 = 100 * 3)
|
||||
{0x11, NULL, 0, 200}, // Sleep out
|
||||
{0xC9, (uint8_t[]){0x00}, 1, 0}, // Source Voltage Select
|
||||
{0x36, (uint8_t[]){0x48}, 1, 0}, // Memory Data Access Control (MX=1, DO=1)
|
||||
{0x3A, (uint8_t[]){0x11}, 1, 0}, // Data Format Select: 1bpp
|
||||
{0xB9, (uint8_t[]){0x20}, 1, 0}, // Gamma Mode Setting
|
||||
{0xB8, (uint8_t[]){0x29}, 1, 0}, // Panel Setting
|
||||
{0x21, NULL, 0, 0}, // Display Inversion On
|
||||
{0x2A, (uint8_t[]){0x12, 0x2A}, 2, 0}, // Column Address Setting
|
||||
{0x2B, (uint8_t[]){0x00, 0xC7}, 2, 0}, // Row Address Setting
|
||||
{0x35, (uint8_t[]){0x00}, 1, 0}, // TE Line
|
||||
{0xD0, (uint8_t[]){0xFF}, 1, 0}, // Auto power down ON
|
||||
{0x38, NULL, 0, 0}, // High Power Mode ON
|
||||
{0x29, NULL, 0, 100}, // Display ON
|
||||
};
|
||||
|
||||
esp_err_t esp_lcd_new_panel_st7305(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config,
|
||||
esp_lcd_panel_handle_t *ret_panel)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
st7305_panel_t *st7305 = NULL;
|
||||
gpio_config_t io_conf = { 0 };
|
||||
|
||||
ESP_GOTO_ON_FALSE(io && panel_dev_config && ret_panel, ESP_ERR_INVALID_ARG, err, TAG, "invalid argument");
|
||||
st7305 = (st7305_panel_t *)calloc(1, sizeof(st7305_panel_t));
|
||||
ESP_GOTO_ON_FALSE(st7305, ESP_ERR_NO_MEM, err, TAG, "no mem for st7305 panel");
|
||||
|
||||
if (panel_dev_config->reset_gpio_num >= 0) {
|
||||
io_conf.mode = GPIO_MODE_OUTPUT;
|
||||
io_conf.pin_bit_mask = 1ULL << panel_dev_config->reset_gpio_num;
|
||||
ESP_GOTO_ON_ERROR(gpio_config(&io_conf), err, TAG, "configure GPIO for RST line failed");
|
||||
}
|
||||
st7305->width = ST7305_WIDTH;
|
||||
st7305->height = ST7305_HEIGHT;
|
||||
st7305->madctl_val = 0x48; // MX=1, DO=1
|
||||
st7305->rotation = 0;
|
||||
|
||||
st7305->io = io;
|
||||
st7305->reset_gpio_num = panel_dev_config->reset_gpio_num;
|
||||
st7305->reset_level = panel_dev_config->flags.reset_active_high;
|
||||
if (panel_dev_config->vendor_config) {
|
||||
st7305->init_cmds = ((st7305_vendor_config_t *)panel_dev_config->vendor_config)->init_cmds;
|
||||
st7305->init_cmds_size = ((st7305_vendor_config_t *)panel_dev_config->vendor_config)->init_cmds_size;
|
||||
} else {
|
||||
st7305->init_cmds = st7305_init_cmds;
|
||||
st7305->init_cmds_size = sizeof(st7305_init_cmds) / sizeof(st7305_lcd_init_cmd_t);
|
||||
}
|
||||
st7305->base.del = panel_st7305_del;
|
||||
st7305->base.reset = panel_st7305_reset;
|
||||
st7305->base.init = panel_st7305_init;
|
||||
st7305->base.draw_bitmap = panel_st7305_draw_bitmap;
|
||||
st7305->base.invert_color = panel_st7305_invert_color;
|
||||
st7305->base.set_gap = panel_st7305_set_gap;
|
||||
st7305->base.mirror = panel_st7305_mirror;
|
||||
st7305->base.swap_xy = panel_st7305_swap_xy;
|
||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
st7305->base.disp_off = panel_st7305_disp_on_off;
|
||||
#else
|
||||
st7305->base.disp_on_off = panel_st7305_disp_on_off;
|
||||
#endif
|
||||
*ret_panel = &(st7305->base);
|
||||
ESP_LOGD(TAG, "new st7305 panel @%p", st7305);
|
||||
|
||||
return ESP_OK;
|
||||
|
||||
err:
|
||||
if (st7305) {
|
||||
if (panel_dev_config->reset_gpio_num >= 0) {
|
||||
gpio_reset_pin(panel_dev_config->reset_gpio_num);
|
||||
}
|
||||
free(st7305);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t panel_st7305_del(esp_lcd_panel_t *panel)
|
||||
{
|
||||
st7305_panel_t *st7305 = __containerof(panel, st7305_panel_t, base);
|
||||
if (st7305->reset_gpio_num >= 0) {
|
||||
gpio_reset_pin(st7305->reset_gpio_num);
|
||||
}
|
||||
free(st7305);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t panel_st7305_reset(esp_lcd_panel_t *panel)
|
||||
{
|
||||
st7305_panel_t *st7305 = __containerof(panel, st7305_panel_t, base);
|
||||
if (st7305->reset_gpio_num >= 0) {
|
||||
gpio_set_level(st7305->reset_gpio_num, !st7305->reset_level);
|
||||
vTaskDelay(pdMS_TO_TICKS(50));
|
||||
gpio_set_level(st7305->reset_gpio_num, st7305->reset_level);
|
||||
vTaskDelay(pdMS_TO_TICKS(20));
|
||||
gpio_set_level(st7305->reset_gpio_num, !st7305->reset_level);
|
||||
vTaskDelay(pdMS_TO_TICKS(50));
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t panel_st7305_init(esp_lcd_panel_t *panel)
|
||||
{
|
||||
st7305_panel_t *st7305 = __containerof(panel, st7305_panel_t, base);
|
||||
esp_lcd_panel_io_handle_t io = st7305->io;
|
||||
|
||||
for (size_t i = 0; i < st7305->init_cmds_size; i++) {
|
||||
if (st7305->init_cmds[i].data_bytes > 0) {
|
||||
esp_lcd_panel_io_tx_param(io, st7305->init_cmds[i].cmd,
|
||||
st7305->init_cmds[i].data,
|
||||
st7305->init_cmds[i].data_bytes);
|
||||
} else {
|
||||
esp_lcd_panel_io_tx_param(io, st7305->init_cmds[i].cmd, NULL, 0);
|
||||
}
|
||||
if (st7305->init_cmds[i].delay_ms > 0) {
|
||||
vTaskDelay(pdMS_TO_TICKS(st7305->init_cmds[i].delay_ms));
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t panel_st7305_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data)
|
||||
{
|
||||
st7305_panel_t *st7305 = __containerof(panel, st7305_panel_t, base);
|
||||
esp_lcd_panel_io_handle_t io = st7305->io;
|
||||
|
||||
// Output buffer size is 15000 bytes (400 * 300 / 8)
|
||||
size_t lcd_buf_size = 15000;
|
||||
uint8_t *temp_buffer = heap_caps_malloc(lcd_buf_size, MALLOC_CAP_DMA);
|
||||
if (!temp_buffer) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
memset(temp_buffer, 0, lcd_buf_size);
|
||||
|
||||
const uint8_t *src = (const uint8_t *)color_data;
|
||||
|
||||
// Convert from vertical-page format (SSD1306-style) to ST7305 landscape 2x4 block format
|
||||
for (int y = 0; y < 300; y++) {
|
||||
int inv_y = 299 - y;
|
||||
int block_y = inv_y >> 2;
|
||||
int local_y = inv_y & 3;
|
||||
|
||||
int src_y_div_8 = y >> 3;
|
||||
int src_y_mod_8 = y & 7;
|
||||
uint8_t src_bit_mask = 1 << src_y_mod_8;
|
||||
|
||||
for (int x = 0; x < 400; x++) {
|
||||
int byte_x = x >> 1;
|
||||
int local_x = x & 1;
|
||||
|
||||
int dest_byte_idx = byte_x * 75 + block_y;
|
||||
int dest_bit_pos = 7 - ((local_y << 1) | local_x);
|
||||
|
||||
int src_byte_idx = 400 * src_y_div_8 + x;
|
||||
|
||||
// Read standard vertical page byte bit
|
||||
bool is_pixel_set = (src[src_byte_idx] & src_bit_mask) != 0;
|
||||
|
||||
// Invert the pixel logic if required, standard:
|
||||
// esp_lvgl_port monochrome transform clears the bit (0) for light/chroma colors
|
||||
// and sets the bit (1) for dark/black.
|
||||
// In ST7305 display RAM, White/Light is 1, Black/Dark is 0.
|
||||
// So we write: 1 (White) if is_pixel_set is false (light), and 0 (Black) if is_pixel_set is true (dark).
|
||||
if (!is_pixel_set) {
|
||||
temp_buffer[dest_byte_idx] |= (1 << dest_bit_pos);
|
||||
} else {
|
||||
temp_buffer[dest_byte_idx] &= ~(1 << dest_bit_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t caset[] = {0x12, 0x2A};
|
||||
uint8_t raset[] = {0x00, 0xC7};
|
||||
|
||||
esp_lcd_panel_io_tx_param(io, ST7305_CMD_CASET, caset, sizeof(caset));
|
||||
esp_lcd_panel_io_tx_param(io, ST7305_CMD_RASET, raset, sizeof(raset));
|
||||
esp_lcd_panel_io_tx_color(io, ST7305_CMD_RAMWR, temp_buffer, lcd_buf_size);
|
||||
|
||||
free(temp_buffer);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t panel_st7305_invert_color(esp_lcd_panel_t *panel, bool invert_color_data)
|
||||
{
|
||||
st7305_panel_t *st7305 = __containerof(panel, st7305_panel_t, base);
|
||||
return esp_lcd_panel_io_tx_param(st7305->io, invert_color_data ? ST7305_CMD_INVON : ST7305_CMD_INVOFF, NULL, 0);
|
||||
}
|
||||
|
||||
static esp_err_t panel_st7305_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y)
|
||||
{
|
||||
st7305_panel_t *st7305 = __containerof(panel, st7305_panel_t, base);
|
||||
esp_lcd_panel_io_handle_t io = st7305->io;
|
||||
if (mirror_x) {
|
||||
st7305->madctl_val |= ST7305_MADCTL_MX;
|
||||
} else {
|
||||
st7305->madctl_val &= ~ST7305_MADCTL_MX;
|
||||
}
|
||||
if (mirror_y) {
|
||||
st7305->madctl_val |= ST7305_MADCTL_MY;
|
||||
} else {
|
||||
st7305->madctl_val &= ~ST7305_MADCTL_MY;
|
||||
}
|
||||
return esp_lcd_panel_io_tx_param(io, ST7305_CMD_MADCTL, &st7305->madctl_val, 1);
|
||||
}
|
||||
|
||||
static esp_err_t panel_st7305_swap_xy(esp_lcd_panel_t *panel, bool swap_axes)
|
||||
{
|
||||
st7305_panel_t *st7305 = __containerof(panel, st7305_panel_t, base);
|
||||
esp_lcd_panel_io_handle_t io = st7305->io;
|
||||
if (swap_axes) {
|
||||
st7305->madctl_val |= ST7305_MADCTL_MV;
|
||||
} else {
|
||||
st7305->madctl_val &= ~ST7305_MADCTL_MV;
|
||||
}
|
||||
return esp_lcd_panel_io_tx_param(io, ST7305_CMD_MADCTL, (uint8_t[]) { st7305->madctl_val }, 1);
|
||||
}
|
||||
|
||||
static esp_err_t panel_st7305_set_gap(esp_lcd_panel_t *panel, int x_gap, int y_gap)
|
||||
{
|
||||
st7305_panel_t *st7305 = __containerof(panel, st7305_panel_t, base);
|
||||
st7305->x_gap = x_gap;
|
||||
st7305->y_gap = y_gap;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t panel_st7305_disp_on_off(esp_lcd_panel_t *panel, bool off)
|
||||
{
|
||||
st7305_panel_t *st7305 = __containerof(panel, st7305_panel_t, base);
|
||||
return esp_lcd_panel_io_tx_param(st7305->io, off ? ST7305_CMD_DISPOFF : ST7305_CMD_DISPON, NULL, 0);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_lcd_types.h"
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int cmd; /*<! The specific LCD command */
|
||||
const void *data; /*<! Buffer that holds the command specific data */
|
||||
size_t data_bytes; /*<! Size of `data` in memory, in bytes */
|
||||
unsigned int delay_ms; /*<! Delay in milliseconds after this command */
|
||||
} st7305_lcd_init_cmd_t;
|
||||
|
||||
typedef struct {
|
||||
const st7305_lcd_init_cmd_t *init_cmds;
|
||||
uint16_t init_cmds_size;
|
||||
} st7305_vendor_config_t;
|
||||
|
||||
#define ST7305_WIDTH 400
|
||||
#define ST7305_HEIGHT 300
|
||||
|
||||
#define ST7305_CMD_NOP 0x00
|
||||
#define ST7305_CMD_SWRESET 0x01
|
||||
#define ST7305_CMD_SLPOUT 0x11
|
||||
#define ST7305_CMD_NORON 0x13
|
||||
#define ST7305_CMD_INVOFF 0x20
|
||||
#define ST7305_CMD_INVON 0x21
|
||||
#define ST7305_CMD_DISPOFF 0x28
|
||||
#define ST7305_CMD_DISPON 0x29
|
||||
#define ST7305_CMD_CASET 0x2A
|
||||
#define ST7305_CMD_RASET 0x2B
|
||||
#define ST7305_CMD_RAMWR 0x2C
|
||||
#define ST7305_CMD_MADCTL 0x36
|
||||
|
||||
#define ST7305_MADCTL_MY 0x80
|
||||
#define ST7305_MADCTL_MX 0x40
|
||||
#define ST7305_MADCTL_MV 0x20
|
||||
#define ST7305_MADCTL_ML 0x10
|
||||
|
||||
esp_err_t esp_lcd_new_panel_st7305(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -18,6 +18,8 @@ endif ()
|
||||
|
||||
set(DEVICETREE_LOCATION "${PROJECT_ROOT}/Devices/${TACTILITY_DEVICE_ID}")
|
||||
|
||||
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
||||
|
||||
# Check if device has Bluetooth enabled
|
||||
# Fixes the sdkconfig bluetooth enable options from getting nuked on non-P4+C6 builds when idf build runs
|
||||
if (DEFINED ENV{ESP_IDF_VERSION})
|
||||
@@ -32,7 +34,7 @@ endif()
|
||||
#
|
||||
|
||||
execute_process(
|
||||
COMMAND python -m pip install lark==1.3.1 pyyaml==6.0.3
|
||||
COMMAND ${Python3_EXECUTABLE} -m pip install --break-system-packages lark==1.3.1 pyyaml==6.0.3
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
)
|
||||
|
||||
@@ -41,7 +43,7 @@ execute_process(
|
||||
#
|
||||
|
||||
execute_process(
|
||||
COMMAND python "${PROJECT_ROOT}/Buildscripts/DevicetreeCompiler/dependencies.py" "${DEVICETREE_LOCATION}"
|
||||
COMMAND ${Python3_EXECUTABLE} "${PROJECT_ROOT}/Buildscripts/DevicetreeCompiler/dependencies.py" "${DEVICETREE_LOCATION}"
|
||||
WORKING_DIRECTORY "${PROJECT_ROOT}"
|
||||
OUTPUT_VARIABLE DEVICE_DEPENDENCIES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
@@ -107,7 +109,7 @@ add_custom_target(AlwaysRun
|
||||
add_custom_command(
|
||||
OUTPUT "${GENERATED_DIR}/devicetree.c"
|
||||
"${GENERATED_DIR}/devicetree.h"
|
||||
COMMAND python "${CMAKE_SOURCE_DIR}/Buildscripts/DevicetreeCompiler/compile.py"
|
||||
COMMAND ${Python3_EXECUTABLE} "${CMAKE_SOURCE_DIR}/Buildscripts/DevicetreeCompiler/compile.py"
|
||||
"${DEVICETREE_LOCATION}" "${GENERATED_DIR}"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
DEPENDS AlwaysRun "${DEVICETREE_LOCATION}/devicetree.yaml" # AlwaysRun ensures it always gets built
|
||||
@@ -119,3 +121,4 @@ set_source_files_properties("${GENERATED_DIR}/devicetree.h" PROPERTIES GENERATED
|
||||
# Update target for generated code
|
||||
target_sources(${COMPONENT_LIB} PRIVATE "${GENERATED_DIR}/devicetree.c")
|
||||
target_include_directories(${COMPONENT_LIB} PRIVATE "${GENERATED_DIR}")
|
||||
add_dependencies(${COMPONENT_LIB} Generated)
|
||||
|
||||
@@ -29,7 +29,6 @@ dependencies:
|
||||
espressif/esp_lcd_touch_ft5x06: "1.0.6~1"
|
||||
espressif/esp_io_expander: "1.0.1"
|
||||
espressif/esp_io_expander_tca95xx_16bit: "1.0.1"
|
||||
espressif/esp_lcd_axs15231b: "2.0.2"
|
||||
lambage/esp_lcd_touch_ft6336u: "1.0.8"
|
||||
espressif/esp_lcd_st7701:
|
||||
version: "1.1.3"
|
||||
@@ -81,5 +80,6 @@ dependencies:
|
||||
version: "1.1.4"
|
||||
rules:
|
||||
- if: "target in [esp32s3, esp32p4]"
|
||||
idf: '5.5.2'
|
||||
espressif/mdns: "*"
|
||||
idf: '>=5.2.0'
|
||||
|
||||
|
||||
@@ -38,9 +38,11 @@
|
||||
#define __QRCODE_H_
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef unsigned char bool;
|
||||
static const bool false = 0;
|
||||
static const bool true = 1;
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
|
||||
// C23 has bool, true, false as standard keywords
|
||||
#else
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -6,7 +6,7 @@ idf_component_register(
|
||||
SRCS ${SOURCES}
|
||||
INCLUDE_DIRS "include/"
|
||||
PRIV_INCLUDE_DIRS "private/"
|
||||
REQUIRES TactilityKernel driver esp_driver_i2c vfs fatfs
|
||||
REQUIRES TactilityKernel driver vfs fatfs
|
||||
)
|
||||
|
||||
idf_component_optional_requires(PRIVATE bt usb espressif__usb_host_hid espressif__usb_host_msc)
|
||||
|
||||
@@ -167,4 +167,11 @@ bool ble_hci_gate_wait_idle(int max_ms);
|
||||
#endif
|
||||
#endif // CONFIG_ESP_HOSTED_ENABLED
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||
|
||||
@@ -815,7 +815,9 @@ static error_t api_scan_start(struct Device* device) {
|
||||
|
||||
struct ble_gap_disc_params disc_params = {};
|
||||
disc_params.passive = 0;
|
||||
disc_params.filter_duplicates = 1;
|
||||
disc_params.filter_duplicates = 0;
|
||||
disc_params.itvl = 160; // 100 ms
|
||||
disc_params.window = 160; // 100 ms
|
||||
|
||||
uint8_t own_addr_type;
|
||||
ble_hs_id_infer_auto(0, &own_addr_type);
|
||||
|
||||
@@ -21,6 +21,14 @@ constexpr auto* TAG = "esp32_ble_scan";
|
||||
// Using BleCtx* (not Device*) so we avoid keeping a static Device reference.
|
||||
static BleCtx* s_scan_ctx = nullptr;
|
||||
|
||||
struct LoggedDevice {
|
||||
ble_addr_t addr;
|
||||
bool has_name;
|
||||
};
|
||||
constexpr size_t MAX_LOGGED_DEVICES = 128;
|
||||
static LoggedDevice s_logged_devices[MAX_LOGGED_DEVICES];
|
||||
static size_t s_logged_count = 0;
|
||||
|
||||
// ---- Scan data helpers ----
|
||||
|
||||
void ble_scan_clear_results(struct Device* device) {
|
||||
@@ -28,6 +36,8 @@ void ble_scan_clear_results(struct Device* device) {
|
||||
xSemaphoreTake(ctx->scan_mutex, portMAX_DELAY);
|
||||
ctx->scan_count = 0;
|
||||
memset(ctx->scan_results, 0, sizeof(ctx->scan_results));
|
||||
s_logged_count = 0;
|
||||
memset(s_logged_devices, 0, sizeof(s_logged_devices));
|
||||
xSemaphoreGive(ctx->scan_mutex);
|
||||
}
|
||||
|
||||
@@ -49,7 +59,8 @@ int ble_gap_disc_event_handler(struct ble_gap_event* event, void* arg) {
|
||||
record.connected = false;
|
||||
|
||||
struct ble_hs_adv_fields fields;
|
||||
if (ble_hs_adv_parse_fields(&fields, disc.data, disc.length_data) == 0) {
|
||||
bool parsed_fields = (ble_hs_adv_parse_fields(&fields, disc.data, disc.length_data) == 0);
|
||||
if (parsed_fields) {
|
||||
if (fields.name != nullptr && fields.name_len > 0) {
|
||||
size_t copy_len = std::min<size_t>(fields.name_len, BT_NAME_MAX);
|
||||
memcpy(record.name, fields.name, copy_len);
|
||||
@@ -57,6 +68,7 @@ int ble_gap_disc_event_handler(struct ble_gap_event* event, void* arg) {
|
||||
}
|
||||
}
|
||||
|
||||
bool should_publish = false;
|
||||
{
|
||||
xSemaphoreTake(ctx->scan_mutex, portMAX_DELAY);
|
||||
bool found = false;
|
||||
@@ -65,32 +77,99 @@ int ble_gap_disc_event_handler(struct ble_gap_event* event, void* arg) {
|
||||
// Deduplicate: merge name from SCAN_RSP without clobbering ADV_IND name
|
||||
if (record.name[0] != '\0') {
|
||||
memcpy(ctx->scan_results[i].name, record.name, BT_NAME_MAX + 1);
|
||||
} else {
|
||||
// If this packet doesn't have a name, keep the previously discovered name
|
||||
memcpy(record.name, ctx->scan_results[i].name, BT_NAME_MAX + 1);
|
||||
}
|
||||
ctx->scan_results[i].rssi = record.rssi;
|
||||
found = true;
|
||||
should_publish = (record.name[0] != '\0');
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found && ctx->scan_count < 64) {
|
||||
if (!found && record.name[0] != '\0' && ctx->scan_count < 64) {
|
||||
ctx->scan_results[ctx->scan_count] = record;
|
||||
ctx->scan_addrs[ctx->scan_count] = disc.addr; // full addr (type+val)
|
||||
ctx->scan_count++;
|
||||
should_publish = true;
|
||||
}
|
||||
xSemaphoreGive(ctx->scan_mutex);
|
||||
}
|
||||
|
||||
// USB Serial logging for unique devices
|
||||
bool logged_already = false;
|
||||
size_t found_idx = 0;
|
||||
for (size_t i = 0; i < s_logged_count; ++i) {
|
||||
if (s_logged_devices[i].addr.type == disc.addr.type &&
|
||||
memcmp(s_logged_devices[i].addr.val, disc.addr.val, BT_ADDR_LEN) == 0) {
|
||||
logged_already = true;
|
||||
found_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool name_updated = false;
|
||||
if (logged_already) {
|
||||
if (!s_logged_devices[found_idx].has_name && record.name[0] != '\0') {
|
||||
s_logged_devices[found_idx].has_name = true;
|
||||
name_updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!logged_already && s_logged_count < MAX_LOGGED_DEVICES) {
|
||||
s_logged_devices[s_logged_count].addr = disc.addr;
|
||||
s_logged_devices[s_logged_count].has_name = (record.name[0] != '\0');
|
||||
s_logged_count++;
|
||||
}
|
||||
|
||||
if (!logged_already || name_updated) {
|
||||
char mac_str[18];
|
||||
snprintf(mac_str, sizeof(mac_str), "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
disc.addr.val[5], disc.addr.val[4], disc.addr.val[3],
|
||||
disc.addr.val[2], disc.addr.val[1], disc.addr.val[0]);
|
||||
|
||||
char extra_info[128] = "";
|
||||
int pos = 0;
|
||||
if (parsed_fields) {
|
||||
if (fields.appearance_is_present) {
|
||||
pos += snprintf(extra_info + pos, sizeof(extra_info) - pos, " App:0x%04x", fields.appearance);
|
||||
}
|
||||
if (fields.num_uuids16 > 0) {
|
||||
pos += snprintf(extra_info + pos, sizeof(extra_info) - pos, " UUID16:%d", (int)fields.num_uuids16);
|
||||
if (fields.uuids16 != nullptr) {
|
||||
uint16_t u16 = fields.uuids16[0].value;
|
||||
pos += snprintf(extra_info + pos, sizeof(extra_info) - pos, "(0x%04x)", (int)u16);
|
||||
}
|
||||
}
|
||||
if (fields.num_uuids128 > 0) {
|
||||
pos += snprintf(extra_info + pos, sizeof(extra_info) - pos, " UUID128:%d", (int)fields.num_uuids128);
|
||||
}
|
||||
if (fields.mfg_data_len > 0) {
|
||||
pos += snprintf(extra_info + pos, sizeof(extra_info) - pos, " Mfg:%d", (int)fields.mfg_data_len);
|
||||
}
|
||||
}
|
||||
LOG_I(TAG, "[BLE SCAN] Unique Device: MAC=%s RSSI=%d Name=%s%s%s",
|
||||
mac_str, (int)record.rssi, record.name[0] ? record.name : "<null>",
|
||||
extra_info, name_updated ? " (Name Updated)" : "");
|
||||
}
|
||||
|
||||
if (should_publish) {
|
||||
struct BtEvent e = {};
|
||||
e.type = BT_EVENT_PEER_FOUND;
|
||||
e.peer = record;
|
||||
ble_publish_event(device, e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BLE_GAP_EVENT_DISC_COMPLETE:
|
||||
LOG_I(TAG, "Scan complete (reason=%d)", event->disc_complete.reason);
|
||||
// Keep scan_active=true; resolveNextUnnamedPeer clears it and fires ScanFinished
|
||||
// once name resolution finishes, so the UI spinner stays active throughout.
|
||||
ble_resolve_next_unnamed_peer(device, 0);
|
||||
ble_set_scan_active(device, false);
|
||||
{
|
||||
struct BtEvent e = {};
|
||||
e.type = BT_EVENT_SCAN_FINISHED;
|
||||
ble_publish_event(device, e);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#include <driver/gpio.h>
|
||||
#include <soc/soc.h>
|
||||
#include <soc/gpio_periph.h>
|
||||
#include <soc/gpio_struct.h>
|
||||
#include <soc/io_mux_reg.h>
|
||||
|
||||
#include <tactility/driver.h>
|
||||
#include <tactility/drivers/esp32_gpio.h>
|
||||
@@ -65,30 +69,34 @@ static error_t set_flags(GpioDescriptor* descriptor, gpio_flags_t flags) {
|
||||
}
|
||||
|
||||
static error_t get_flags(GpioDescriptor* descriptor, gpio_flags_t* flags) {
|
||||
gpio_io_config_t esp_config;
|
||||
if (gpio_get_io_config(static_cast<gpio_num_t>(descriptor->pin), &esp_config) != ESP_OK) {
|
||||
return ERROR_RESOURCE;
|
||||
}
|
||||
|
||||
auto pin = static_cast<gpio_num_t>(descriptor->pin);
|
||||
gpio_flags_t output = 0;
|
||||
|
||||
if (esp_config.pu) {
|
||||
// Read pull-up, pull-down, input-enable from IO MUX register
|
||||
uint32_t pin_mux = REG_READ(GPIO_PIN_MUX_REG[pin]);
|
||||
if (pin_mux & FUN_PU) {
|
||||
output |= GPIO_FLAG_PULL_UP;
|
||||
}
|
||||
|
||||
if (esp_config.pd) {
|
||||
if (pin_mux & FUN_PD) {
|
||||
output |= GPIO_FLAG_PULL_DOWN;
|
||||
}
|
||||
|
||||
if (esp_config.ie) {
|
||||
if (pin_mux & FUN_IE) {
|
||||
output |= GPIO_FLAG_DIRECTION_INPUT;
|
||||
}
|
||||
|
||||
if (esp_config.oe) {
|
||||
// Read output-enable from GPIO matrix
|
||||
bool oe = false;
|
||||
if (pin < 32) {
|
||||
oe = (GPIO.enable & (1UL << pin)) != 0;
|
||||
} else {
|
||||
oe = (GPIO.enable1.data & (1UL << (pin - 32))) != 0;
|
||||
}
|
||||
if (oe) {
|
||||
output |= GPIO_FLAG_DIRECTION_OUTPUT;
|
||||
}
|
||||
|
||||
if (esp_config.oe_inv) {
|
||||
// Read output-inversion from GPIO matrix
|
||||
if (GPIO.func_out_sel_cfg[pin].inv_sel) {
|
||||
output |= GPIO_FLAG_ACTIVE_LOW;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <driver/i2c_master.h>
|
||||
|
||||
#include <new>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <tactility/error_esp32.h>
|
||||
#include <tactility/driver.h>
|
||||
@@ -39,12 +41,48 @@ struct Esp32I2cMasterInternal {
|
||||
#define lock(data) mutex_lock(&data->mutex);
|
||||
#define unlock(data) mutex_unlock(&data->mutex);
|
||||
|
||||
struct MyI2cMasterDev {
|
||||
void* master_bus;
|
||||
uint16_t device_address;
|
||||
};
|
||||
|
||||
static esp_err_t my_i2c_master_device_change_address(i2c_master_dev_handle_t i2c_dev, uint16_t new_device_address, int timeout_ms) {
|
||||
if (i2c_dev == nullptr) return ESP_ERR_INVALID_ARG;
|
||||
auto* dev = reinterpret_cast<MyI2cMasterDev*>(i2c_dev);
|
||||
dev->device_address = new_device_address;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t my_i2c_master_transmit_multi_buffer(i2c_master_dev_handle_t dev_handle, uint8_t reg, const uint8_t* data, uint16_t data_size, int timeout_ms) {
|
||||
uint32_t total_size = data_size + 1;
|
||||
if (total_size <= 128) {
|
||||
uint8_t temp_buf[128];
|
||||
temp_buf[0] = reg;
|
||||
if (data_size > 0 && data != nullptr) {
|
||||
std::memcpy(temp_buf + 1, data, data_size);
|
||||
}
|
||||
return i2c_master_transmit(dev_handle, temp_buf, total_size, timeout_ms);
|
||||
} else {
|
||||
uint8_t* temp_buf = (uint8_t*)std::malloc(total_size);
|
||||
if (temp_buf == nullptr) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
temp_buf[0] = reg;
|
||||
if (data_size > 0 && data != nullptr) {
|
||||
std::memcpy(temp_buf + 1, data, data_size);
|
||||
}
|
||||
esp_err_t ret = i2c_master_transmit(dev_handle, temp_buf, total_size, timeout_ms);
|
||||
std::free(temp_buf);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
// Switches the device's target address only when it differs from the currently configured one.
|
||||
static esp_err_t ensure_address(Esp32I2cMasterInternal* driver_data, uint8_t address, int timeout_ms) {
|
||||
if (driver_data->current_address == address) {
|
||||
return ESP_OK;
|
||||
}
|
||||
esp_err_t esp_error = i2c_master_device_change_address(driver_data->dev_handle, address, timeout_ms);
|
||||
esp_err_t esp_error = my_i2c_master_device_change_address(driver_data->dev_handle, address, timeout_ms);
|
||||
if (esp_error == ESP_OK) {
|
||||
driver_data->current_address = address;
|
||||
}
|
||||
@@ -149,11 +187,7 @@ static error_t write_register(Device* device, uint8_t address, uint8_t reg, cons
|
||||
if (esp_error != ESP_OK) {
|
||||
LOG_E(TAG, "change_address(0x%02X) failed: %s", address, esp_err_to_name(esp_error));
|
||||
} else {
|
||||
i2c_master_transmit_multi_buffer_info_t buffers[2] = {
|
||||
{.write_buffer = ®, .buffer_size = 1},
|
||||
{.write_buffer = data, .buffer_size = data_size}
|
||||
};
|
||||
esp_error = i2c_master_multi_buffer_transmit(driver_data->dev_handle, buffers, 2, timeout_ms);
|
||||
esp_error = my_i2c_master_transmit_multi_buffer(driver_data->dev_handle, reg, data, data_size, timeout_ms);
|
||||
if (esp_error != ESP_OK) {
|
||||
LOG_E(TAG, "write_register(0x%02X, reg=0x%02X) failed: %s", address, reg, esp_err_to_name(esp_error));
|
||||
}
|
||||
@@ -212,7 +246,6 @@ static error_t start(Device* device) {
|
||||
.trans_queue_depth = 0,
|
||||
.flags = {
|
||||
.enable_internal_pullup = ((sda_spec.flags & GPIO_FLAG_PULL_UP) != 0) || ((scl_spec.flags & GPIO_FLAG_PULL_UP) != 0),
|
||||
.allow_pd = 0,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -307,7 +340,7 @@ extern Module platform_esp32_module;
|
||||
|
||||
Driver esp32_i2c_master_driver = {
|
||||
.name = "esp32_i2c_master",
|
||||
.compatible = (const char*[]) { "espressif,esp32-i2c-master", nullptr },
|
||||
.compatible = (const char*[]) { "espressif,esp32-i2c", "espressif,esp32-i2c-master", nullptr },
|
||||
.start_device = start,
|
||||
.stop_device = stop,
|
||||
.api = &ESP32_I2C_MASTER_API,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <tactility/drivers/esp32_i2s.h>
|
||||
|
||||
#include <new>
|
||||
#include <cstring>
|
||||
|
||||
#define TAG "esp32_i2s"
|
||||
|
||||
@@ -112,13 +113,19 @@ static i2s_data_bit_width_t to_esp32_bits_per_sample(uint8_t bits) {
|
||||
}
|
||||
|
||||
static void get_esp32_std_config(Esp32I2sInternal* internal, const I2sConfig* config, i2s_std_config_t* std_cfg) {
|
||||
i2s_slot_mode_t slot_mode = I2S_SLOT_MODE_STEREO;
|
||||
if ((config->channel_left != I2S_CHANNEL_NONE && config->channel_right == I2S_CHANNEL_NONE) ||
|
||||
(config->channel_left == I2S_CHANNEL_NONE && config->channel_right != I2S_CHANNEL_NONE)) {
|
||||
slot_mode = I2S_SLOT_MODE_MONO;
|
||||
}
|
||||
|
||||
std_cfg->clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(config->sample_rate);
|
||||
std_cfg->slot_cfg = I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG(to_esp32_bits_per_sample(config->bits_per_sample), I2S_SLOT_MODE_STEREO);
|
||||
std_cfg->slot_cfg = I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG(to_esp32_bits_per_sample(config->bits_per_sample), slot_mode);
|
||||
|
||||
if (config->communication_format & I2S_FORMAT_STAND_MSB) {
|
||||
std_cfg->slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(to_esp32_bits_per_sample(config->bits_per_sample), I2S_SLOT_MODE_STEREO);
|
||||
std_cfg->slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(to_esp32_bits_per_sample(config->bits_per_sample), slot_mode);
|
||||
} else if (config->communication_format & (I2S_FORMAT_STAND_PCM_SHORT | I2S_FORMAT_STAND_PCM_LONG)) {
|
||||
std_cfg->slot_cfg = I2S_STD_PCM_SLOT_DEFAULT_CONFIG(to_esp32_bits_per_sample(config->bits_per_sample), I2S_SLOT_MODE_STEREO);
|
||||
std_cfg->slot_cfg = I2S_STD_PCM_SLOT_DEFAULT_CONFIG(to_esp32_bits_per_sample(config->bits_per_sample), slot_mode);
|
||||
}
|
||||
|
||||
if (config->channel_left != I2S_CHANNEL_NONE && config->channel_right == I2S_CHANNEL_NONE) {
|
||||
|
||||
@@ -9,11 +9,17 @@
|
||||
#include <tactility/log.h>
|
||||
|
||||
#include <driver/sdmmc_host.h>
|
||||
#include <driver/gpio.h>
|
||||
#include <esp_vfs_fat.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
#include <sdmmc_cmd.h>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
#ifndef SDMMC_SLOT_FLAG_UHS1
|
||||
#define SDMMC_SLOT_FLAG_UHS1 0
|
||||
#endif
|
||||
|
||||
#if SOC_SD_PWR_CTRL_SUPPORTED
|
||||
#include <sd_pwr_ctrl_by_on_chip_ldo.h>
|
||||
@@ -103,15 +109,33 @@ static error_t mount(void* data) {
|
||||
uint32_t slot_config_flags = 0;
|
||||
if (config->enable_uhs) slot_config_flags |= SDMMC_SLOT_FLAG_UHS1;
|
||||
if (config->wp_active_high) slot_config_flags |= SDMMC_SLOT_FLAG_WP_ACTIVE_HIGH;
|
||||
if (config->pullups) slot_config_flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;
|
||||
|
||||
gpio_num_t clk_pin = to_native_pin(config->pin_clk);
|
||||
gpio_num_t cmd_pin = to_native_pin(config->pin_cmd);
|
||||
gpio_num_t d0_pin = to_native_pin(config->pin_d0);
|
||||
gpio_num_t d3_pin = to_native_pin(config->pin_d3);
|
||||
|
||||
// Manually enable pull-ups on CMD, D0, and D3 if pullups configuration is true
|
||||
// This avoids pulling up the CLK line which can cause clock signal distortion
|
||||
if (config->pullups) {
|
||||
if (cmd_pin != GPIO_NUM_NC) {
|
||||
gpio_pullup_en(cmd_pin);
|
||||
}
|
||||
if (d0_pin != GPIO_NUM_NC) {
|
||||
gpio_pullup_en(d0_pin);
|
||||
}
|
||||
if (d3_pin != GPIO_NUM_NC) {
|
||||
gpio_pullup_en(d3_pin);
|
||||
}
|
||||
}
|
||||
|
||||
sdmmc_slot_config_t slot_config = {
|
||||
.clk = to_native_pin(config->pin_clk),
|
||||
.cmd = to_native_pin(config->pin_cmd),
|
||||
.d0 = to_native_pin(config->pin_d0),
|
||||
.clk = clk_pin,
|
||||
.cmd = cmd_pin,
|
||||
.d0 = d0_pin,
|
||||
.d1 = to_native_pin(config->pin_d1),
|
||||
.d2 = to_native_pin(config->pin_d2),
|
||||
.d3 = to_native_pin(config->pin_d3),
|
||||
.d3 = d3_pin,
|
||||
.d4 = to_native_pin(config->pin_d4),
|
||||
.d5 = to_native_pin(config->pin_d5),
|
||||
.d6 = to_native_pin(config->pin_d6),
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <esp_vfs_fat.h>
|
||||
#include <sdmmc_cmd.h>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
#define TAG "esp32_sdspi_fs"
|
||||
|
||||
|
||||
@@ -110,7 +110,6 @@ static error_t start(Device* device) {
|
||||
.data5_io_num = GPIO_NUM_NC,
|
||||
.data6_io_num = GPIO_NUM_NC,
|
||||
.data7_io_num = GPIO_NUM_NC,
|
||||
.data_io_default_level = false,
|
||||
.max_transfer_sz = dts_config->max_transfer_size,
|
||||
.flags = 0,
|
||||
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <tactility/drivers/esp32_gpio_helpers.h>
|
||||
|
||||
#include <new>
|
||||
#include <cstring>
|
||||
|
||||
#define TAG "esp32_uart"
|
||||
|
||||
@@ -264,10 +265,6 @@ static error_t open(Device* device) {
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, // Flow control is not yet exposed via UartConfig
|
||||
.rx_flow_ctrl_thresh = 0,
|
||||
.source_clk = UART_SCLK_DEFAULT,
|
||||
.flags = {
|
||||
.allow_pd = 0,
|
||||
.backup_before_sleep = 0
|
||||
}
|
||||
};
|
||||
|
||||
if (dts_config->pin_cts.gpio_controller != nullptr || dts_config->pin_rts.gpio_controller != nullptr) {
|
||||
|
||||
@@ -70,8 +70,6 @@ static error_t start_device(struct Device* device) {
|
||||
.root_port_unpowered = false,
|
||||
.intr_flags = ESP_INTR_FLAG_LEVEL1,
|
||||
.enum_filter_cb = nullptr,
|
||||
.fifo_settings_custom = {},
|
||||
.peripheral_map = cfg->peripheral_map,
|
||||
};
|
||||
|
||||
esp_err_t ret = usb_host_install(&host_cfg);
|
||||
|
||||
@@ -26,6 +26,7 @@ if (DEFINED ENV{ESP_IDF_VERSION})
|
||||
esp_http_client
|
||||
esp-tls
|
||||
esp_wifi
|
||||
mdns
|
||||
json # Effectively cJSON
|
||||
nvs_flash
|
||||
spiffs
|
||||
|
||||
@@ -26,6 +26,12 @@ void statusbar_icon_set_image(int8_t id, const std::string& image);
|
||||
/** Update the visibility for an icon on the statusbar. Does not need to be called with LVGL lock. */
|
||||
void statusbar_icon_set_visibility(int8_t id, bool visible);
|
||||
|
||||
/** Set the battery text. Does not need to be called with LVGL lock. */
|
||||
void statusbar_set_battery_text(const std::string& text);
|
||||
|
||||
/** Set the battery text visibility. Does not need to be called with LVGL lock. */
|
||||
void statusbar_set_battery_visibility(bool visible);
|
||||
|
||||
int statusbar_get_height();
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -18,6 +18,7 @@ enum class ScreensaverType {
|
||||
Mystify,
|
||||
MatrixRain,
|
||||
StackChan,
|
||||
McpScreen, // MCP LLM-driven canvas
|
||||
Count // Sentinel for bounds checking - must be last
|
||||
};
|
||||
|
||||
@@ -28,6 +29,7 @@ struct DisplaySettings {
|
||||
bool backlightTimeoutEnabled;
|
||||
uint32_t backlightTimeoutMs; // 0 = Never
|
||||
ScreensaverType screensaverType = ScreensaverType::BouncingBalls;
|
||||
bool disableScreensaverWhenCharging = false;
|
||||
};
|
||||
|
||||
/** Compares default settings with the function parameter to return the difference */
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
namespace tt::settings::mcp {
|
||||
|
||||
struct McpSettings {
|
||||
bool mcpEnabled = false; // Enable MCP server endpoints on system web server
|
||||
};
|
||||
|
||||
bool load(McpSettings& settings);
|
||||
McpSettings getDefault();
|
||||
McpSettings loadOrGetDefault();
|
||||
bool save(const McpSettings& settings);
|
||||
|
||||
} // namespace tt::settings::mcp
|
||||
@@ -7,5 +7,6 @@ namespace tt::app::files {
|
||||
bool isSupportedAppFile(const std::string& filename);
|
||||
bool isSupportedImageFile(const std::string& filename);
|
||||
bool isSupportedTextFile(const std::string& filename);
|
||||
bool isSupportedAudioFile(const std::string& filename);
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#pragma once
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <tactility/device.h>
|
||||
|
||||
namespace tt::mcp {
|
||||
|
||||
struct McpSystemState {
|
||||
std::mutex mutex;
|
||||
bool overrideActive = false;
|
||||
|
||||
// UI elements when McpOverrideApp is active
|
||||
lv_obj_t* drawArea = nullptr;
|
||||
uint16_t* framebuffer = nullptr;
|
||||
size_t framebufferSize = 0;
|
||||
uint16_t displayWidth = 320;
|
||||
uint16_t displayHeight = 240;
|
||||
uint16_t drawWidth = 320;
|
||||
uint16_t drawHeight = 240;
|
||||
int drawColor = 1; // 0 = white, 1 = black
|
||||
|
||||
// Audio device status
|
||||
Device* i2sDevice = nullptr;
|
||||
volatile bool audioBusy = false;
|
||||
volatile bool audioRunning = false; // Used to abort play/record loop
|
||||
|
||||
// Video streaming state
|
||||
volatile bool streamRunning = false;
|
||||
void* streamTaskHandle = nullptr; // use void* to avoid freertos header inclusion dependency
|
||||
uint32_t framesDrawn = 0;
|
||||
uint32_t tcpBytesReceived = 0;
|
||||
uint32_t lastDrawMs = 0;
|
||||
double lastFps = 0.0;
|
||||
};
|
||||
|
||||
McpSystemState& getState();
|
||||
|
||||
bool clearScreen(int color);
|
||||
bool drawText(const std::string& text, int x, int y, int size);
|
||||
bool drawRgb565(const uint8_t* data, size_t size, int x, int y, int w, int h);
|
||||
bool drawBmp(const uint8_t* data, size_t size, int x, int y);
|
||||
bool drawPbm(const uint8_t* data, size_t size, int x, int y);
|
||||
std::string getScreenshotPbmBase64();
|
||||
|
||||
bool playTone(int frequency, int durationMs, int volume, std::string& error);
|
||||
bool recordVoice(int durationSec, const std::string& filename, size_t& recordedBytes, std::string& error);
|
||||
bool playAudioFile(const std::string& filename, int volume, std::string& error);
|
||||
bool playWavMemory(const uint8_t* data, size_t size, int volume, std::string& error);
|
||||
bool playMp3File(const std::string& filename, int volume, std::string& error);
|
||||
bool playMp3Memory(const uint8_t* data, size_t size, int volume, std::string& error);
|
||||
|
||||
bool getBatteryStatus(double& voltage_v, int& percentage_pct, std::string& error);
|
||||
bool setLedColor(int r, int g, int b, const std::string& mode, std::string& error);
|
||||
bool getSensors(double& temp_c, double& hum_pct, std::string& imu_json, std::string& error);
|
||||
bool scanBleDevices(int duration_ms, std::string& devices_json, std::string& error);
|
||||
bool writeSdFile(const std::string& filename, const std::string& content, std::string& error);
|
||||
bool readSdFile(const std::string& filename, std::string& content, std::string& error);
|
||||
bool downloadSdFile(const std::string& url, const std::string& filename, std::string& error);
|
||||
|
||||
bool startVideoStreamServer();
|
||||
void stopVideoStreamServer();
|
||||
bool getVideoStreamStats(std::string& stats_json);
|
||||
|
||||
bool listApps(std::string& apps_json, std::string& error);
|
||||
bool runApp(const std::string& appId, std::string& error);
|
||||
bool listSdFiles(const std::string& directory, std::string& files_json, std::string& error);
|
||||
|
||||
} // namespace tt::mcp
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -43,7 +43,8 @@ class DevelopmentService final : public Service {
|
||||
.handler = handleAppUninstall,
|
||||
.user_ctx = this
|
||||
}
|
||||
}
|
||||
},
|
||||
8192
|
||||
);
|
||||
|
||||
void startServer();
|
||||
|
||||
@@ -37,6 +37,7 @@ class DisplayIdleService final : public Service {
|
||||
bool backlightOff = false;
|
||||
|
||||
static void stopScreensaverCb(lv_event_t* e);
|
||||
void stopScreensaverLocked();
|
||||
|
||||
/** @pre Caller must hold LVGL lock */
|
||||
void activateScreensaver();
|
||||
@@ -57,6 +58,12 @@ public:
|
||||
*/
|
||||
void startScreensaver();
|
||||
|
||||
/**
|
||||
* Force the MCP screensaver specifically, regardless of the current
|
||||
* screensaver type setting. Safe to call from any thread (acquires LVGL lock).
|
||||
*/
|
||||
void startMcpScreensaver();
|
||||
|
||||
/**
|
||||
* Force the screensaver to stop immediately and restore backlight.
|
||||
* @note Not thread-safe. Call from LVGL/main context only, not from
|
||||
|
||||
@@ -76,6 +76,8 @@ private:
|
||||
static esp_err_t handleApiAppsInstall(httpd_req_t* request);
|
||||
static esp_err_t handleApiWifi(httpd_req_t* request);
|
||||
static esp_err_t handleApiScreenshot(httpd_req_t* request);
|
||||
static esp_err_t handleApiMcp(httpd_req_t* request);
|
||||
static esp_err_t handleApiScreenRaw(httpd_req_t* request);
|
||||
|
||||
// Dynamic asset serving
|
||||
static esp_err_t handleAssets(httpd_req_t* request);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <Tactility/PartitionsEsp.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <cstring>
|
||||
|
||||
#include <esp_vfs_fat.h>
|
||||
#include <nvs_flash.h>
|
||||
|
||||
@@ -120,6 +120,7 @@ namespace app {
|
||||
namespace apwebserver { extern const AppManifest manifest; }
|
||||
namespace crashdiagnostics { extern const AppManifest manifest; }
|
||||
namespace webserversettings { extern const AppManifest manifest; }
|
||||
namespace mcpsettings { extern const AppManifest manifest; }
|
||||
#if CONFIG_TT_TDECK_WORKAROUND == 1
|
||||
namespace keyboardsettings { extern const AppManifest manifest; } // T-Deck only for now
|
||||
namespace trackballsettings { extern const AppManifest manifest; } // T-Deck only for now
|
||||
@@ -170,6 +171,7 @@ static void registerInternalApps() {
|
||||
#ifdef ESP_PLATFORM
|
||||
addAppManifest(app::apwebserver::manifest);
|
||||
addAppManifest(app::webserversettings::manifest);
|
||||
addAppManifest(app::mcpsettings::manifest);
|
||||
addAppManifest(app::crashdiagnostics::manifest);
|
||||
addAppManifest(app::development::manifest);
|
||||
#if defined(CONFIG_TT_TDECK_WORKAROUND)
|
||||
@@ -337,9 +339,22 @@ void run(const Configuration& config, Module* dtsModules[], DtsDevice dtsDevices
|
||||
#ifdef ESP_PLATFORM
|
||||
initEsp();
|
||||
#endif
|
||||
file::setFindLockFunction(file::findLock);
|
||||
settings::initTimeZone();
|
||||
hal::init(*config.hardware);
|
||||
|
||||
LOGGER.info("DEBUG: Listing /sdcard");
|
||||
file::listDirectory("/sdcard", [](const dirent& entry) {
|
||||
LOGGER.info("DEBUG: /sdcard entry: {} (dir={})", entry.d_name, entry.d_type == DT_DIR);
|
||||
});
|
||||
if (file::isDirectory("/sdcard/app")) {
|
||||
LOGGER.info("DEBUG: Listing /sdcard/app");
|
||||
file::listDirectory("/sdcard/app", [](const dirent& entry) {
|
||||
LOGGER.info("DEBUG: /sdcard/app entry: {}", entry.d_name);
|
||||
});
|
||||
} else {
|
||||
LOGGER.info("DEBUG: /sdcard/app is NOT a directory");
|
||||
}
|
||||
|
||||
network::ntp::init();
|
||||
bluetooth::systemStart();
|
||||
|
||||
|
||||
@@ -10,8 +10,19 @@
|
||||
|
||||
constexpr auto* TAG = "Tactility";
|
||||
|
||||
#include <cJSON.h>
|
||||
#include <esp_heap_caps.h>
|
||||
|
||||
namespace tt {
|
||||
|
||||
static void* cjson_psram_malloc(size_t size) {
|
||||
return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
||||
}
|
||||
|
||||
static void cjson_psram_free(void* ptr) {
|
||||
heap_caps_free(ptr);
|
||||
}
|
||||
|
||||
static void initNetwork() {
|
||||
LOG_I(TAG, "Init network");
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
@@ -19,6 +30,13 @@ static void initNetwork() {
|
||||
}
|
||||
|
||||
void initEsp() {
|
||||
cJSON_Hooks hooks = {
|
||||
.malloc_fn = cjson_psram_malloc,
|
||||
.free_fn = cjson_psram_free
|
||||
};
|
||||
cJSON_InitHooks(&hooks);
|
||||
LOG_I(TAG, "cJSON hooks initialized to use PSRAM");
|
||||
|
||||
check(initPartitionsEsp(), "Failed to init partitions");
|
||||
initNetwork();
|
||||
}
|
||||
|
||||
@@ -35,9 +35,7 @@ static bool untarFile(minitar* mp, const minitar_entry* entry, const std::string
|
||||
}
|
||||
|
||||
// Note: fchmod() doesn't exist on ESP-IDF and chmod() does nothing on that platform
|
||||
if (chmod(absolute_path.c_str(), entry->metadata.mode) < 0) {
|
||||
return false;
|
||||
}
|
||||
chmod(absolute_path.c_str(), entry->metadata.mode);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ class DisplayApp final : public App {
|
||||
lv_obj_t* timeoutSwitch = nullptr;
|
||||
lv_obj_t* timeoutDropdown = nullptr;
|
||||
lv_obj_t* screensaverDropdown = nullptr;
|
||||
lv_obj_t* disableWhenChargingWrapper = nullptr;
|
||||
lv_obj_t* disableWhenChargingSwitch = nullptr;
|
||||
|
||||
static void onBacklightSliderEvent(lv_event_t* event) {
|
||||
auto* slider = static_cast<lv_obj_t*>(lv_event_get_target(event));
|
||||
@@ -95,14 +97,28 @@ class DisplayApp final : public App {
|
||||
if (app->screensaverDropdown) {
|
||||
lv_obj_clear_state(app->screensaverDropdown, LV_STATE_DISABLED);
|
||||
}
|
||||
if (app->disableWhenChargingWrapper) {
|
||||
lv_obj_clear_state(app->disableWhenChargingWrapper, LV_STATE_DISABLED);
|
||||
}
|
||||
} else {
|
||||
lv_obj_add_state(app->timeoutDropdown, LV_STATE_DISABLED);
|
||||
if (app->screensaverDropdown) {
|
||||
lv_obj_add_state(app->screensaverDropdown, LV_STATE_DISABLED);
|
||||
}
|
||||
if (app->disableWhenChargingWrapper) {
|
||||
lv_obj_add_state(app->disableWhenChargingWrapper, LV_STATE_DISABLED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void onDisableWhenChargingChanged(lv_event_t* event) {
|
||||
auto* app = static_cast<DisplayApp*>(lv_event_get_user_data(event));
|
||||
auto* sw = static_cast<lv_obj_t*>(lv_event_get_target(event));
|
||||
bool enabled = lv_obj_has_state(sw, LV_STATE_CHECKED);
|
||||
app->displaySettings.disableScreensaverWhenCharging = enabled;
|
||||
app->displaySettingsUpdated = true;
|
||||
}
|
||||
|
||||
static void onTimeoutChanged(lv_event_t* event) {
|
||||
auto* app = static_cast<DisplayApp*>(lv_event_get_user_data(event));
|
||||
@@ -286,13 +302,34 @@ public:
|
||||
|
||||
screensaverDropdown = lv_dropdown_create(screensaver_wrapper);
|
||||
// Note: order correlates with settings::display::ScreensaverType enum order
|
||||
lv_dropdown_set_options(screensaverDropdown, "None\nBouncing Balls\nMystify\nMatrix Rain\nStackChan");
|
||||
lv_dropdown_set_options(screensaverDropdown, "None\nBouncing Balls\nMystify\nMatrix Rain\nStackChan\nMCP Screen");
|
||||
|
||||
lv_obj_align(screensaverDropdown, LV_ALIGN_RIGHT_MID, 0, 0);
|
||||
lv_obj_add_event_cb(screensaverDropdown, onScreensaverChanged, LV_EVENT_VALUE_CHANGED, this);
|
||||
lv_dropdown_set_selected(screensaverDropdown, static_cast<uint16_t>(displaySettings.screensaverType));
|
||||
if (!displaySettings.backlightTimeoutEnabled) {
|
||||
lv_obj_add_state(screensaverDropdown, LV_STATE_DISABLED);
|
||||
}
|
||||
|
||||
// Disable screensaver when charging toggle
|
||||
disableWhenChargingWrapper = lv_obj_create(main_wrapper);
|
||||
lv_obj_set_size(disableWhenChargingWrapper, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
lv_obj_set_style_pad_all(disableWhenChargingWrapper, 0, LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_border_width(disableWhenChargingWrapper, 0, LV_STATE_DEFAULT);
|
||||
|
||||
auto* charging_label = lv_label_create(disableWhenChargingWrapper);
|
||||
lv_label_set_text(charging_label, "Disable on charging");
|
||||
lv_obj_align(charging_label, LV_ALIGN_LEFT_MID, 0, 0);
|
||||
|
||||
disableWhenChargingSwitch = lv_switch_create(disableWhenChargingWrapper);
|
||||
if (displaySettings.disableScreensaverWhenCharging) {
|
||||
lv_obj_add_state(disableWhenChargingSwitch, LV_STATE_CHECKED);
|
||||
}
|
||||
lv_obj_align(disableWhenChargingSwitch, LV_ALIGN_RIGHT_MID, 0, 0);
|
||||
lv_obj_add_event_cb(disableWhenChargingSwitch, onDisableWhenChargingChanged, LV_EVENT_VALUE_CHANGED, this);
|
||||
if (!displaySettings.backlightTimeoutEnabled) {
|
||||
lv_obj_add_state(disableWhenChargingWrapper, LV_STATE_DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasCalibratableTouchDevice()) {
|
||||
|
||||
@@ -10,8 +10,10 @@ bool isSupportedAppFile(const std::string& filename) {
|
||||
}
|
||||
|
||||
bool isSupportedImageFile(const std::string& filename) {
|
||||
// Currently only the PNG library is built into Tactility
|
||||
return string::lowercase(filename).ends_with(".png");
|
||||
std::string filename_lower = string::lowercase(filename);
|
||||
return filename_lower.ends_with(".png") ||
|
||||
filename_lower.ends_with(".jpg") ||
|
||||
filename_lower.ends_with(".jpeg");
|
||||
}
|
||||
|
||||
bool isSupportedTextFile(const std::string& filename) {
|
||||
@@ -26,4 +28,9 @@ bool isSupportedTextFile(const std::string& filename) {
|
||||
filename_lower.ends_with(".properties");
|
||||
}
|
||||
|
||||
bool isSupportedAudioFile(const std::string& filename) {
|
||||
std::string filename_lower = string::lowercase(filename);
|
||||
return filename_lower.ends_with(".mp3");
|
||||
}
|
||||
|
||||
} // namespace tt::app::filebrowser
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <Tactility/app/imageviewer/ImageViewer.h>
|
||||
#include <Tactility/app/inputdialog/InputDialog.h>
|
||||
#include <Tactility/app/notes/Notes.h>
|
||||
#include <Tactility/app/App.h>
|
||||
#include <Tactility/Bundle.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/kernel/Platform.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
@@ -233,6 +235,10 @@ void View::viewFile(const std::string& path, const std::string& filename) {
|
||||
// Remove forward slash, because we need a relative path
|
||||
notes::start(processed_filepath.substr(1));
|
||||
}
|
||||
} else if (isSupportedAudioFile(filename)) {
|
||||
auto parameters = std::make_shared<Bundle>();
|
||||
parameters->putString("file", processed_filepath);
|
||||
app::start("one.tactility.mp3player", parameters);
|
||||
} else {
|
||||
LOGGER.warn("Opening files of this type is not supported");
|
||||
}
|
||||
|
||||
@@ -49,6 +49,16 @@ class LauncherApp final : public App {
|
||||
lv_obj_set_style_shadow_width(apps_button, 0, LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_opa(apps_button, 0, LV_STATE_DEFAULT);
|
||||
|
||||
// Add a high-contrast focus outline for monochrome / RLCD screens
|
||||
lv_obj_set_style_outline_width(apps_button, 2, LV_STATE_FOCUSED);
|
||||
lv_obj_set_style_outline_pad(apps_button, 2, LV_STATE_FOCUSED);
|
||||
lv_obj_set_style_outline_color(apps_button, lv_theme_get_color_primary(apps_button), LV_STATE_FOCUSED);
|
||||
|
||||
auto* default_group = lv_group_get_default();
|
||||
if (default_group) {
|
||||
lv_group_add_obj(default_group, apps_button);
|
||||
}
|
||||
|
||||
// create the image first
|
||||
auto* button_image = lv_image_create(apps_button);
|
||||
lv_obj_set_style_text_font(button_image, lvgl_get_launcher_icon_font(), LV_STATE_DEFAULT);
|
||||
@@ -162,7 +172,11 @@ public:
|
||||
}
|
||||
|
||||
void onShow(AppContext& app, lv_obj_t* parent) override {
|
||||
// Remove click-focusable flag from parent container to prevent it from stealing focus
|
||||
lv_obj_remove_flag(parent, LV_OBJ_FLAG_CLICK_FOCUSABLE);
|
||||
|
||||
auto* buttons_wrapper = lv_obj_create(parent);
|
||||
lv_obj_remove_flag(buttons_wrapper, LV_OBJ_FLAG_CLICK_FOCUSABLE);
|
||||
|
||||
auto ui_density = lvgl_get_ui_density();
|
||||
const auto button_size = lvgl_get_launcher_icon_font_height();
|
||||
@@ -209,6 +223,16 @@ public:
|
||||
lv_obj_set_style_shadow_width(power_button, 0, LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_opa(power_button, 0, LV_PART_MAIN);
|
||||
|
||||
// Add high-contrast focus outline for monochrome / RLCD screens
|
||||
lv_obj_set_style_outline_width(power_button, 2, LV_STATE_FOCUSED);
|
||||
lv_obj_set_style_outline_pad(power_button, 2, LV_STATE_FOCUSED);
|
||||
lv_obj_set_style_outline_color(power_button, lv_theme_get_color_primary(power_button), LV_STATE_FOCUSED);
|
||||
|
||||
auto* default_group = lv_group_get_default();
|
||||
if (default_group) {
|
||||
lv_group_add_obj(default_group, power_button);
|
||||
}
|
||||
|
||||
auto* power_label = lv_label_create(power_button);
|
||||
lv_label_set_text(power_label, LV_SYMBOL_POWER);
|
||||
lv_obj_set_style_text_color(power_label, lv_theme_get_color_primary(parent), LV_STATE_DEFAULT);
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/mcp/McpSystem.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <tactility/lvgl_icon_shared.h>
|
||||
#include <esp_heap_caps.h>
|
||||
|
||||
namespace tt::app::mcpoverride {
|
||||
|
||||
static const auto LOGGER = Logger("McpOverrideApp");
|
||||
|
||||
class McpOverrideApp final : public App {
|
||||
|
||||
public:
|
||||
void onCreate(AppContext& app) override {
|
||||
// Prepare global state
|
||||
auto& state = mcp::getState();
|
||||
state.overrideActive = false;
|
||||
}
|
||||
|
||||
void onShow(AppContext& app, lv_obj_t* parent) override {
|
||||
LOGGER.info("onShow: Starting MCP Override display canvas");
|
||||
auto& state = mcp::getState();
|
||||
|
||||
lv_obj_remove_flag(parent, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_style_pad_all(parent, 0, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_row(parent, 0, LV_PART_MAIN);
|
||||
|
||||
// Standard toolbar so the user can navigate back
|
||||
lv_obj_t* toolbar = lvgl::toolbar_create(parent, app);
|
||||
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||
|
||||
lv_obj_t* title_label = lv_label_create(toolbar);
|
||||
lv_label_set_text(title_label, "MCP Override Screen");
|
||||
|
||||
// Create drawing canvas
|
||||
state.drawArea = lv_canvas_create(parent);
|
||||
lv_obj_set_width(state.drawArea, LV_PCT(100));
|
||||
lv_obj_set_flex_grow(state.drawArea, 1);
|
||||
lv_obj_set_style_radius(state.drawArea, 0, LV_PART_MAIN);
|
||||
lv_obj_set_style_border_width(state.drawArea, 0, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_all(state.drawArea, 0, LV_PART_MAIN);
|
||||
lv_obj_remove_flag(state.drawArea, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
// Get display metrics
|
||||
lv_display_t* display = lv_obj_get_display(parent);
|
||||
state.displayWidth = lv_display_get_horizontal_resolution(display);
|
||||
state.displayHeight = lv_display_get_vertical_resolution(display);
|
||||
|
||||
lv_obj_update_layout(parent);
|
||||
state.drawWidth = lv_obj_get_content_width(state.drawArea);
|
||||
state.drawHeight = lv_obj_get_content_height(state.drawArea);
|
||||
|
||||
// Allocate framebuffer
|
||||
size_t required_size = (size_t)state.drawWidth * state.drawHeight * sizeof(uint16_t);
|
||||
if (state.framebuffer == nullptr || state.framebufferSize != required_size) {
|
||||
if (state.framebuffer != nullptr) {
|
||||
heap_caps_free(state.framebuffer);
|
||||
state.framebuffer = nullptr;
|
||||
}
|
||||
state.framebuffer = (uint16_t*)heap_caps_malloc(required_size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
||||
if (state.framebuffer == nullptr) {
|
||||
state.framebuffer = (uint16_t*)heap_caps_malloc(required_size, MALLOC_CAP_8BIT);
|
||||
}
|
||||
state.framebufferSize = state.framebuffer == nullptr ? 0 : required_size;
|
||||
}
|
||||
|
||||
if (state.framebuffer == nullptr) {
|
||||
LOGGER.error("Failed to allocate {} bytes framebuffer", (unsigned)required_size);
|
||||
lv_obj_t* error = lv_label_create(state.drawArea);
|
||||
lv_label_set_text(error, "Framebuffer allocation failed");
|
||||
lv_obj_center(error);
|
||||
return;
|
||||
}
|
||||
|
||||
lv_canvas_set_buffer(
|
||||
state.drawArea,
|
||||
state.framebuffer,
|
||||
state.drawWidth,
|
||||
state.drawHeight,
|
||||
LV_COLOR_FORMAT_RGB565
|
||||
);
|
||||
|
||||
// Initialize welcome/waiting screen if LLM hasn't written anything yet
|
||||
if (!state.overrideActive) {
|
||||
// Fill with a nice dark blue/slate color
|
||||
for (size_t i = 0; i < (size_t)state.drawWidth * state.drawHeight; ++i) {
|
||||
state.framebuffer[i] = 0x18E3;
|
||||
}
|
||||
state.drawColor = 1;
|
||||
|
||||
lv_obj_t* welcome_label = lv_label_create(state.drawArea);
|
||||
lv_label_set_text(welcome_label, "Waiting for LLM...");
|
||||
lv_obj_set_style_text_color(welcome_label, lv_color_white(), LV_PART_MAIN);
|
||||
lv_obj_align(welcome_label, LV_ALIGN_CENTER, 0, -20);
|
||||
|
||||
lv_obj_t* desc_label = lv_label_create(state.drawArea);
|
||||
lv_label_set_text_fmt(desc_label, "Display Resolution: %ux%u", state.drawWidth, state.drawHeight);
|
||||
lv_obj_set_style_text_color(desc_label, lv_palette_lighten(LV_PALETTE_BLUE, 3), LV_PART_MAIN);
|
||||
lv_obj_align(desc_label, LV_ALIGN_CENTER, 0, 10);
|
||||
}
|
||||
}
|
||||
|
||||
void onHide(AppContext& app) override {
|
||||
LOGGER.info("onHide: Tearing down MCP Override canvas");
|
||||
auto& state = mcp::getState();
|
||||
state.drawArea = nullptr;
|
||||
if (state.framebuffer != nullptr) {
|
||||
heap_caps_free(state.framebuffer);
|
||||
state.framebuffer = nullptr;
|
||||
state.framebufferSize = 0;
|
||||
}
|
||||
state.overrideActive = false;
|
||||
|
||||
// Stop any running tone or recording to prevent stuck state
|
||||
state.audioRunning = false;
|
||||
}
|
||||
|
||||
void onDestroy(AppContext& app) override {
|
||||
onHide(app);
|
||||
}
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.appId = "one.tactility.mcpscreen", // Keep the original appId for compatibility
|
||||
.appName = "MCP Override Screen",
|
||||
.appIcon = LVGL_ICON_SHARED_TOOLBAR,
|
||||
.appCategory = Category::System,
|
||||
.createApp = create<McpOverrideApp>
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // ESP_PLATFORM
|
||||
@@ -0,0 +1,195 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/settings/McpSettings.h>
|
||||
#include <Tactility/settings/WebServerSettings.h>
|
||||
#include <Tactility/service/webserver/WebServerService.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <tactility/lvgl_icon_shared.h>
|
||||
|
||||
#include <esp_netif.h>
|
||||
#include <esp_wifi.h>
|
||||
|
||||
namespace tt::app::mcpsettings {
|
||||
|
||||
static const auto LOGGER = tt::Logger("McpSettingsApp");
|
||||
|
||||
class McpSettingsApp final : public App {
|
||||
|
||||
settings::mcp::McpSettings mcpSettings;
|
||||
settings::mcp::McpSettings originalSettings;
|
||||
settings::webserver::WebServerSettings wsSettings;
|
||||
bool updated = false;
|
||||
|
||||
lv_obj_t* switchMcpEnabled = nullptr;
|
||||
lv_obj_t* labelUrlValue = nullptr;
|
||||
|
||||
static void onMcpEnabledSwitch(lv_event_t* e) {
|
||||
auto* app = static_cast<McpSettingsApp*>(lv_event_get_user_data(e));
|
||||
bool enabled = lv_obj_has_state(app->switchMcpEnabled, LV_STATE_CHECKED);
|
||||
getMainDispatcher().dispatch([app, enabled] {
|
||||
app->mcpSettings.mcpEnabled = enabled;
|
||||
app->updated = true;
|
||||
if (lvgl::lock(100)) {
|
||||
app->updateUrlDisplay();
|
||||
lvgl::unlock();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void updateUrlDisplay() {
|
||||
if (!labelUrlValue) return;
|
||||
|
||||
if (!mcpSettings.mcpEnabled) {
|
||||
lv_label_set_text(labelUrlValue, "Disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string url = "http://";
|
||||
bool ip_added = false;
|
||||
|
||||
// Try getting station IP first (we are connected to home Wi-Fi)
|
||||
esp_netif_t* sta_netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
|
||||
if (sta_netif != nullptr) {
|
||||
esp_netif_ip_info_t ip_info;
|
||||
if (esp_netif_get_ip_info(sta_netif, &ip_info) == ESP_OK && ip_info.ip.addr != 0) {
|
||||
char ip_str[16];
|
||||
snprintf(ip_str, sizeof(ip_str), IPSTR, IP2STR(&ip_info.ip));
|
||||
url += ip_str;
|
||||
ip_added = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If no station IP, check if the AP interface has a valid IP address
|
||||
if (!ip_added) {
|
||||
esp_netif_t* ap_netif = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
|
||||
if (ap_netif != nullptr) {
|
||||
esp_netif_ip_info_t ip_info;
|
||||
if (esp_netif_get_ip_info(ap_netif, &ip_info) == ESP_OK && ip_info.ip.addr != 0) {
|
||||
char ip_str[16];
|
||||
snprintf(ip_str, sizeof(ip_str), IPSTR, IP2STR(&ip_info.ip));
|
||||
url += ip_str;
|
||||
ip_added = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback if no active IP address is detected on either interface
|
||||
if (!ip_added) {
|
||||
if (wsSettings.wifiMode == settings::webserver::WiFiMode::AccessPoint) {
|
||||
url += "192.168.4.1";
|
||||
} else {
|
||||
url = "Connecting...";
|
||||
}
|
||||
}
|
||||
|
||||
if (url.starts_with("http://")) {
|
||||
if (wsSettings.webServerPort != 80) {
|
||||
url += ":" + std::to_string(wsSettings.webServerPort);
|
||||
}
|
||||
url += "/api/mcp";
|
||||
}
|
||||
|
||||
lv_label_set_text(labelUrlValue, url.c_str());
|
||||
}
|
||||
|
||||
public:
|
||||
void onCreate(AppContext& app) override {
|
||||
mcpSettings = settings::mcp::loadOrGetDefault();
|
||||
originalSettings = mcpSettings;
|
||||
wsSettings = settings::webserver::loadOrGetDefault();
|
||||
}
|
||||
|
||||
void onShow(AppContext& app, lv_obj_t* parent) override {
|
||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
|
||||
|
||||
lv_obj_t* toolbar = lvgl::toolbar_create(parent, app);
|
||||
|
||||
// MCP Enable toggle on toolbar
|
||||
switchMcpEnabled = lvgl::toolbar_add_switch_action(toolbar);
|
||||
if (mcpSettings.mcpEnabled) {
|
||||
lv_obj_add_state(switchMcpEnabled, LV_STATE_CHECKED);
|
||||
}
|
||||
lv_obj_add_event_cb(switchMcpEnabled, onMcpEnabledSwitch, LV_EVENT_VALUE_CHANGED, this);
|
||||
|
||||
auto* main_wrapper = lv_obj_create(parent);
|
||||
lv_obj_set_flex_flow(main_wrapper, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_width(main_wrapper, LV_PCT(100));
|
||||
lv_obj_set_flex_grow(main_wrapper, 1);
|
||||
|
||||
// URL Display
|
||||
auto* url_wrapper = lv_obj_create(main_wrapper);
|
||||
lv_obj_set_size(url_wrapper, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
lv_obj_set_style_pad_all(url_wrapper, 10, LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_border_width(url_wrapper, 1, LV_STATE_DEFAULT);
|
||||
lv_obj_set_flex_flow(url_wrapper, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_style_flex_cross_place(url_wrapper, LV_FLEX_ALIGN_START, 0);
|
||||
|
||||
auto* url_title = lv_label_create(url_wrapper);
|
||||
lv_label_set_text(url_title, "MCP Endpoint URL:");
|
||||
|
||||
labelUrlValue = lv_label_create(url_wrapper);
|
||||
if (lv_display_get_color_format(lv_obj_get_display(parent)) == LV_COLOR_FORMAT_L8) {
|
||||
lv_obj_set_style_text_color(labelUrlValue, lv_theme_get_color_secondary(labelUrlValue), LV_PART_MAIN);
|
||||
} else {
|
||||
lv_obj_set_style_text_color(labelUrlValue, lv_palette_main(LV_PALETTE_BLUE), 0);
|
||||
}
|
||||
|
||||
updateUrlDisplay();
|
||||
|
||||
// Info / Documentation text
|
||||
auto* info_label = lv_label_create(main_wrapper);
|
||||
lv_label_set_long_mode(info_label, LV_LABEL_LONG_WRAP);
|
||||
lv_obj_set_width(info_label, LV_PCT(95));
|
||||
if (lv_display_get_color_format(lv_obj_get_display(parent)) != LV_COLOR_FORMAT_L8) {
|
||||
lv_obj_set_style_text_color(info_label, lv_palette_main(LV_PALETTE_GREY), 0);
|
||||
}
|
||||
lv_label_set_text(info_label,
|
||||
"MCP (Model Context Protocol) Screen service allows LLMs to interact with the device "
|
||||
"screen, audio, and tools directly.\n\n"
|
||||
"Endpoints:\n"
|
||||
"- POST /api/mcp (JSON-RPC tools)\n"
|
||||
"- POST /api/screen/raw (big-endian RGB565 writes)\n\n"
|
||||
"To show the LLM canvas, select 'MCP Screen' in Settings -> Display -> Screensaver. "
|
||||
"The canvas also pops up automatically when an LLM sends a draw command.");
|
||||
}
|
||||
|
||||
void onHide(AppContext& app) override {
|
||||
if (updated) {
|
||||
const auto copy = mcpSettings;
|
||||
const bool mcpStateChanged = (copy.mcpEnabled != originalSettings.mcpEnabled);
|
||||
|
||||
getMainDispatcher().dispatch([copy, mcpStateChanged]{
|
||||
// Save to properties file
|
||||
if (!settings::mcp::save(copy)) {
|
||||
LOGGER.warn("Failed to persist MCP settings");
|
||||
}
|
||||
|
||||
// Publish WebServerSettingsChanged event so the HTTP server restarts/refreshes if needed
|
||||
service::webserver::getPubsub()->publish(service::webserver::WebServerEvent::WebServerSettingsChanged);
|
||||
|
||||
if (mcpStateChanged) {
|
||||
LOGGER.info("MCP server state changed to {}", copy.mcpEnabled ? "enabled" : "disabled");
|
||||
service::webserver::setWebServerEnabled(copy.mcpEnabled);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.appId = "McpSettings",
|
||||
.appName = "MCP Screen",
|
||||
.appIcon = LVGL_ICON_SHARED_SETTINGS,
|
||||
.appCategory = Category::Settings,
|
||||
.createApp = create<McpSettingsApp>
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // ESP_PLATFORM
|
||||
@@ -18,6 +18,14 @@
|
||||
#include <host/ble_gatt.h>
|
||||
#include <host/ble_hs.h>
|
||||
#include <host/ble_uuid.h>
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
#include <esp_timer.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/queue.h>
|
||||
@@ -63,6 +71,8 @@ struct HidHostCtx {
|
||||
bool securityInitiated = false;
|
||||
bool typeResolutionDone = false;
|
||||
bool readyBlockFired = false;
|
||||
bool encrypted = false;
|
||||
bool dscsDiscovered = false;
|
||||
lv_indev_t* kbIndev = nullptr;
|
||||
lv_indev_t* mouseIndev = nullptr;
|
||||
lv_obj_t* mouseCursor = nullptr;
|
||||
@@ -179,16 +189,16 @@ static void hidHostMouseReadCb(lv_indev_t* /*indev*/, lv_indev_data_t* data) {
|
||||
data->point.y = (lv_coord_t)cy;
|
||||
break;
|
||||
case LV_DISPLAY_ROTATION_90:
|
||||
data->point.x = (lv_coord_t)cy;
|
||||
data->point.y = (lv_coord_t)(oh - cx - 1);
|
||||
data->point.x = (lv_coord_t)(ow - cy - 1);
|
||||
data->point.y = (lv_coord_t)cx;
|
||||
break;
|
||||
case LV_DISPLAY_ROTATION_180:
|
||||
data->point.x = (lv_coord_t)(ow - cx - 1);
|
||||
data->point.y = (lv_coord_t)(oh - cy - 1);
|
||||
break;
|
||||
case LV_DISPLAY_ROTATION_270:
|
||||
data->point.x = (lv_coord_t)(ow - cy - 1);
|
||||
data->point.y = (lv_coord_t)cx;
|
||||
data->point.x = (lv_coord_t)cy;
|
||||
data->point.y = (lv_coord_t)(oh - cx - 1);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -206,10 +216,29 @@ static void hidHostMouseReadCb(lv_indev_t* /*indev*/, lv_indev_data_t* data) {
|
||||
}
|
||||
|
||||
static void hidHostHandleMouseReport(const uint8_t* data, uint16_t len) {
|
||||
if (len < 3) return;
|
||||
bool btn = (data[0] & 0x01) != 0;
|
||||
int8_t dx = (int8_t)data[1];
|
||||
int8_t dy = (int8_t)data[2];
|
||||
int32_t dx = 0;
|
||||
int32_t dy = 0;
|
||||
bool btn = false;
|
||||
|
||||
if (len >= 5) {
|
||||
// 12-bit packed coordinate format (Logitech/high-res HID mice)
|
||||
btn = (data[0] & 0x01) != 0;
|
||||
|
||||
int16_t raw_x = data[2] | ((data[3] & 0x0F) << 8);
|
||||
if (raw_x & 0x0800) raw_x |= 0xF000; // sign extend 12-bit to 16-bit
|
||||
dx = (int16_t)raw_x;
|
||||
|
||||
int16_t raw_y = (data[3] >> 4) | (data[4] << 4);
|
||||
if (raw_y & 0x0800) raw_y |= 0xF000; // sign extend 12-bit to 16-bit
|
||||
dy = (int16_t)raw_y;
|
||||
} else if (len >= 3) {
|
||||
// Standard 3-byte boot protocol
|
||||
btn = (data[0] & 0x01) != 0;
|
||||
dx = (int8_t)data[1];
|
||||
dy = (int8_t)data[2];
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
lv_display_t* disp = lv_display_get_default();
|
||||
int32_t w = disp ? lv_display_get_horizontal_resolution(disp) : 320;
|
||||
@@ -246,17 +275,33 @@ static void hidHostHandleMouseReport(const uint8_t* data, uint16_t len) {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Asynchronous coordination helpers ----
|
||||
|
||||
static void hidHostOnDscsDiscovered(HidHostCtx& ctx) {
|
||||
ctx.dscsDiscovered = true;
|
||||
if (ctx.encrypted) {
|
||||
ctx.rptRefReadIdx = 0;
|
||||
hidHostStartRptRefRead(ctx);
|
||||
} else {
|
||||
LOGGER.info("Descriptors discovered, waiting for encryption");
|
||||
}
|
||||
}
|
||||
|
||||
static void hidHostOnEncrypted(HidHostCtx& ctx) {
|
||||
ctx.encrypted = true;
|
||||
if (ctx.dscsDiscovered) {
|
||||
ctx.rptRefReadIdx = 0;
|
||||
hidHostStartRptRefRead(ctx);
|
||||
} else {
|
||||
LOGGER.info("Encryption established, waiting for descriptor discovery");
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Timer callback for post-encryption CCCD retry ----
|
||||
|
||||
static void hidEncRetryTimerCb(void* /*arg*/) {
|
||||
if (hid_host_ctx) {
|
||||
if (!hid_host_ctx->typeResolutionDone) {
|
||||
LOGGER.warn("Post-encryption delay — type resolution timed out, proceeding");
|
||||
hid_host_ctx->typeResolutionDone = true;
|
||||
hid_host_ctx->subscribeIdx = 0;
|
||||
} else {
|
||||
LOGGER.info("Post-encryption delay complete — starting CCCD subscriptions");
|
||||
}
|
||||
LOGGER.info("CCCD delay complete — starting subscriptions");
|
||||
hidHostSubscribeNext(*hid_host_ctx);
|
||||
}
|
||||
}
|
||||
@@ -387,7 +432,12 @@ static void hidHostReadReportMap(HidHostCtx& ctx) {
|
||||
LOGGER.info("No Report Map char — skipping type resolution");
|
||||
ctx.typeResolutionDone = true;
|
||||
ctx.subscribeIdx = 0;
|
||||
if (hid_enc_retry_timer) {
|
||||
esp_timer_stop(hid_enc_retry_timer);
|
||||
esp_timer_start_once(hid_enc_retry_timer, 500 * 1000);
|
||||
} else {
|
||||
hidHostSubscribeNext(ctx);
|
||||
}
|
||||
return;
|
||||
}
|
||||
int rc = ble_gattc_read_long(ctx.connHandle, ctx.rptMapHandle, 0,
|
||||
@@ -411,16 +461,27 @@ static void hidHostReadReportMap(HidHostCtx& ctx) {
|
||||
}
|
||||
ctx.typeResolutionDone = true;
|
||||
ctx.subscribeIdx = 0;
|
||||
LOGGER.info("Type resolution complete — delaying CCCD subscriptions by 500ms");
|
||||
if (hid_enc_retry_timer) {
|
||||
esp_timer_stop(hid_enc_retry_timer);
|
||||
esp_timer_start_once(hid_enc_retry_timer, 500 * 1000);
|
||||
} else {
|
||||
hidHostSubscribeNext(ctx);
|
||||
}
|
||||
return 0;
|
||||
}, nullptr);
|
||||
if (rc != 0) {
|
||||
LOGGER.warn("Report map read_long failed rc={} — skipping", rc);
|
||||
ctx.typeResolutionDone = true;
|
||||
ctx.subscribeIdx = 0;
|
||||
if (hid_enc_retry_timer) {
|
||||
esp_timer_stop(hid_enc_retry_timer);
|
||||
esp_timer_start_once(hid_enc_retry_timer, 500 * 1000);
|
||||
} else {
|
||||
hidHostSubscribeNext(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- CCCD subscription chain ----
|
||||
|
||||
@@ -471,6 +532,19 @@ static void hidHostSubscribeNext(HidHostCtx& ctx) {
|
||||
}
|
||||
getMainDispatcher().dispatch([] {
|
||||
if (!hid_host_ctx || hid_host_ctx->kbIndev != nullptr) return;
|
||||
|
||||
bool has_keyboard = false;
|
||||
for (const auto& rpt : hid_host_ctx->inputRpts) {
|
||||
if (rpt.type == HidReportType::Keyboard || rpt.type == HidReportType::Unknown) {
|
||||
has_keyboard = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!has_keyboard) {
|
||||
LOGGER.info("No keyboard reports found — skipping keyboard indev registration");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tt::lvgl::lock(1000)) { LOGGER.warn("LVGL lock failed for kb indev"); return; }
|
||||
auto* kb = lv_indev_create();
|
||||
lv_indev_set_type(kb, LV_INDEV_TYPE_KEYPAD);
|
||||
@@ -555,12 +629,10 @@ static int hidHostDscDiscCb(uint16_t conn_handle, const struct ble_gatt_error* e
|
||||
hidHostDscDiscCb, nullptr);
|
||||
if (rc != 0) {
|
||||
LOGGER.warn("disc_all_dscs[{}] failed rc={}", next_idx, rc);
|
||||
ctx.rptRefReadIdx = 0;
|
||||
hidHostStartRptRefRead(ctx);
|
||||
hidHostOnDscsDiscovered(ctx);
|
||||
}
|
||||
} else {
|
||||
ctx.rptRefReadIdx = 0;
|
||||
hidHostStartRptRefRead(ctx);
|
||||
hidHostOnDscsDiscovered(ctx);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -606,8 +678,7 @@ static int hidHostChrDiscCb(uint16_t conn_handle, const struct ble_gatt_error* e
|
||||
hidHostDscDiscCb, nullptr);
|
||||
if (rc != 0) {
|
||||
LOGGER.warn("disc_all_dscs[0] failed rc={}", rc);
|
||||
ctx.rptRefReadIdx = 0;
|
||||
hidHostStartRptRefRead(ctx);
|
||||
hidHostOnDscsDiscovered(ctx);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -654,6 +725,11 @@ static int hidHostGapCb(struct ble_gap_event* event, void* /*arg*/) {
|
||||
if (event->connect.status == 0) {
|
||||
ctx.connHandle = event->connect.conn_handle;
|
||||
LOGGER.info("Connected (handle={})", ctx.connHandle);
|
||||
|
||||
// Initiate security immediately to encrypt the link for HOGP (HID over GATT)
|
||||
ble_gap_security_initiate(ctx.connHandle);
|
||||
ctx.securityInitiated = true;
|
||||
|
||||
int rc = ble_gattc_disc_all_svcs(ctx.connHandle, hidHostSvcDiscCb, nullptr);
|
||||
if (rc != 0) {
|
||||
LOGGER.warn("disc_all_svcs failed rc={}", rc);
|
||||
@@ -717,14 +793,8 @@ static int hidHostGapCb(struct ble_gap_event* event, void* /*arg*/) {
|
||||
case BLE_GAP_EVENT_ENC_CHANGE:
|
||||
if (event->enc_change.conn_handle == ctx.connHandle) {
|
||||
if (event->enc_change.status == 0) {
|
||||
LOGGER.info("Encryption established — retrying CCCD in 500ms");
|
||||
ctx.subscribeIdx = 0;
|
||||
if (hid_enc_retry_timer) {
|
||||
esp_timer_stop(hid_enc_retry_timer);
|
||||
esp_timer_start_once(hid_enc_retry_timer, 500 * 1000);
|
||||
} else {
|
||||
hidHostSubscribeNext(ctx);
|
||||
}
|
||||
LOGGER.info("Encryption established — notifying state machine");
|
||||
hidHostOnEncrypted(ctx);
|
||||
} else {
|
||||
LOGGER.warn("Encryption failed status={}", event->enc_change.status);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ struct StatusbarData {
|
||||
uint8_t time_minutes = 0;
|
||||
bool time_set = false;
|
||||
kernel::SystemEventSubscription systemEventSubscription = 0;
|
||||
std::string battery_text;
|
||||
bool battery_text_visible = false;
|
||||
};
|
||||
|
||||
static StatusbarData statusbar_data;
|
||||
@@ -47,7 +49,7 @@ typedef struct {
|
||||
lv_obj_t obj;
|
||||
lv_obj_t* time;
|
||||
lv_obj_t* icons[STATUSBAR_ICON_LIMIT];
|
||||
lv_obj_t* battery_icon;
|
||||
lv_obj_t* battery_label;
|
||||
PubSub<void*>::SubscriptionHandle pubsub_subscription;
|
||||
} Statusbar;
|
||||
|
||||
@@ -199,6 +201,13 @@ lv_obj_t* statusbar_create(lv_obj_t* parent) {
|
||||
update_icon(image, &(statusbar_data.icons[i]));
|
||||
}
|
||||
statusbar_data.mutex.unlock();
|
||||
|
||||
statusbar->battery_label = lv_label_create(obj);
|
||||
lv_obj_set_style_text_color(statusbar->battery_label, lv_color_white(), LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_all(statusbar->battery_label, 0, LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_margin_right(statusbar->battery_label, 4, LV_STATE_DEFAULT);
|
||||
lv_obj_add_flag(statusbar->battery_label, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -219,6 +228,12 @@ static void update_main(Statusbar* statusbar) {
|
||||
for (int i = 0; i < STATUSBAR_ICON_LIMIT; ++i) {
|
||||
update_icon(statusbar->icons[i], &(statusbar_data.icons[i]));
|
||||
}
|
||||
if (statusbar_data.battery_text_visible && !statusbar_data.battery_text.empty()) {
|
||||
lv_label_set_text(statusbar->battery_label, statusbar_data.battery_text.c_str());
|
||||
lv_obj_remove_flag(statusbar->battery_label, LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
lv_obj_add_flag(statusbar->battery_label, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
statusbar_data.mutex.unlock();
|
||||
}
|
||||
}
|
||||
@@ -306,6 +321,20 @@ void statusbar_icon_set_visibility(int8_t id, bool visible) {
|
||||
statusbar_data.pubsub->publish(nullptr);
|
||||
}
|
||||
|
||||
void statusbar_set_battery_text(const std::string& text) {
|
||||
statusbar_data.mutex.lock();
|
||||
statusbar_data.battery_text = text;
|
||||
statusbar_data.mutex.unlock();
|
||||
statusbar_data.pubsub->publish(nullptr);
|
||||
}
|
||||
|
||||
void statusbar_set_battery_visibility(bool visible) {
|
||||
statusbar_data.mutex.lock();
|
||||
statusbar_data.battery_text_visible = visible;
|
||||
statusbar_data.mutex.unlock();
|
||||
statusbar_data.pubsub->publish(nullptr);
|
||||
}
|
||||
|
||||
int statusbar_get_height() {
|
||||
const auto icon_size = lvgl_get_statusbar_icon_font_height();
|
||||
const auto vertical_padding = static_cast<uint32_t>((static_cast<float>(icon_size) * 0.1f));
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,9 +17,13 @@ bool HttpServer::startInternal() {
|
||||
config.server_port = port;
|
||||
config.uri_match_fn = matchUri;
|
||||
config.max_uri_handlers = handlers.size() + INTERNAL_URI_HANDLER_COUNT;
|
||||
// Assign unique ctrl port based on server port to avoid collision when
|
||||
// multiple HTTP servers (e.g. WebServer 80 + DevServer 6666) start simultaneously.
|
||||
// ESP-IDF default ctrl_port is 32768; we offset by server port.
|
||||
config.ctrl_port = static_cast<uint16_t>(32768 + (port % 1000));
|
||||
|
||||
if (httpd_start(&server, &config) != ESP_OK) {
|
||||
LOGGER.error("Failed to start http server on port {}", port);
|
||||
LOGGER.error("Failed to start http server on port {} (ctrl_port {})", port, config.ctrl_port);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,11 +126,14 @@ esp_err_t DevelopmentService::handleAppInstall(httpd_req_t* request) {
|
||||
// Skip newline after reading boundary
|
||||
auto content_headers_data = network::receiveTextUntil(request, "\r\n\r\n");
|
||||
content_left -= content_headers_data.length();
|
||||
auto content_headers = string::split(content_headers_data, "\r\n")
|
||||
| std::views::filter([](const std::string& line) {
|
||||
return line.length() > 0;
|
||||
})
|
||||
| std::ranges::to<std::vector>();
|
||||
auto raw_headers = string::split(content_headers_data, "\r\n");
|
||||
std::vector<std::string> content_headers;
|
||||
content_headers.reserve(raw_headers.size());
|
||||
for (const auto& line : raw_headers) {
|
||||
if (line.length() > 0) {
|
||||
content_headers.push_back(line);
|
||||
}
|
||||
}
|
||||
|
||||
auto content_disposition_map = network::parseContentDisposition(content_headers);
|
||||
if (content_disposition_map.empty()) {
|
||||
|
||||
@@ -7,14 +7,17 @@
|
||||
#include "MatrixRainScreensaver.h"
|
||||
#include "MystifyScreensaver.h"
|
||||
#include "StackChanScreensaver.h"
|
||||
#include "McpScreensaver.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/CoreDefines.h>
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
#include <Tactility/hal/power/PowerDevice.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/service/ServiceContext.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
#include <Tactility/mcp/McpSystem.h>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
|
||||
@@ -28,19 +31,28 @@ static std::shared_ptr<hal::display::DisplayDevice> getDisplay() {
|
||||
return hal::findFirstDevice<hal::display::DisplayDevice>(hal::Device::Type::Display);
|
||||
}
|
||||
|
||||
static bool isDeviceCharging() {
|
||||
bool charging = false;
|
||||
hal::findDevices<hal::power::PowerDevice>(hal::Device::Type::Power, [&charging](const auto& power) {
|
||||
if (!power->supportsMetric(hal::power::PowerDevice::MetricType::IsCharging)) {
|
||||
return true; // continue
|
||||
}
|
||||
hal::power::PowerDevice::MetricData data;
|
||||
if (power->getMetric(hal::power::PowerDevice::MetricType::IsCharging, data) && data.valueAsBool) {
|
||||
charging = true;
|
||||
return false; // stop iter
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return charging;
|
||||
}
|
||||
|
||||
void DisplayIdleService::stopScreensaverCb(lv_event_t* e) {
|
||||
auto* self = static_cast<DisplayIdleService*>(lv_event_get_user_data(e));
|
||||
lv_event_stop_bubbling(e);
|
||||
self->stopScreensaverRequested.store(true, std::memory_order_release);
|
||||
lv_display_trigger_activity(nullptr);
|
||||
}
|
||||
|
||||
void DisplayIdleService::stopScreensaver() {
|
||||
if (!lvgl::lock(100)) {
|
||||
// Lock failed - keep flag set to retry on next tick
|
||||
return;
|
||||
self->stopScreensaverLocked();
|
||||
}
|
||||
|
||||
void DisplayIdleService::stopScreensaverLocked() {
|
||||
const auto restoreDuty = cachedDisplaySettings.backlightDuty;
|
||||
const bool wasDimmed = displayDimmed;
|
||||
|
||||
@@ -52,7 +64,6 @@ void DisplayIdleService::stopScreensaver() {
|
||||
lv_obj_delete(screensaverOverlay);
|
||||
screensaverOverlay = nullptr;
|
||||
}
|
||||
lvgl::unlock();
|
||||
stopScreensaverRequested.store(false, std::memory_order_relaxed);
|
||||
|
||||
// Reset auto-off state
|
||||
@@ -67,6 +78,15 @@ void DisplayIdleService::stopScreensaver() {
|
||||
displayDimmed = wasDimmed ? false : displayDimmed;
|
||||
}
|
||||
|
||||
void DisplayIdleService::stopScreensaver() {
|
||||
if (!lvgl::lock(100)) {
|
||||
// Lock failed - keep flag set to retry on next tick
|
||||
return;
|
||||
}
|
||||
stopScreensaverLocked();
|
||||
lvgl::unlock();
|
||||
}
|
||||
|
||||
void DisplayIdleService::activateScreensaver() {
|
||||
lv_obj_t* top = lv_layer_top();
|
||||
|
||||
@@ -103,6 +123,9 @@ void DisplayIdleService::activateScreensaver() {
|
||||
case settings::display::ScreensaverType::StackChan:
|
||||
screensaver = std::make_unique<StackChanScreensaver>();
|
||||
break;
|
||||
case settings::display::ScreensaverType::McpScreen:
|
||||
screensaver = std::make_unique<McpScreensaver>();
|
||||
break;
|
||||
case settings::display::ScreensaverType::None:
|
||||
default:
|
||||
// Just black screen, no animated screensaver
|
||||
@@ -172,26 +195,37 @@ void DisplayIdleService::tick() {
|
||||
}
|
||||
|
||||
auto display = getDisplay();
|
||||
if (display != nullptr && display->supportsBacklightDuty()) {
|
||||
bool supportsBacklight = display != nullptr && display->supportsBacklightDuty();
|
||||
|
||||
if (supportsBacklight) {
|
||||
if (!cachedDisplaySettings.backlightTimeoutEnabled || cachedDisplaySettings.backlightTimeoutMs == 0) {
|
||||
if (displayDimmed) {
|
||||
display->setBacklightDuty(cachedDisplaySettings.backlightDuty);
|
||||
displayDimmed = false;
|
||||
}
|
||||
} else {
|
||||
bool charging_blocks = cachedDisplaySettings.disableScreensaverWhenCharging && isDeviceCharging();
|
||||
|
||||
if (!displayDimmed && inactive_ms >= cachedDisplaySettings.backlightTimeoutMs) {
|
||||
if (charging_blocks) {
|
||||
// Skip screensaver while charging
|
||||
} else {
|
||||
if (!lvgl::lock(100)) {
|
||||
return; // Retry on next tick
|
||||
}
|
||||
activateScreensaver();
|
||||
lvgl::unlock();
|
||||
// Turn off backlight for "None" screensaver (just black screen)
|
||||
if (cachedDisplaySettings.screensaverType == settings::display::ScreensaverType::None) {
|
||||
display->setBacklightDuty(0);
|
||||
}
|
||||
displayDimmed = true;
|
||||
} else if (displayDimmed && (inactive_ms < kWakeActivityThresholdMs)) {
|
||||
}
|
||||
} else if (displayDimmed) {
|
||||
if (inactive_ms < kWakeActivityThresholdMs) {
|
||||
stopScreensaver();
|
||||
} else if (charging_blocks) {
|
||||
stopScreensaver();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,6 +237,11 @@ bool DisplayIdleService::onStart(ServiceContext& service) {
|
||||
|
||||
cachedDisplaySettings = settings::display::loadOrGetDefault();
|
||||
|
||||
auto display = getDisplay();
|
||||
if (display != nullptr && !display->supportsBacklightDuty()) {
|
||||
LOGGER.info("Monochrome/RLCD display detected (no backlight control): idle timer will run but auto-backlight off is disabled");
|
||||
}
|
||||
|
||||
timer = std::make_unique<Timer>(Timer::Type::Periodic, kernel::millisToTicks(TICK_INTERVAL_MS), [this]{ this->tick(); });
|
||||
timer->setCallbackPriority(Thread::Priority::Lower);
|
||||
timer->start();
|
||||
@@ -259,6 +298,62 @@ void DisplayIdleService::reloadSettings() {
|
||||
settingsReloadRequested.store(true, std::memory_order_release);
|
||||
}
|
||||
|
||||
void DisplayIdleService::startMcpScreensaver() {
|
||||
if (!lvgl::lock(200)) {
|
||||
LOGGER.warn("startMcpScreensaver: failed to acquire LVGL lock");
|
||||
return;
|
||||
}
|
||||
|
||||
if (screensaverOverlay != nullptr) {
|
||||
// Screensaver already active — if drawArea is registered we're done,
|
||||
// otherwise stop the current one so we can replace it with McpScreensaver.
|
||||
const auto& mcpState = mcp::getState();
|
||||
if (mcpState.drawArea != nullptr) {
|
||||
lvgl::unlock();
|
||||
return; // McpScreensaver already running
|
||||
}
|
||||
// Wrong screensaver type active — tear it down first
|
||||
if (screensaver) {
|
||||
screensaver->stop();
|
||||
screensaver.reset();
|
||||
}
|
||||
lv_obj_delete(screensaverOverlay);
|
||||
screensaverOverlay = nullptr;
|
||||
}
|
||||
|
||||
screensaverActiveCounter = 0;
|
||||
backlightOff = false;
|
||||
|
||||
// Ensure backlight is active if the display supports it
|
||||
auto display = getDisplay();
|
||||
if (display != nullptr && display->supportsBacklightDuty()) {
|
||||
uint8_t duty = cachedDisplaySettings.backlightDuty;
|
||||
if (duty == 0) duty = 255; // ensure visible if settings not loaded / default
|
||||
display->setBacklightDuty(duty);
|
||||
}
|
||||
|
||||
lv_coord_t screenW = lv_display_get_horizontal_resolution(nullptr);
|
||||
|
||||
lv_coord_t screenH = lv_display_get_vertical_resolution(nullptr);
|
||||
|
||||
lv_obj_t* top = lv_layer_top();
|
||||
screensaverOverlay = lv_obj_create(top);
|
||||
lv_obj_remove_style_all(screensaverOverlay);
|
||||
lv_obj_set_size(screensaverOverlay, LV_PCT(100), LV_PCT(100));
|
||||
lv_obj_set_pos(screensaverOverlay, 0, 0);
|
||||
lv_obj_set_style_bg_color(screensaverOverlay, lv_color_black(), 0);
|
||||
lv_obj_set_style_bg_opa(screensaverOverlay, LV_OPA_COVER, 0);
|
||||
lv_obj_add_flag(screensaverOverlay, LV_OBJ_FLAG_CLICKABLE);
|
||||
lv_obj_add_event_cb(screensaverOverlay, stopScreensaverCb, LV_EVENT_CLICKED, this);
|
||||
|
||||
screensaver = std::make_unique<McpScreensaver>();
|
||||
screensaver->start(screensaverOverlay, screenW, screenH);
|
||||
|
||||
lvgl::unlock();
|
||||
displayDimmed = true;
|
||||
LOGGER.info("MCP screensaver activated");
|
||||
}
|
||||
|
||||
std::shared_ptr<DisplayIdleService> findService() {
|
||||
return std::static_pointer_cast<DisplayIdleService>(
|
||||
findServiceById("DisplayIdle")
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include "McpScreensaver.h"
|
||||
#include <Tactility/mcp/McpSystem.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <esp_heap_caps.h>
|
||||
|
||||
namespace tt::service::displayidle {
|
||||
|
||||
static const auto LOGGER = Logger("McpScreensaver");
|
||||
|
||||
void McpScreensaver::start(lv_obj_t* overlay, lv_coord_t screenW, lv_coord_t screenH) {
|
||||
auto& state = mcp::getState();
|
||||
|
||||
// Full-screen canvas on the overlay
|
||||
lv_obj_t* canvas = lv_canvas_create(overlay);
|
||||
lv_obj_set_size(canvas, screenW, screenH);
|
||||
lv_obj_set_pos(canvas, 0, 0);
|
||||
lv_obj_set_style_radius(canvas, 0, LV_PART_MAIN);
|
||||
lv_obj_set_style_border_width(canvas, 0, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_all(canvas, 0, LV_PART_MAIN);
|
||||
lv_obj_remove_flag(canvas, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
// Allocate framebuffer (prefer SPIRAM)
|
||||
size_t requiredSize = (size_t)screenW * screenH * sizeof(uint16_t);
|
||||
framebuffer = (uint16_t*)heap_caps_malloc(requiredSize, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
||||
if (framebuffer == nullptr) {
|
||||
framebuffer = (uint16_t*)heap_caps_malloc(requiredSize, MALLOC_CAP_8BIT);
|
||||
}
|
||||
framebufferSize = (framebuffer != nullptr) ? requiredSize : 0;
|
||||
|
||||
if (framebuffer == nullptr) {
|
||||
LOGGER.error("Failed to allocate {}B framebuffer", (unsigned)requiredSize);
|
||||
lv_obj_t* err = lv_label_create(canvas);
|
||||
lv_label_set_text(err, "Framebuffer alloc failed");
|
||||
lv_obj_center(err);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fill with a dark slate background (inverted for display path)
|
||||
size_t pixelCount = (size_t)screenW * screenH;
|
||||
for (size_t i = 0; i < pixelCount; ++i) {
|
||||
framebuffer[i] = ~0x18E3; // dark blue-grey
|
||||
}
|
||||
|
||||
lv_canvas_set_buffer(canvas, framebuffer, screenW, screenH, LV_COLOR_FORMAT_RGB565);
|
||||
|
||||
// Waiting label (removed on first MCP draw via lv_obj_clean)
|
||||
lv_obj_t* waitLabel = lv_label_create(canvas);
|
||||
lv_label_set_text(waitLabel, "Waiting for LLM...");
|
||||
lv_obj_set_style_text_color(waitLabel, lv_color_black(), LV_PART_MAIN); // white on screen (inverted)
|
||||
lv_obj_align(waitLabel, LV_ALIGN_CENTER, 0, -20);
|
||||
|
||||
lv_obj_t* resLabel = lv_label_create(canvas);
|
||||
lv_label_set_text_fmt(resLabel, "Display: %dx%d", (int)screenW, (int)screenH);
|
||||
lv_color_t resColor = lv_palette_lighten(LV_PALETTE_BLUE, 3);
|
||||
lv_obj_set_style_text_color(resLabel, lv_color_make(~resColor.red, ~resColor.green, ~resColor.blue), LV_PART_MAIN);
|
||||
lv_obj_align(resLabel, LV_ALIGN_CENTER, 0, 10);
|
||||
|
||||
// Register with McpSystemState
|
||||
std::lock_guard<std::mutex> lock(state.mutex);
|
||||
state.drawArea = canvas;
|
||||
state.framebuffer = framebuffer;
|
||||
state.framebufferSize = framebufferSize;
|
||||
state.displayWidth = (uint16_t)screenW;
|
||||
state.displayHeight = (uint16_t)screenH;
|
||||
state.drawWidth = (uint16_t)screenW;
|
||||
state.drawHeight = (uint16_t)screenH;
|
||||
// Don't reset overrideActive — if the LLM already drew, we keep the content
|
||||
|
||||
LOGGER.info("McpScreensaver started ({}x{})", (int)screenW, (int)screenH);
|
||||
}
|
||||
|
||||
void McpScreensaver::stop() {
|
||||
auto& state = mcp::getState();
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(state.mutex);
|
||||
state.drawArea = nullptr;
|
||||
state.framebuffer = nullptr;
|
||||
state.framebufferSize = 0;
|
||||
state.overrideActive = false;
|
||||
}
|
||||
|
||||
if (framebuffer != nullptr) {
|
||||
heap_caps_free(framebuffer);
|
||||
framebuffer = nullptr;
|
||||
framebufferSize = 0;
|
||||
}
|
||||
|
||||
LOGGER.info("McpScreensaver stopped");
|
||||
}
|
||||
|
||||
void McpScreensaver::update(lv_coord_t /*screenW*/, lv_coord_t /*screenH*/) {
|
||||
// MCP draws on demand via HTTP — no per-frame animation needed
|
||||
}
|
||||
|
||||
} // namespace tt::service::displayidle
|
||||
|
||||
#endif // ESP_PLATFORM
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include "Screensaver.h"
|
||||
#include <cstdint>
|
||||
|
||||
namespace tt::service::displayidle {
|
||||
|
||||
/**
|
||||
* MCP Screen screensaver.
|
||||
* Creates a full-screen LVGL canvas on the overlay and registers it in
|
||||
* McpSystemState so that MCP HTTP draw commands can paint to it.
|
||||
* Dismissed by a touch event (handled by the parent DisplayIdle overlay).
|
||||
*/
|
||||
class McpScreensaver final : public Screensaver {
|
||||
uint16_t* framebuffer = nullptr;
|
||||
size_t framebufferSize = 0;
|
||||
|
||||
public:
|
||||
McpScreensaver() = default;
|
||||
~McpScreensaver() override = default;
|
||||
|
||||
void start(lv_obj_t* overlay, lv_coord_t screenW, lv_coord_t screenH) override;
|
||||
void stop() override;
|
||||
void update(lv_coord_t screenW, lv_coord_t screenH) override;
|
||||
};
|
||||
|
||||
} // namespace tt::service::displayidle
|
||||
|
||||
#endif // ESP_PLATFORM
|
||||
@@ -199,7 +199,7 @@ bool GuiService::onStart(ServiceContext& service) {
|
||||
|
||||
thread = new Thread(
|
||||
GUI_TASK_NAME,
|
||||
4096, // Last known minimum was 2800 for launching desktop
|
||||
8192, // Last known minimum was 2800 for launching desktop, increased to 8192 to prevent stack overflow on complex layouts/MCP settings
|
||||
guiMain
|
||||
);
|
||||
thread->setPriority(THREAD_PRIORITY_SERVICE);
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include <tactility/lvgl_icon_statusbar.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <string>
|
||||
|
||||
namespace tt::service::statusbar {
|
||||
|
||||
@@ -102,6 +104,13 @@ static const char* getPowerStatusIcon() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
hal::power::PowerDevice::MetricData charging_data;
|
||||
if (power->supportsMetric(hal::power::PowerDevice::MetricType::IsCharging) &&
|
||||
power->getMetric(hal::power::PowerDevice::MetricType::IsCharging, charging_data) &&
|
||||
charging_data.valueAsBool) {
|
||||
return LVGL_ICON_STATUSBAR_BATTERY_ANDROID_FRAME_BOLT;
|
||||
}
|
||||
|
||||
hal::power::PowerDevice::MetricData charge_level;
|
||||
if (!power->getMetric(hal::power::PowerDevice::MetricType::ChargeLevel, charge_level)) {
|
||||
return nullptr;
|
||||
@@ -210,6 +219,29 @@ class StatusbarService final : public Service {
|
||||
}
|
||||
power_last_icon = desired_icon;
|
||||
}
|
||||
|
||||
std::shared_ptr<hal::power::PowerDevice> power;
|
||||
hal::findDevices<hal::power::PowerDevice>(hal::Device::Type::Power, [&power](const auto& device) {
|
||||
if (device->supportsMetric(hal::power::PowerDevice::MetricType::ChargeLevel)) {
|
||||
power = device;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
if (power != nullptr) {
|
||||
hal::power::PowerDevice::MetricData charge_level;
|
||||
if (power->getMetric(hal::power::PowerDevice::MetricType::ChargeLevel, charge_level)) {
|
||||
uint8_t charge = charge_level.valueAsUint8;
|
||||
std::string battery_text = std::format("{}%", charge);
|
||||
lvgl::statusbar_set_battery_text(battery_text);
|
||||
lvgl::statusbar_set_battery_visibility(true);
|
||||
} else {
|
||||
lvgl::statusbar_set_battery_visibility(false);
|
||||
}
|
||||
} else {
|
||||
lvgl::statusbar_set_battery_visibility(false);
|
||||
}
|
||||
}
|
||||
|
||||
void updateUsbIcon() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,8 @@
|
||||
#include <Tactility/service/webserver/AssetVersion.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/settings/WebServerSettings.h>
|
||||
#include <Tactility/settings/McpSettings.h>
|
||||
#include <Tactility/mcp/McpSystem.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/Logger.h>
|
||||
@@ -67,7 +69,9 @@ static const char* getChipModelName(esp_chip_model_t model) {
|
||||
case CHIP_ESP32C6: return "ESP32-C6";
|
||||
case CHIP_ESP32H2: return "ESP32-H2";
|
||||
case CHIP_ESP32P4: return "ESP32-P4";
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32C5_BETA3_VERSION) || defined(CONFIG_IDF_TARGET_ESP32C5_MP_VERSION)
|
||||
case CHIP_ESP32C5: return "ESP32-C5";
|
||||
#endif
|
||||
case CHIP_ESP32C61: return "ESP32-C61";
|
||||
default: return "Unknown";
|
||||
}
|
||||
@@ -214,7 +218,9 @@ bool WebServerService::onStart(ServiceContext& service) {
|
||||
lock.lock();
|
||||
g_cachedSettings = settings::webserver::loadOrGetDefault();
|
||||
g_settingsCached = true;
|
||||
serverEnabled = g_cachedSettings.webServerEnabled;
|
||||
|
||||
auto mcpSettings = settings::mcp::loadOrGetDefault();
|
||||
serverEnabled = g_cachedSettings.webServerEnabled || mcpSettings.mcpEnabled;
|
||||
}
|
||||
// Subscribe to settings change events to refresh cache
|
||||
settingsEventSubscription = pubsub->subscribe([](WebServerEvent event) {
|
||||
@@ -228,10 +234,10 @@ bool WebServerService::onStart(ServiceContext& service) {
|
||||
|
||||
// Start HTTP server only if enabled in settings (default: OFF to save memory)
|
||||
if (serverEnabled) {
|
||||
LOGGER.info("WebServer enabled in settings, starting HTTP server...");
|
||||
LOGGER.info("WebServer or MCP enabled in settings, starting HTTP server...");
|
||||
setEnabled(true);
|
||||
} else {
|
||||
LOGGER.info("WebServer disabled in settings, NOT starting HTTP server (saves ~10KB RAM)");
|
||||
LOGGER.info("WebServer and MCP disabled in settings, NOT starting HTTP server (saves RAM)");
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
@@ -260,11 +266,16 @@ void WebServerService::setEnabled(bool enabled) {
|
||||
lock.lock();
|
||||
|
||||
if (enabled) {
|
||||
// Start unconditionally if explicitly requested
|
||||
if (!httpServer || !httpServer->isStarted()) {
|
||||
startServer();
|
||||
}
|
||||
} else {
|
||||
if (httpServer && httpServer->isStarted()) {
|
||||
// Stop only if both web server and MCP are disabled
|
||||
auto wsSettings = settings::webserver::loadOrGetDefault();
|
||||
auto mcpSettings = settings::mcp::loadOrGetDefault();
|
||||
bool anyEnabled = wsSettings.webServerEnabled || mcpSettings.mcpEnabled;
|
||||
if (!anyEnabled && httpServer && httpServer->isStarted()) {
|
||||
stopServer();
|
||||
}
|
||||
}
|
||||
@@ -500,7 +511,7 @@ bool WebServerService::startServer() {
|
||||
settings.webServerPort,
|
||||
"0.0.0.0",
|
||||
handlers,
|
||||
8192 // Stack size
|
||||
12288 // Stack size (forces allocation in internal SRAM instead of PSRAM)
|
||||
);
|
||||
|
||||
httpServer->start();
|
||||
@@ -521,6 +532,11 @@ bool WebServerService::startServer() {
|
||||
settings.wifiMode == settings::webserver::WiFiMode::AccessPoint ? "AP" : "Station");
|
||||
}
|
||||
|
||||
auto mcpSettings = settings::mcp::loadOrGetDefault();
|
||||
if (mcpSettings.mcpEnabled) {
|
||||
mcp::startVideoStreamServer();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -532,6 +548,8 @@ void WebServerService::stopServer() {
|
||||
httpServer->stop();
|
||||
httpServer.reset();
|
||||
|
||||
mcp::stopVideoStreamServer();
|
||||
|
||||
// Stop AP mode WiFi if we started it
|
||||
if (apWifiInitialized || apNetif != nullptr) {
|
||||
stopApMode();
|
||||
@@ -1026,13 +1044,22 @@ esp_err_t WebServerService::handleApiGet(httpd_req_t* request) {
|
||||
|
||||
// API POST dispatcher - all POST endpoints require authentication
|
||||
esp_err_t WebServerService::handleApiPost(httpd_req_t* request) {
|
||||
const char* uri = request->uri;
|
||||
|
||||
// Route MCP endpoints unauthenticated
|
||||
if (strncmp(uri, "/api/mcp", 8) == 0) {
|
||||
return handleApiMcp(request);
|
||||
}
|
||||
if (strncmp(uri, "/api/screen/raw", 15) == 0) {
|
||||
return handleApiScreenRaw(request);
|
||||
}
|
||||
|
||||
bool authPassed = false;
|
||||
esp_err_t authResult = validateRequestAuth(request, authPassed);
|
||||
if (!authPassed) {
|
||||
return authResult;
|
||||
}
|
||||
|
||||
const char* uri = request->uri;
|
||||
if (strncmp(uri, "/api/apps/run", 13) == 0) {
|
||||
return handleApiAppsRun(request);
|
||||
}
|
||||
@@ -1332,11 +1359,14 @@ esp_err_t WebServerService::handleApiAppsInstall(httpd_req_t* request) {
|
||||
content_left -= content_headers_data.length();
|
||||
|
||||
// Split headers into lines and filter empty ones
|
||||
auto content_headers = string::split(content_headers_data, "\r\n")
|
||||
| std::views::filter([](const std::string& line) {
|
||||
return line.length() > 0;
|
||||
})
|
||||
| std::ranges::to<std::vector>();
|
||||
auto raw_headers = string::split(content_headers_data, "\r\n");
|
||||
std::vector<std::string> content_headers;
|
||||
content_headers.reserve(raw_headers.size());
|
||||
for (const auto& line : raw_headers) {
|
||||
if (line.length() > 0) {
|
||||
content_headers.push_back(line);
|
||||
}
|
||||
}
|
||||
|
||||
auto content_disposition_map = network::parseContentDisposition(content_headers);
|
||||
if (content_disposition_map.empty()) {
|
||||
|
||||
@@ -107,6 +107,23 @@ static bool decrypt(const std::string& ssidInput, std::string& ssidOutput) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Strip PKCS#7 padding
|
||||
if (result_length > 0) {
|
||||
uint8_t pad_val = result[result_length - 1];
|
||||
if (pad_val >= 1 && pad_val <= 16 && pad_val <= result_length) {
|
||||
bool valid_padding = true;
|
||||
for (size_t i = result_length - pad_val; i < result_length; ++i) {
|
||||
if (result[i] != pad_val) {
|
||||
valid_padding = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (valid_padding) {
|
||||
result[result_length - pad_val] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ssidOutput = reinterpret_cast<char*>(result);
|
||||
free(result);
|
||||
return true;
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
#include <Tactility/service/wifi/WifiSettings.h>
|
||||
|
||||
#include <esp_wifi_default.h>
|
||||
#include <esp_mac.h>
|
||||
#include <esp_netif.h>
|
||||
#include <mdns.h>
|
||||
#include <lwip/esp_netif_net_stack.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <atomic>
|
||||
@@ -543,6 +546,28 @@ static void dispatchEnable(std::shared_ptr<Wifi> wifi) {
|
||||
}
|
||||
wifi->netif = esp_netif_create_default_wifi_sta();
|
||||
|
||||
if (wifi->netif != nullptr) {
|
||||
uint8_t mac[6];
|
||||
char hostname[32];
|
||||
if (esp_read_mac(mac, ESP_MAC_WIFI_STA) == ESP_OK) {
|
||||
snprintf(hostname, sizeof(hostname), "kidsOS-%02X%02X", mac[4], mac[5]);
|
||||
} else {
|
||||
strncpy(hostname, "kidsOS", sizeof(hostname));
|
||||
}
|
||||
LOGGER.info("Setting DHCP Hostname to '{}'", hostname);
|
||||
esp_netif_set_hostname(wifi->netif, hostname);
|
||||
|
||||
// Initialize mDNS
|
||||
esp_err_t mdns_err = mdns_init();
|
||||
if (mdns_err == ESP_OK) {
|
||||
LOGGER.info("mDNS initialized, setting hostname to '{}.local'", hostname);
|
||||
mdns_hostname_set(hostname);
|
||||
mdns_instance_name_set("kidsOS Tactility Device");
|
||||
} else {
|
||||
LOGGER.error("Failed to initialize mDNS: {}", (int)mdns_err);
|
||||
}
|
||||
}
|
||||
|
||||
// Warning: this is the memory-intensive operation
|
||||
// It uses over 117kB of RAM with default settings for S3 on IDF v5.1.2
|
||||
wifi_init_config_t config = WIFI_INIT_CONFIG_DEFAULT();
|
||||
|
||||
@@ -22,6 +22,7 @@ constexpr auto* SETTINGS_KEY_BACKLIGHT_DUTY = "backlightDuty";
|
||||
constexpr auto* SETTINGS_KEY_TIMEOUT_ENABLED = "backlightTimeoutEnabled";
|
||||
constexpr auto* SETTINGS_KEY_TIMEOUT_MS = "backlightTimeoutMs";
|
||||
constexpr auto* SETTINGS_KEY_SCREENSAVER_TYPE = "screensaverType";
|
||||
constexpr auto* SETTINGS_KEY_DISABLE_WHEN_CHARGING = "disableScreensaverWhenCharging";
|
||||
|
||||
static Orientation getDefaultOrientation() {
|
||||
auto* display = lv_display_get_default();
|
||||
@@ -83,6 +84,8 @@ static std::string toString(ScreensaverType type) {
|
||||
return "MatrixRain";
|
||||
case StackChan:
|
||||
return "StackChan";
|
||||
case McpScreen:
|
||||
return "McpScreen";
|
||||
default:
|
||||
std::unreachable();
|
||||
}
|
||||
@@ -104,6 +107,9 @@ static bool fromString(const std::string& str, ScreensaverType& type) {
|
||||
} else if (str == "StackChan") {
|
||||
type = ScreensaverType::StackChan;
|
||||
return true;
|
||||
} else if (str == "McpScreen") {
|
||||
type = ScreensaverType::McpScreen;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -159,12 +165,19 @@ bool load(DisplaySettings& settings) {
|
||||
fromString(screensaver_entry->second, screensaver_type);
|
||||
}
|
||||
|
||||
bool disable_when_charging = false;
|
||||
auto disable_charging_entry = map.find(SETTINGS_KEY_DISABLE_WHEN_CHARGING);
|
||||
if (disable_charging_entry != map.end()) {
|
||||
disable_when_charging = (disable_charging_entry->second == "1" || disable_charging_entry->second == "true" || disable_charging_entry->second == "True");
|
||||
}
|
||||
|
||||
settings.orientation = orientation;
|
||||
settings.gammaCurve = gamma_curve;
|
||||
settings.backlightDuty = backlight_duty;
|
||||
settings.backlightTimeoutEnabled = timeout_enabled;
|
||||
settings.backlightTimeoutMs = timeout_ms;
|
||||
settings.screensaverType = screensaver_type;
|
||||
settings.disableScreensaverWhenCharging = disable_when_charging;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -176,7 +189,8 @@ DisplaySettings getDefault() {
|
||||
.backlightDuty = 200,
|
||||
.backlightTimeoutEnabled = false,
|
||||
.backlightTimeoutMs = 60000,
|
||||
.screensaverType = ScreensaverType::BouncingBalls
|
||||
.screensaverType = ScreensaverType::BouncingBalls,
|
||||
.disableScreensaverWhenCharging = false
|
||||
};
|
||||
}
|
||||
|
||||
@@ -196,6 +210,7 @@ bool save(const DisplaySettings& settings) {
|
||||
map[SETTINGS_KEY_TIMEOUT_ENABLED] = settings.backlightTimeoutEnabled ? "1" : "0";
|
||||
map[SETTINGS_KEY_TIMEOUT_MS] = std::to_string(settings.backlightTimeoutMs);
|
||||
map[SETTINGS_KEY_SCREENSAVER_TYPE] = toString(settings.screensaverType);
|
||||
map[SETTINGS_KEY_DISABLE_WHEN_CHARGING] = settings.disableScreensaverWhenCharging ? "1" : "0";
|
||||
auto settings_path = getSettingsFilePath();
|
||||
if (!file::findOrCreateParentDirectory(settings_path, 0755)) {
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#include <Tactility/settings/McpSettings.h>
|
||||
#include <Tactility/file/PropertiesFile.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/Paths.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace tt::settings::mcp {
|
||||
|
||||
static const auto LOGGER = Logger("McpSettings");
|
||||
|
||||
static std::string getSettingsFilePath() {
|
||||
return getUserDataPath() + "/settings/mcp.properties";
|
||||
}
|
||||
|
||||
constexpr auto* KEY_MCP_ENABLED = "mcpEnabled";
|
||||
|
||||
bool load(McpSettings& settings) {
|
||||
auto settings_path = getSettingsFilePath();
|
||||
if (!file::isFile(settings_path)) {
|
||||
return false;
|
||||
}
|
||||
std::map<std::string, std::string> map;
|
||||
if (!file::loadPropertiesFile(settings_path, map)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto mcp_enabled = map.find(KEY_MCP_ENABLED);
|
||||
settings.mcpEnabled = (mcp_enabled != map.end())
|
||||
? (mcp_enabled->second == "1" || mcp_enabled->second == "true")
|
||||
: false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
McpSettings getDefault() {
|
||||
return McpSettings{
|
||||
.mcpEnabled = false
|
||||
};
|
||||
}
|
||||
|
||||
McpSettings loadOrGetDefault() {
|
||||
McpSettings settings;
|
||||
if (!load(settings)) {
|
||||
settings = getDefault();
|
||||
if (!save(settings)) {
|
||||
LOGGER.warn("Failed to save default MCP settings");
|
||||
}
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
bool save(const McpSettings& settings) {
|
||||
std::map<std::string, std::string> map;
|
||||
map[KEY_MCP_ENABLED] = settings.mcpEnabled ? "true" : "false";
|
||||
|
||||
auto settings_path = getSettingsFilePath();
|
||||
if (!file::findOrCreateParentDirectory(settings_path, 0755)) {
|
||||
LOGGER.error("Failed to create parent dir for {}", settings_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!file::savePropertiesFile(settings_path, map)) {
|
||||
LOGGER.error("Failed to save MCP settings to {}", settings_path);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <symbols/esp_http_client.h>
|
||||
|
||||
#include <esp_http_client.h>
|
||||
#include <esp_idf_version.h>
|
||||
|
||||
const esp_elfsym esp_http_client_symbols[] = {
|
||||
ESP_ELFSYM_EXPORT(esp_http_client_init),
|
||||
@@ -23,11 +24,15 @@ const esp_elfsym esp_http_client_symbols[] = {
|
||||
ESP_ELFSYM_EXPORT(esp_http_client_get_user_data),
|
||||
ESP_ELFSYM_EXPORT(esp_http_client_set_user_data),
|
||||
ESP_ELFSYM_EXPORT(esp_http_client_get_errno),
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
|
||||
ESP_ELFSYM_EXPORT(esp_http_client_get_and_clear_last_tls_error),
|
||||
#endif
|
||||
ESP_ELFSYM_EXPORT(esp_http_client_set_method),
|
||||
ESP_ELFSYM_EXPORT(esp_http_client_set_timeout_ms),
|
||||
ESP_ELFSYM_EXPORT(esp_http_client_delete_header),
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
|
||||
ESP_ELFSYM_EXPORT(esp_http_client_delete_all_headers),
|
||||
#endif
|
||||
ESP_ELFSYM_EXPORT(esp_http_client_open),
|
||||
ESP_ELFSYM_EXPORT(esp_http_client_write),
|
||||
ESP_ELFSYM_EXPORT(esp_http_client_fetch_headers),
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <getopt.h>
|
||||
#include <dirent.h>
|
||||
#include <esp_log.h>
|
||||
#include <esp_idf_version.h>
|
||||
#include <esp_random.h>
|
||||
#include <esp_sntp.h>
|
||||
#include <esp_netif.h>
|
||||
@@ -61,6 +62,8 @@
|
||||
#include <driver/i2s_common.h>
|
||||
#include <driver/i2s_std.h>
|
||||
#include <driver/gpio.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/i2s_controller.h>
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32P4
|
||||
#include <driver/ppa.h>
|
||||
@@ -263,7 +266,9 @@ const esp_elfsym main_symbols[] {
|
||||
ESP_ELFSYM_EXPORT(tolower),
|
||||
ESP_ELFSYM_EXPORT(toupper),
|
||||
// ESP-IDF
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
|
||||
ESP_ELFSYM_EXPORT(esp_log),
|
||||
#endif
|
||||
ESP_ELFSYM_EXPORT(esp_log_write),
|
||||
ESP_ELFSYM_EXPORT(esp_log_timestamp),
|
||||
ESP_ELFSYM_EXPORT(esp_err_to_name),
|
||||
@@ -423,7 +428,23 @@ const esp_elfsym main_symbols[] {
|
||||
ESP_ELFSYM_EXPORT(i2s_channel_read),
|
||||
ESP_ELFSYM_EXPORT(i2s_channel_register_event_callback),
|
||||
ESP_ELFSYM_EXPORT(i2s_channel_preload_data),
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
|
||||
ESP_ELFSYM_EXPORT(i2s_channel_tune_rate),
|
||||
#endif
|
||||
// tactility/device.h (kernel device discovery)
|
||||
ESP_ELFSYM_EXPORT(device_find_by_name),
|
||||
ESP_ELFSYM_EXPORT(device_find_first_active_by_type),
|
||||
ESP_ELFSYM_EXPORT(device_is_ready),
|
||||
ESP_ELFSYM_EXPORT(device_lock),
|
||||
ESP_ELFSYM_EXPORT(device_try_lock),
|
||||
ESP_ELFSYM_EXPORT(device_unlock),
|
||||
// tactility/drivers/i2s_controller.h
|
||||
ESP_ELFSYM_EXPORT(i2s_controller_read),
|
||||
ESP_ELFSYM_EXPORT(i2s_controller_write),
|
||||
ESP_ELFSYM_EXPORT(i2s_controller_set_config),
|
||||
ESP_ELFSYM_EXPORT(i2s_controller_get_config),
|
||||
ESP_ELFSYM_EXPORT(i2s_controller_reset),
|
||||
ESP_ELFSYM_EXPORT(I2S_CONTROLLER_TYPE),
|
||||
// driver/i2s_std.h
|
||||
ESP_ELFSYM_EXPORT(i2s_channel_init_std_mode),
|
||||
ESP_ELFSYM_EXPORT(i2s_channel_reconfig_std_clock),
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace tt {
|
||||
#ifdef CONFIG_ESP_WIFI_ENABLED
|
||||
|
||||
static CpuAffinity getEspWifiAffinity() {
|
||||
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 1
|
||||
#if CONFIG_SOC_CPU_CORES_NUM == 1
|
||||
return 0;
|
||||
#elif defined(CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0)
|
||||
return 0;
|
||||
@@ -28,7 +28,7 @@ static CpuAffinity getEspWifiAffinity() {
|
||||
|
||||
// Warning: Must watch ESP WiFi, as this task is used by WiFi
|
||||
static CpuAffinity getEspMainSchedulerAffinity() {
|
||||
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 1
|
||||
#if CONFIG_SOC_CPU_CORES_NUM == 1
|
||||
return 0;
|
||||
#elif defined(CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0)
|
||||
return 0;
|
||||
@@ -41,7 +41,7 @@ static CpuAffinity getEspMainSchedulerAffinity() {
|
||||
}
|
||||
|
||||
static CpuAffinity getFreeRtosTimerAffinity() {
|
||||
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 1
|
||||
#if CONFIG_SOC_CPU_CORES_NUM == 1
|
||||
return 0;
|
||||
#elif defined(CONFIG_FREERTOS_TIMER_TASK_NO_AFFINITY)
|
||||
return None;
|
||||
@@ -50,11 +50,11 @@ static CpuAffinity getFreeRtosTimerAffinity() {
|
||||
#elif defined(CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU1)
|
||||
return 1;
|
||||
#else
|
||||
static_assert(false);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 1
|
||||
#if CONFIG_SOC_CPU_CORES_NUM == 1
|
||||
static const CpuAffinityConfiguration esp = {
|
||||
.system = 0,
|
||||
.graphics = 0,
|
||||
@@ -63,7 +63,7 @@ static const CpuAffinityConfiguration esp = {
|
||||
.apps = 0,
|
||||
.timer = getFreeRtosTimerAffinity()
|
||||
};
|
||||
#elif CONFIG_FREERTOS_NUMBER_OF_CORES == 2
|
||||
#elif CONFIG_SOC_CPU_CORES_NUM == 2
|
||||
static const CpuAffinityConfiguration esp = {
|
||||
.system = 0,
|
||||
.graphics = 1,
|
||||
@@ -94,7 +94,7 @@ static const CpuAffinityConfiguration simulator = {
|
||||
const CpuAffinityConfiguration& getCpuAffinityConfiguration() {
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
|
||||
#if CONFIG_SOC_CPU_CORES_NUM == 2
|
||||
// WiFi uses the main dispatcher to defer operations in the background
|
||||
assert(esp.wifi == esp.mainDispatcher);
|
||||
#endif // CORES
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
b581c2abc643da397b98d269bb63a6fed8f7efa94df054b00d3e333c387ddb78
|
||||
@@ -0,0 +1 @@
|
||||
{"version":"1.0","algorithm":"sha256","created_at":"2025-11-29T02:16:24.972824+00:00","files":[{"path":"CMakeLists.txt","size":115,"hash":"ddcc34d3ac2ee5238581367fc4fd5d564d568f224dc47bc7718424c96775bc57"},{"path":"README.md","size":2415,"hash":"589710be7e62dac281b4bbc1261615b77a8e8247ac7e80af867ef772508b7f5f"},{"path":"esp_lcd_touch_ft6x36.c","size":12037,"hash":"42ec067b1ebb135f75ab8eb9a73b557037e72e39a62047117353d9b00e98d369"},{"path":"idf_component.yml","size":409,"hash":"2f7bf7b2b3218704fbc383c445a162c3bf62b39eede92de824b2fec9992e5cec"},{"path":"license.txt","size":11560,"hash":"3ddf9be5c28fe27dad143a5dc76eea25222ad1dd68934a047064e56ed2fa40c5"},{"path":"include/esp_lcd_touch_ft6x36.h","size":1698,"hash":"d5c5c521ccf4784cf3aca293ff671c55786565ee9301532bb887adac4129160a"}]}
|
||||
@@ -0,0 +1,5 @@
|
||||
idf_component_register(
|
||||
SRCS "esp_lcd_touch_ft6x36.c"
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES "esp_lcd"
|
||||
)
|
||||
@@ -0,0 +1,67 @@
|
||||
# ESP LCD Touch FT6x36 Controller
|
||||
|
||||
[](https://components.espressif.com/components/lambage/esp_lcd_touch_ft6x36)
|
||||
|
||||
This repository is forked from https://github.com/cfscn/esp_lcd_touch_ft6x36
|
||||
|
||||
Implementation of the FT6x36 touch controller with esp_lcd_touch component.
|
||||
|
||||
| Touch controller | Communication interface | Component name | Link to datasheet |
|
||||
| :--------------: | :---------------------: | :------------: | :---------------: |
|
||||
| FT6x36 | I2C | esp_lcd_touch_ft6x36 | [PDF](https://www.buydisplay.com/download/ic/FT6236-FT6336-FT6436L-FT6436_Datasheet.pdf) |
|
||||
|
||||
[^1]: **NOTE:** This controller should work via I2C or SPI communication interface. But it was tested on HW only via I2C communication interface.
|
||||
|
||||
## Add to project
|
||||
|
||||
Packages from this repository are uploaded to [Espressif's component service](https://components.espressif.com/).
|
||||
You can add them to your project via `idf.py add-dependancy`, e.g.
|
||||
```
|
||||
idf.py add-dependency esp_lcd_touch_ft6x36==1.0.0
|
||||
```
|
||||
|
||||
Alternatively, you can create `idf_component.yml`. More is in [Espressif's documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html).
|
||||
|
||||
## Example use
|
||||
|
||||
I2C initialization of the touch component.
|
||||
|
||||
```
|
||||
esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_FT6x36_CONFIG();
|
||||
|
||||
esp_lcd_touch_config_t tp_cfg = {
|
||||
.x_max = CONFIG_LCD_HRES,
|
||||
.y_max = CONFIG_LCD_VRES,
|
||||
.rst_gpio_num = -1,
|
||||
.int_gpio_num = -1,
|
||||
.levels = {
|
||||
.reset = 0,
|
||||
.interrupt = 0,
|
||||
},
|
||||
.flags = {
|
||||
.swap_xy = 0,
|
||||
.mirror_x = 0,
|
||||
.mirror_y = 0,
|
||||
},
|
||||
};
|
||||
|
||||
esp_lcd_touch_handle_t tp;
|
||||
esp_lcd_touch_new_i2c_ft6x36(io_handle, &tp_cfg, &tp);
|
||||
```
|
||||
|
||||
Read data from the touch controller and store it in RAM memory. It should be called regularly in poll.
|
||||
|
||||
```
|
||||
esp_lcd_touch_read_data(tp);
|
||||
```
|
||||
|
||||
Get one X and Y coordinates with strength of touch.
|
||||
|
||||
```
|
||||
uint16_t touch_x[1];
|
||||
uint16_t touch_y[1];
|
||||
uint16_t touch_strength[1];
|
||||
uint8_t touch_cnt = 0;
|
||||
|
||||
bool touchpad_pressed = esp_lcd_touch_get_coordinates(tp, touch_x, touch_y, touch_strength, &touch_cnt, 1);
|
||||
```
|
||||
@@ -0,0 +1,358 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 CFSoft Systems (Chengdu) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_check.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_touch.h"
|
||||
|
||||
static const char *TAG = "FT6x36";
|
||||
|
||||
/* Registers */
|
||||
#define FT62XX_G_FT5201ID 0xA8 // FocalTech's panel ID
|
||||
#define FT62XX_REG_NUMTOUCHES 0x02 // Number of touch points
|
||||
|
||||
#define FT62XX_NUM_X 0x33 // Touch X position
|
||||
#define FT62XX_NUM_Y 0x34 // Touch Y position
|
||||
|
||||
#define FT62XX_REG_MODE 0x00 // Device mode, either WORKING or FACTORY
|
||||
#define FT62XX_REG_READDATA 0x00 // Read data from register
|
||||
#define FT62XX_REG_CALIBRATE 0x02 // Calibrate mode
|
||||
#define FT62XX_REG_WORKMODE 0x00 // Work mode
|
||||
#define FT62XX_REG_FACTORYMODE 0x40 // Factory mode
|
||||
#define FT62XX_REG_THRESHHOLD 0x80 // Threshold for touch detection
|
||||
#define FT62XX_REG_POINTRATE 0x88 // Point rate
|
||||
#define FT62XX_REG_FIRMVERS 0xA6 // Firmware version
|
||||
#define FT62XX_REG_CHIPID 0xA3 // Chip selecting
|
||||
#define FT62XX_REG_VENDID 0xA8 // FocalTech's panel ID
|
||||
|
||||
#define FT62XX_VENDID 0x11 // FocalTech's panel ID
|
||||
#define FT6336_VENDID 0x88 // FocalTech's panel ID
|
||||
#define FT6206_CHIPID 0x06 // Chip selecting
|
||||
#define FT3236_CHIPID 0x33 // Chip selecting
|
||||
#define FT6236_CHIPID 0x36 // Chip selecting
|
||||
#define FT6236U_CHIPID 0x64 // Chip selecting
|
||||
#define FT6336U_CHIPID 0x64 // Chip selecting
|
||||
|
||||
#define FT62XX_DEFAULT_THRESHOLD 60 // Default threshold for touch detection (lowered from 128 to improve sensitivity on battery/floating ground)
|
||||
|
||||
/*******************************************************************************
|
||||
* Function definitions
|
||||
*******************************************************************************/
|
||||
static esp_err_t esp_lcd_touch_ft6x36_read_data(esp_lcd_touch_handle_t tp);
|
||||
static bool esp_lcd_touch_ft6x36_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num);
|
||||
static esp_err_t esp_lcd_touch_ft6x36_del(esp_lcd_touch_handle_t tp);
|
||||
|
||||
/* I2C read */
|
||||
static esp_err_t touch_ft6x36_i2c_write(esp_lcd_touch_handle_t tp, uint8_t reg, uint8_t data);
|
||||
static esp_err_t touch_ft6x36_i2c_read(esp_lcd_touch_handle_t tp, uint8_t reg, uint8_t *data, uint8_t len);
|
||||
|
||||
/* FT6x36 init */
|
||||
static esp_err_t touch_ft6x36_init(esp_lcd_touch_handle_t tp);
|
||||
/* FT6x36 reset */
|
||||
static esp_err_t touch_ft6x36_reset(esp_lcd_touch_handle_t tp);
|
||||
|
||||
/*******************************************************************************
|
||||
* Public API functions
|
||||
*******************************************************************************/
|
||||
|
||||
esp_err_t esp_lcd_touch_new_i2c_ft6x36(const esp_lcd_panel_io_handle_t io, const esp_lcd_touch_config_t *config, esp_lcd_touch_handle_t *out_touch)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
assert(config != NULL);
|
||||
assert(out_touch != NULL);
|
||||
|
||||
/* Prepare main structure */
|
||||
esp_lcd_touch_handle_t esp_lcd_touch_ft6x36 = heap_caps_calloc(1, sizeof(esp_lcd_touch_t), MALLOC_CAP_DEFAULT);
|
||||
ESP_GOTO_ON_FALSE(esp_lcd_touch_ft6x36, ESP_ERR_NO_MEM, err, TAG, "no mem for FT6x36 controller");
|
||||
|
||||
/* Communication interface */
|
||||
esp_lcd_touch_ft6x36->io = io;
|
||||
|
||||
/* Only supported callbacks are set */
|
||||
esp_lcd_touch_ft6x36->read_data = esp_lcd_touch_ft6x36_read_data;
|
||||
esp_lcd_touch_ft6x36->get_xy = esp_lcd_touch_ft6x36_get_xy;
|
||||
esp_lcd_touch_ft6x36->del = esp_lcd_touch_ft6x36_del;
|
||||
|
||||
/* Mutex */
|
||||
esp_lcd_touch_ft6x36->data.lock.owner = portMUX_FREE_VAL;
|
||||
|
||||
/* Save config */
|
||||
memcpy(&esp_lcd_touch_ft6x36->config, config, sizeof(esp_lcd_touch_config_t));
|
||||
|
||||
/* Prepare pin for touch interrupt */
|
||||
if (esp_lcd_touch_ft6x36->config.int_gpio_num != GPIO_NUM_NC)
|
||||
{
|
||||
const gpio_config_t int_gpio_config = {
|
||||
.mode = GPIO_MODE_INPUT,
|
||||
.intr_type = (esp_lcd_touch_ft6x36->config.levels.interrupt ? GPIO_INTR_POSEDGE : GPIO_INTR_NEGEDGE),
|
||||
.pin_bit_mask = BIT64(esp_lcd_touch_ft6x36->config.int_gpio_num)};
|
||||
ret = gpio_config(&int_gpio_config);
|
||||
ESP_GOTO_ON_ERROR(ret, err, TAG, "GPIO config failed");
|
||||
|
||||
/* Register interrupt callback */
|
||||
if (esp_lcd_touch_ft6x36->config.interrupt_callback)
|
||||
{
|
||||
esp_lcd_touch_register_interrupt_callback(esp_lcd_touch_ft6x36, esp_lcd_touch_ft6x36->config.interrupt_callback);
|
||||
}
|
||||
}
|
||||
|
||||
/* Prepare pin for touch controller reset */
|
||||
if (esp_lcd_touch_ft6x36->config.rst_gpio_num != GPIO_NUM_NC)
|
||||
{
|
||||
const gpio_config_t rst_gpio_config = {
|
||||
.mode = GPIO_MODE_OUTPUT,
|
||||
.pin_bit_mask = BIT64(esp_lcd_touch_ft6x36->config.rst_gpio_num)};
|
||||
ret = gpio_config(&rst_gpio_config);
|
||||
ESP_GOTO_ON_ERROR(ret, err, TAG, "GPIO config failed");
|
||||
}
|
||||
|
||||
/* Reset controller */
|
||||
ret = touch_ft6x36_reset(esp_lcd_touch_ft6x36);
|
||||
ESP_GOTO_ON_ERROR(ret, err, TAG, "FT6x36 reset failed");
|
||||
|
||||
/* Init controller */
|
||||
ret = touch_ft6x36_init(esp_lcd_touch_ft6x36);
|
||||
ESP_GOTO_ON_ERROR(ret, err, TAG, "FT6x36 init failed");
|
||||
|
||||
*out_touch = esp_lcd_touch_ft6x36;
|
||||
|
||||
err:
|
||||
if (ret != ESP_OK)
|
||||
{
|
||||
ESP_LOGE(TAG, "Error (0x%x)! Touch controller FT6x36 initialization failed!", ret);
|
||||
if (esp_lcd_touch_ft6x36)
|
||||
{
|
||||
esp_lcd_touch_ft6x36_del(esp_lcd_touch_ft6x36);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t esp_lcd_touch_ft6x36_read_data(esp_lcd_touch_handle_t tp)
|
||||
{
|
||||
esp_err_t err;
|
||||
uint8_t data[16];
|
||||
uint8_t points, touches;
|
||||
size_t i = 0;
|
||||
|
||||
assert(tp != NULL);
|
||||
|
||||
/* Read number of touched points */
|
||||
err = touch_ft6x36_i2c_read(tp, FT62XX_REG_NUMTOUCHES, &points, 1);
|
||||
ESP_RETURN_ON_ERROR(err, TAG, "I2C read error!");
|
||||
|
||||
if (points > 2 || points == 0)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/* Number of touched points */
|
||||
points = (points > CONFIG_ESP_LCD_TOUCH_MAX_POINTS ? CONFIG_ESP_LCD_TOUCH_MAX_POINTS : points);
|
||||
|
||||
err = touch_ft6x36_i2c_read(tp, FT62XX_REG_READDATA, data, 16);
|
||||
ESP_RETURN_ON_ERROR(err, TAG, "I2C read error!");
|
||||
|
||||
/* Number of touched points */
|
||||
touches = data[0x02];
|
||||
|
||||
/* Check if the number of touched points is correct */
|
||||
if (points != touches)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
portENTER_CRITICAL(&tp->data.lock);
|
||||
|
||||
/* Number of touched points */
|
||||
tp->data.points = points;
|
||||
|
||||
/* Fill all coordinates */
|
||||
for (i = 0; i < points; i++)
|
||||
{
|
||||
tp->data.coords[i].x = ((data[0x03 + i * 6] & 0x0F) << 8) | data[0x04 + i * 6];
|
||||
tp->data.coords[i].y = ((data[0x05 + i * 6] & 0x0F) << 8) | data[0x06 + i * 6];
|
||||
}
|
||||
|
||||
portEXIT_CRITICAL(&tp->data.lock);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static bool esp_lcd_touch_ft6x36_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num)
|
||||
{
|
||||
assert(tp != NULL);
|
||||
assert(x != NULL);
|
||||
assert(y != NULL);
|
||||
assert(point_num != NULL);
|
||||
assert(max_point_num > 0);
|
||||
|
||||
portENTER_CRITICAL(&tp->data.lock);
|
||||
|
||||
/* Count of points */
|
||||
*point_num = (tp->data.points > max_point_num ? max_point_num : tp->data.points);
|
||||
|
||||
for (size_t i = 0; i < *point_num; i++)
|
||||
{
|
||||
x[i] = tp->data.coords[i].x;
|
||||
y[i] = tp->data.coords[i].y;
|
||||
|
||||
if (strength)
|
||||
{
|
||||
strength[i] = tp->data.coords[i].strength;
|
||||
}
|
||||
}
|
||||
|
||||
/* Invalidate */
|
||||
tp->data.points = 0;
|
||||
|
||||
portEXIT_CRITICAL(&tp->data.lock);
|
||||
|
||||
return (*point_num > 0);
|
||||
}
|
||||
|
||||
static esp_err_t esp_lcd_touch_ft6x36_del(esp_lcd_touch_handle_t tp)
|
||||
{
|
||||
assert(tp != NULL);
|
||||
|
||||
/* Reset GPIO pin settings */
|
||||
if (tp->config.int_gpio_num != GPIO_NUM_NC)
|
||||
{
|
||||
gpio_reset_pin(tp->config.int_gpio_num);
|
||||
if (tp->config.interrupt_callback)
|
||||
{
|
||||
gpio_isr_handler_remove(tp->config.int_gpio_num);
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset GPIO pin settings */
|
||||
if (tp->config.rst_gpio_num != GPIO_NUM_NC)
|
||||
{
|
||||
gpio_reset_pin(tp->config.rst_gpio_num);
|
||||
}
|
||||
|
||||
free(tp);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Private API function
|
||||
*******************************************************************************/
|
||||
|
||||
static esp_err_t touch_ft6x36_init(esp_lcd_touch_handle_t tp)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
uint8_t vend_id, chip_id, firm_vers, point_rate, thresh, reg_val;
|
||||
|
||||
assert(tp != NULL);
|
||||
|
||||
/* Read vendor ID */
|
||||
ESP_RETURN_ON_ERROR(touch_ft6x36_i2c_read(tp, FT62XX_REG_VENDID, &vend_id, 1), TAG, "Read vendor ID error");
|
||||
|
||||
/* Read chip ID */
|
||||
ESP_RETURN_ON_ERROR(touch_ft6x36_i2c_read(tp, FT62XX_REG_CHIPID, &chip_id, 1), TAG, "Read chip ID error");
|
||||
|
||||
/* Read firmware version */
|
||||
ESP_RETURN_ON_ERROR(touch_ft6x36_i2c_read(tp, FT62XX_REG_FIRMVERS, &firm_vers, 1), TAG, "Read firmware version error");
|
||||
|
||||
/* Read point rate */
|
||||
ESP_RETURN_ON_ERROR(touch_ft6x36_i2c_read(tp, FT62XX_REG_POINTRATE, &point_rate, 1), TAG, "Read point rate error");
|
||||
|
||||
/* Read threshold */
|
||||
ESP_RETURN_ON_ERROR(touch_ft6x36_i2c_read(tp, FT62XX_REG_THRESHHOLD, &thresh, 1), TAG, "Read threshold error");
|
||||
|
||||
/* Print out the values */
|
||||
ESP_LOGI(TAG, "Vend ID: 0x%02X", vend_id);
|
||||
ESP_LOGI(TAG, "Chip ID: 0x%02X", chip_id);
|
||||
ESP_LOGI(TAG, "Firm V: %d", firm_vers);
|
||||
ESP_LOGI(TAG, "Point Rate Hz: %d", point_rate);
|
||||
ESP_LOGI(TAG, "Thresh: %d", thresh);
|
||||
|
||||
/* Dump all registers */
|
||||
ESP_LOGI(TAG, "Dumping all registers:");
|
||||
for (int16_t i = 0; i < 0x10; i++)
|
||||
{
|
||||
/* Read register */
|
||||
if (touch_ft6x36_i2c_read(tp, i, ®_val, 1) == ESP_OK)
|
||||
{
|
||||
ESP_LOGI(TAG, "I2C $%02X = 0x%02X", i, reg_val);
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE(TAG, "Failed to read register 0x%02X", i);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the values are valid */
|
||||
if (vend_id != FT62XX_VENDID && vend_id != FT6336_VENDID)
|
||||
{
|
||||
ESP_LOGE(TAG, "Invalid vendor ID: 0x%02X", vend_id);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
/* Check if the chip ID is supported */
|
||||
if (chip_id != FT6206_CHIPID && chip_id != FT6236_CHIPID && chip_id != FT6236U_CHIPID && chip_id != FT6336U_CHIPID && chip_id != FT3236_CHIPID)
|
||||
{
|
||||
ESP_LOGE(TAG, "Unsupported chip ID: 0x%02X", chip_id);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
/* Set to work mode */
|
||||
ret |= touch_ft6x36_i2c_write(tp, FT62XX_REG_MODE, FT62XX_REG_WORKMODE);
|
||||
|
||||
/* Set threshold */
|
||||
ret |= touch_ft6x36_i2c_write(tp, FT62XX_REG_THRESHHOLD, FT62XX_DEFAULT_THRESHOLD);
|
||||
|
||||
/* Set point rate */
|
||||
ret |= touch_ft6x36_i2c_write(tp, FT62XX_REG_POINTRATE, 0x0E);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Reset controller */
|
||||
static esp_err_t touch_ft6x36_reset(esp_lcd_touch_handle_t tp)
|
||||
{
|
||||
assert(tp != NULL);
|
||||
|
||||
if (tp->config.rst_gpio_num != GPIO_NUM_NC)
|
||||
{
|
||||
ESP_RETURN_ON_ERROR(gpio_set_level(tp->config.rst_gpio_num, tp->config.levels.reset), TAG, "GPIO set level error!");
|
||||
vTaskDelay(pdMS_TO_TICKS(20));
|
||||
ESP_RETURN_ON_ERROR(gpio_set_level(tp->config.rst_gpio_num, !tp->config.levels.reset), TAG, "GPIO set level error!");
|
||||
vTaskDelay(pdMS_TO_TICKS(500));
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t touch_ft6x36_i2c_write(esp_lcd_touch_handle_t tp, uint8_t reg, uint8_t data)
|
||||
{
|
||||
assert(tp != NULL);
|
||||
|
||||
// *INDENT-OFF*
|
||||
/* Write data */
|
||||
return esp_lcd_panel_io_tx_param(tp->io, reg, (uint8_t[]){data}, 1);
|
||||
// *INDENT-ON*
|
||||
}
|
||||
|
||||
static esp_err_t touch_ft6x36_i2c_read(esp_lcd_touch_handle_t tp, uint8_t reg, uint8_t *data, uint8_t len)
|
||||
{
|
||||
assert(tp != NULL);
|
||||
assert(data != NULL);
|
||||
|
||||
/* Read data */
|
||||
return esp_lcd_panel_io_rx_param(tp->io, reg, data, len);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
dependencies:
|
||||
esp_lcd_touch:
|
||||
public: true
|
||||
version: ^1.0.4
|
||||
idf: '>=4.4.2'
|
||||
description: ESP LCD Touch FT6x36 - touch controller FT6x36
|
||||
repository: git://github.com/lambage/esp_lcd_touch_ft6x36.git
|
||||
repository_info:
|
||||
commit_sha: c2772def5d1168bb3ba85c1334dd07ea99b977ec
|
||||
path: components/esp_lcd_touch_ft6x36
|
||||
url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch
|
||||
version: 1.0.8
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 CFSoft Systems (Chengdu) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief ESP LCD touch: FT6x36
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_lcd_touch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Create a new FT6x36 touch driver
|
||||
*
|
||||
* @note The I2C communication should be initialized before use this function.
|
||||
*
|
||||
* @param io LCD/Touch panel IO handle
|
||||
* @param config: Touch configuration
|
||||
* @param out_touch: Touch instance handle
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NO_MEM if there is no memory for allocating main structure
|
||||
*/
|
||||
esp_err_t esp_lcd_touch_new_i2c_ft6x36(const esp_lcd_panel_io_handle_t io, const esp_lcd_touch_config_t *config, esp_lcd_touch_handle_t *out_touch);
|
||||
|
||||
/**
|
||||
* @brief I2C address of the FT6x36 controller
|
||||
*
|
||||
*/
|
||||
#define ESP_LCD_TOUCH_IO_I2C_FT6x36_ADDRESS (0x38)
|
||||
|
||||
/**
|
||||
* @brief Touch IO configuration structure
|
||||
*
|
||||
*/
|
||||
#define ESP_LCD_TOUCH_IO_I2C_FT6x36_CONFIG() \
|
||||
{ \
|
||||
.dev_addr = ESP_LCD_TOUCH_IO_I2C_FT6x36_ADDRESS, \
|
||||
.control_phase_bytes = 1, \
|
||||
.dc_bit_offset = 0, \
|
||||
.lcd_cmd_bits = 8, \
|
||||
.flags = \
|
||||
{ \
|
||||
.disable_control_phase = 1, \
|
||||
} \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1 @@
|
||||
b702d642e03e95928046d5c6726558e6444e112420c77efa5fdb6650b0a13c5d
|
||||
@@ -0,0 +1,27 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project (lv_emscripten)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -s USE_SDL=2")
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR})
|
||||
|
||||
add_subdirectory(lvgl)
|
||||
file(GLOB MY_SOURCES "./*.c")
|
||||
set(SOURCES ${MY_SOURCES})
|
||||
|
||||
add_executable(index ${SOURCES} ${INCLUDES})
|
||||
|
||||
if(NOT LVGL_CHOSEN_DEMO)
|
||||
set(LVGL_CHOSEN_DEMO lv_demo_widgets)
|
||||
endif()
|
||||
set_source_files_properties(main.c PROPERTIES COMPILE_FLAGS -DCHOSEN_DEMO=${LVGL_CHOSEN_DEMO})
|
||||
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
target_link_libraries(index
|
||||
lvgl
|
||||
lvgl_examples
|
||||
lvgl_demos
|
||||
lvgl_thorvg
|
||||
SDL2
|
||||
)
|
||||
set_target_properties(index PROPERTIES LINK_FLAGS "--shell-file ${PROJECT_SOURCE_DIR}/lvgl/.devcontainer/lvgl_shell.html -s SINGLE_FILE=1")
|
||||
@@ -0,0 +1,5 @@
|
||||
cd build
|
||||
emcmake cmake ..
|
||||
emmake make -j$(nproc)
|
||||
echo "Built succesfully, opening index.html"
|
||||
code index.html
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**",
|
||||
"/usr/local/emsdk/upstream/emscripten/cache/sysroot/include/"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/clang",
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "c++14",
|
||||
"intelliSenseMode": "linux-clang-x64"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
|
||||
/**
|
||||
* @file main
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#define SDL_MAIN_HANDLED /*To fix SDL's "undefined reference to WinMain" issue*/
|
||||
#include <SDL2/SDL.h>
|
||||
#include <emscripten.h>
|
||||
#include "lvgl/lvgl.h"
|
||||
#include "lvgl/demos/lv_demos.h"
|
||||
#include "lvgl/examples/lv_examples.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/*On OSX SDL needs different handling*/
|
||||
#if defined(__APPLE__) && defined(TARGET_OS_MAC)
|
||||
# if __APPLE__ && TARGET_OS_MAC
|
||||
#define SDL_APPLE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void hal_init(void);
|
||||
static int tick_thread(void * data);
|
||||
static void memory_monitor(lv_timer_t * param);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_display_t * disp1;
|
||||
|
||||
int monitor_hor_res, monitor_ver_res;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
void do_loop(void *arg);
|
||||
|
||||
/* Allows disabling CHOSEN_DEMO */
|
||||
static void lv_example_noop(void) {
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
|
||||
monitor_hor_res = 800;
|
||||
monitor_ver_res = 480;
|
||||
printf("Starting with screen resolution of %dx%d px\n", monitor_hor_res, monitor_ver_res);
|
||||
|
||||
/*Initialize LittlevGL*/
|
||||
lv_init();
|
||||
|
||||
/*Initialize the HAL (display, input devices, tick) for LittlevGL*/
|
||||
hal_init();
|
||||
|
||||
lv_demo_widgets();
|
||||
|
||||
emscripten_set_main_loop_arg(do_loop, NULL, -1, true);
|
||||
}
|
||||
|
||||
void do_loop(void *arg)
|
||||
{
|
||||
/* Periodically call the lv_timer handler.
|
||||
* It could be done in a timer interrupt or an OS task too.*/
|
||||
lv_timer_handler();
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the Hardware Abstraction Layer (HAL) for the Littlev graphics library
|
||||
*/
|
||||
static void hal_init(void)
|
||||
{
|
||||
lv_display_t * disp = lv_sdl_window_create(monitor_hor_res, monitor_ver_res);
|
||||
|
||||
lv_group_t * g = lv_group_create();
|
||||
lv_group_set_default(g);
|
||||
|
||||
lv_sdl_mouse_create();
|
||||
lv_indev_t * mousewheel = lv_sdl_mousewheel_create();
|
||||
lv_indev_set_group(mousewheel, lv_group_get_default());
|
||||
|
||||
lv_indev_t * keyboard = lv_sdl_keyboard_create();
|
||||
lv_indev_set_group(keyboard, lv_group_get_default());
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"sdl.h": "c"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"image": "mcr.microsoft.com/devcontainers/universal:2",
|
||||
"features": {
|
||||
"ghcr.io/ebaskoro/devcontainer-features/emscripten:1": {}
|
||||
},
|
||||
"postCreateCommand": "chmod +x /workspace/lvgl_app/lvgl/.devcontainer/setup.sh; /workspace/lvgl_app/lvgl/.devcontainer/setup.sh",
|
||||
"postStartCommand": ". /usr/local/emsdk/emsdk_env.sh;",
|
||||
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
// Configure properties specific to VS Code.
|
||||
"vscode": {
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": [
|
||||
//"searKing.preview-vscode"
|
||||
"analytic-signal.preview-html"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
"hostRequirements": {
|
||||
"cpus": 4
|
||||
},
|
||||
|
||||
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace/lvgl_app/lvgl,type=bind",
|
||||
"workspaceFolder": "/workspace/lvgl_app"
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
LV_COLOR_DEPTH 32
|
||||
LV_MEM_SIZE (1024 * 1024)
|
||||
LV_DRAW_THREAD_STACK_SIZE (64 * 1024)
|
||||
LV_USE_MATRIX 1
|
||||
LV_USE_FLOAT 1
|
||||
LV_USE_LOTTIE 1
|
||||
|
||||
LV_USE_DRAW_SW_COMPLEX_GRADIENTS 1
|
||||
LV_OBJ_STYLE_CACHE 1
|
||||
LV_USE_LOG 1
|
||||
LV_LOG_PRINTF 1
|
||||
LV_USE_PERF_MONITOR 1
|
||||
LV_USE_SYSMON 1
|
||||
|
||||
LV_USE_ASSERT_MEM_INTEGRITY 1
|
||||
LV_USE_ASSERT_OBJ 1
|
||||
LV_USE_ASSERT_STYLE 1
|
||||
LV_FONT_MONTSERRAT_12 1
|
||||
LV_FONT_MONTSERRAT_14 1
|
||||
LV_FONT_MONTSERRAT_16 1
|
||||
LV_FONT_MONTSERRAT_18 1
|
||||
LV_FONT_MONTSERRAT_20 1
|
||||
LV_FONT_MONTSERRAT_22 1
|
||||
LV_FONT_MONTSERRAT_24 1
|
||||
LV_FONT_MONTSERRAT_26 1
|
||||
LV_FONT_MONTSERRAT_28 1
|
||||
LV_FONT_MONTSERRAT_30 1
|
||||
LV_FONT_MONTSERRAT_32 1
|
||||
LV_FONT_MONTSERRAT_34 1
|
||||
LV_FONT_MONTSERRAT_36 1
|
||||
LV_FONT_MONTSERRAT_38 1
|
||||
LV_FONT_MONTSERRAT_40 1
|
||||
LV_FONT_MONTSERRAT_42 1
|
||||
LV_FONT_MONTSERRAT_44 1
|
||||
LV_FONT_MONTSERRAT_46 1
|
||||
LV_FONT_MONTSERRAT_48 1
|
||||
LV_FONT_MONTSERRAT_28_COMPRESSED 1
|
||||
LV_FONT_DEJAVU_16_PERSIAN_HEBREW 1
|
||||
LV_FONT_SOURCE_HAN_SANS_SC_16_CJK 1
|
||||
LV_FONT_UNSCII_8 1
|
||||
|
||||
LV_USE_IMGFONT 1
|
||||
LV_USE_FS_STDIO 1
|
||||
LV_FS_STDIO_LETTER 'A'
|
||||
LV_USE_FS_MEMFS 1
|
||||
LV_FS_MEMFS_LETTER 'M'
|
||||
LV_USE_THORVG_INTERNAL 1
|
||||
LV_USE_LZ4_INTERNAL 1
|
||||
LV_USE_VECTOR_GRAPHIC 1
|
||||
LV_USE_TINY_TTF 1
|
||||
LV_USE_BARCODE 1
|
||||
LV_USE_QRCODE 1
|
||||
LV_USE_RLE 1
|
||||
LV_BIN_DECODER_RAM_LOAD 1
|
||||
LV_USE_TJPGD 1
|
||||
LV_USE_BMP 1
|
||||
LV_USE_LODEPNG 1
|
||||
LV_USE_SDL 1
|
||||
|
||||
LV_USE_DEMO_WIDGETS 1
|
||||
LV_USE_DEMO_KEYPAD_AND_ENCODER 1
|
||||
LV_USE_DEMO_BENCHMARK 1
|
||||
LV_USE_DEMO_RENDER 1
|
||||
LV_USE_DEMO_STRESS 1
|
||||
LV_USE_DEMO_MUSIC 1
|
||||
LV_USE_DEMO_FLEX_LAYOUT 1
|
||||
LV_USE_DEMO_MULTILANG 1
|
||||
LV_USE_DEMO_TRANSFORM 1
|
||||
LV_USE_DEMO_SCROLL 1
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user