Compare commits

...

6 Commits

Author SHA1 Message Date
Ken Van Hoeylandt
f45f809c9b Add AXP192 driver 2025-10-13 21:52:53 +02:00
Ken Van Hoeylandt
0513037dbf Renamed Core2 external ports 2025-10-13 21:52:25 +02:00
Ken Van Hoeylandt
a63a78e959 Improved button margin setting for vertical layouts 2025-10-12 16:49:13 +02:00
Ken Van Hoeylandt
00f2e3b88e Don't add SD card service if no SD card is present in the configuration 2025-10-12 16:48:45 +02:00
Ken Van Hoeylandt
20c4e6d3ab Create separate project for AXP192 driver 2025-10-12 14:47:32 +02:00
Ken Van Hoeylandt
e23b956cf4 Implement LilyGO T-Dongle S3
+ fix issue with apps installed in /data
+ implement SDMMC driver
+ implement ST7735 driver
2025-10-11 16:29:57 +02:00
65 changed files with 2106 additions and 19 deletions

View File

@ -0,0 +1,7 @@
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
idf_component_register(
SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Source"
REQUIRES Tactility EspLcdCompat ST7735 GT911 PwmBacklight driver
)

View File

@ -0,0 +1,15 @@
#include "PwmBacklight.h"
#include "Tactility/service/gps/GpsService.h"
#include <Tactility/TactilityCore.h>
#define TAG "T-Dongle"
bool initBoot() {
if (!driver::pwmbacklight::init(GPIO_NUM_38, 12000)) {
TT_LOG_E(TAG, "Backlight init failed");
return false;
}
return true;
}

View File

@ -0,0 +1,92 @@
#include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
#include "devices/Display.h"
#include "devices/Sdcard.h"
#define TDECK_SPI_TRANSFER_SIZE_LIMIT (80 * 160 * (LV_COLOR_DEPTH / 8))
bool initBoot();
using namespace tt::hal;
static std::vector<std::shared_ptr<Device>> createDevices() {
return {
createDisplay(),
createSdCard()
};
}
extern const Configuration lilygo_tdongle_s3 = {
.initBoot = initBoot,
.uiScale = UiScale::Smallest,
.createDevices = createDevices,
.i2c = {
i2c::Configuration {
.name = "STEMMA QT",
.port = I2C_NUM_0,
.initMode = i2c::InitMode::ByTactility,
.isMutable = false,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_44,
.scl_io_num = GPIO_NUM_43,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
}
},
.spi {
spi::Configuration {
.device = SPI3_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_3,
.miso_io_num = GPIO_NUM_NC,
.sclk_io_num = GPIO_NUM_5,
.quadwp_io_num = GPIO_NUM_NC,
.data4_io_num = GPIO_NUM_NC,
.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 = TDECK_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = spi::InitMode::ByTactility,
.isMutable = false,
.lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display
},
},
.uart {
uart::Configuration {
.name = "STEMMA QT",
.port = UART_NUM_1,
.rxPin = GPIO_NUM_44,
.txPin = GPIO_NUM_43,
.rtsPin = GPIO_NUM_NC,
.ctsPin = GPIO_NUM_NC,
.rxBufferSize = 1024,
.txBufferSize = 1024,
.config = {
.baud_rate = 38400,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_DEFAULT,
.flags = {
.allow_pd = 0,
.backup_before_sleep = 0,
}
}
}
}
};

View File

@ -0,0 +1,5 @@
#pragma once
#include <Tactility/hal/Configuration.h>
extern const tt::hal::Configuration lilygo_tdongle_s3;

View File

@ -0,0 +1,36 @@
#include "Display.h"
#include <PwmBacklight.h>
#include <St7735Display.h>
#define LCD_SPI_HOST SPI3_HOST
#define LCD_PIN_CS GPIO_NUM_4
#define LCD_PIN_DC GPIO_NUM_2
#define LCD_PIN_RESET GPIO_NUM_1
#define LCD_HORIZONTAL_RESOLUTION 80
#define LCD_VERTICAL_RESOLUTION 160
#define LCD_SPI_TRANSFER_HEIGHT LCD_VERTICAL_RESOLUTION / 4
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto configuration = std::make_unique<St7735Display::Configuration>(
LCD_SPI_HOST,
LCD_PIN_CS,
LCD_PIN_DC,
LCD_PIN_RESET,
80,
160,
nullptr,
false,
false,
false,
true,
0,
26,
1
);
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
auto display = std::make_shared<St7735Display>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
}

View File

@ -0,0 +1,5 @@
#pragma once
#include <Tactility/hal/display/DisplayDevice.h>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -0,0 +1,22 @@
#include "Sdcard.h"
#include <Tactility/hal/sdcard/SdmmcDevice.h>
#include <Tactility/lvgl/LvglSync.h>
using tt::hal::sdcard::SdmmcDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SdmmcDevice::Config>(
GPIO_NUM_12,
GPIO_NUM_16,
GPIO_NUM_14,
GPIO_NUM_17,
GPIO_NUM_21,
GPIO_NUM_18,
SdCardDevice::MountBehaviour::AtBoot
);
return std::make_shared<SdmmcDevice>(
std::move(configuration)
);
}

View File

@ -0,0 +1,7 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();

View File

@ -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 ILI934x FT6x36 driver vfs fatfs
REQUIRES Tactility esp_lvgl_port esp_lcd AXP192 ILI934x FT6x36 driver vfs fatfs
)

View File

@ -1,8 +1,7 @@
#include "M5stackCore2.h"
#include "InitBoot.h"
#include "devices/Display.h"
#include "devices/Core2Power.h"
#include "devices/SdCard.h"
#include "devices/Power.h"
#include <lvgl.h>
#include <Tactility/lvgl/LvglSync.h>
@ -11,9 +10,16 @@
using namespace tt::hal;
constexpr auto* TAG = "Core2";
bool initBoot() {
TT_LOG_I(TAG, "initBoot");
return initAxp();
}
static DeviceVector createDevices() {
return {
createPower(),
getAxp192(),
createSdCard(),
createDisplay()
};
@ -41,7 +47,7 @@ extern const Configuration m5stack_core2 = {
}
},
i2c::Configuration {
.name = "External", // (Grove)
.name = "Port A", // Grove
.port = I2C_NUM_1,
.initMode = i2c::InitMode::ByTactility,
.isMutable = true,
@ -85,7 +91,7 @@ extern const Configuration m5stack_core2 = {
},
.uart {
uart::Configuration {
.name = "Grove",
.name = "Port A", // Grove
.port = UART_NUM_1,
.rxPin = GPIO_NUM_32,
.txPin = GPIO_NUM_33,

View File

@ -0,0 +1,35 @@
#include <Axp192.h>
static std::shared_ptr<Axp192> axp192 = nullptr;
std::shared_ptr<Axp192> createAxp192() {
assert(axp192 == nullptr);
auto configuration = std::make_unique<Axp192::Configuration>(I2C_NUM_0);
axp192 = std::make_shared<Axp192>(std::move(configuration));
return axp192;
}
std::shared_ptr<Axp192> getAxp192() {
assert(axp192 != nullptr);
return axp192;
}
bool initAxp() {
const auto axp = createAxp192();
return axp->init([](auto* driver) {
axp192_ioctl(driver, AXP192_LDO2_SET_VOLTAGE, 3300); // LCD + SD
axp192_ioctl(driver, AXP192_LDO3_SET_VOLTAGE, 0); // VIB_MOTOR STOP
axp192_ioctl(driver, AXP192_DCDC3_SET_VOLTAGE, 3300);
axp192_ioctl(driver, AXP192_LDO2_ENABLE);
axp192_ioctl(driver, AXP192_LDO3_DISABLE);
axp192_ioctl(driver, AXP192_DCDC3_ENABLE);
axp192_write(driver, AXP192_PWM1_DUTY_CYCLE_2, 255); // PWM 255 (LED OFF)
axp192_write(driver, AXP192_GPIO1_CONTROL, 0x02); // GPIO1 PWM
// TODO: We could charge at 390mA according to the M5Unified code, but the AXP driver in M5Unified limits to 132mA, so it's unclear what the AXP supports.
return true;
});
}

View File

@ -0,0 +1,9 @@
#pragma once
#include <Axp192.h>
bool initAxp();
// Must call initAxp() first before this returns a non-nullptr response
std::shared_ptr<Axp192> getAxp192();

View File

@ -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 esp_lcd ILI934x FT6x36 driver vfs fatfs
)

View File

@ -0,0 +1,9 @@
# M5Stack Core2
This board implementation concerns the original Core2 hardware and **not** the v1.1 variant.
Reference implementations:
- [ESP-BSP](https://github.com/espressif/esp-bsp/tree/master/bsp/m5stack_core_2)
Docs:
- [M5Stack.com](https://docs.m5stack.com/en/core/Core2)

View File

@ -0,0 +1,111 @@
#include "M5stackCore2.h"
#include "InitBoot.h"
#include "devices/Display.h"
#include "devices/Core2Power.h"
#include "devices/SdCard.h"
#include <lvgl.h>
#include <Tactility/lvgl/LvglSync.h>
#define CORE2_SPI_TRANSFER_SIZE_LIMIT (CORE2_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
using namespace tt::hal;
static DeviceVector createDevices() {
return {
createPower(),
createSdCard(),
createDisplay()
};
}
extern const Configuration m5stack_core2 = {
.initBoot = initBoot,
.createDevices = createDevices,
.i2c = {
i2c::Configuration {
.name = "Internal",
.port = I2C_NUM_0,
.initMode = i2c::InitMode::ByTactility,
.isMutable = false,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_21,
.scl_io_num = GPIO_NUM_22,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
},
i2c::Configuration {
.name = "External", // (Grove)
.port = I2C_NUM_1,
.initMode = i2c::InitMode::ByTactility,
.isMutable = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_32,
.scl_io_num = GPIO_NUM_33,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
}
},
.spi {
spi::Configuration {
.device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_23,
.miso_io_num = GPIO_NUM_38,
.sclk_io_num = GPIO_NUM_18,
.quadwp_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported
.quadhd_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported
.data4_io_num = GPIO_NUM_NC,
.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 = CORE2_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = spi::InitMode::ByTactility,
.isMutable = false,
.lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display
}
},
.uart {
uart::Configuration {
.name = "Grove",
.port = UART_NUM_1,
.rxPin = GPIO_NUM_32,
.txPin = GPIO_NUM_33,
.rtsPin = GPIO_NUM_NC,
.ctsPin = GPIO_NUM_NC,
.rxBufferSize = 1024,
.txBufferSize = 1024,
.config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_DEFAULT,
.flags = {
.allow_pd = 0,
.backup_before_sleep = 0,
}
}
},
}
};

View File

@ -0,0 +1,5 @@
#pragma once
#include <Tactility/hal/Configuration.h>
extern const tt::hal::Configuration m5stack_core2;

View File

@ -0,0 +1,36 @@
#include "Display.h"
#include <Ft6x36Touch.h>
#include <Ili934xDisplay.h>
std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto configuration = std::make_unique<Ft6x36Touch::Configuration>(
I2C_NUM_0,
GPIO_NUM_39,
CORE2_LCD_HORIZONTAL_RESOLUTION,
CORE2_LCD_VERTICAL_RESOLUTION
);
auto touch = std::make_shared<Ft6x36Touch>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::touch::TouchDevice>(touch);
}
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto touch = createTouch();
auto configuration = std::make_unique<Ili934xDisplay::Configuration>(
CORE2_LCD_SPI_HOST,
CORE2_LCD_PIN_CS,
CORE2_LCD_PIN_DC,
CORE2_LCD_HORIZONTAL_RESOLUTION,
CORE2_LCD_VERTICAL_RESOLUTION,
touch,
false,
false,
false,
true
);
auto display = std::make_shared<Ili934xDisplay>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
}

View File

@ -0,0 +1,14 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <memory>
#define CORE2_LCD_SPI_HOST SPI2_HOST
#define CORE2_LCD_PIN_CS GPIO_NUM_5
#define CORE2_LCD_PIN_DC GPIO_NUM_15
#define CORE2_LCD_HORIZONTAL_RESOLUTION 320
#define CORE2_LCD_VERTICAL_RESOLUTION 240
#define CORE2_LCD_DRAW_BUFFER_HEIGHT (CORE2_LCD_VERTICAL_RESOLUTION / 10)
#define CORE2_LCD_DRAW_BUFFER_SIZE (CORE2_LCD_HORIZONTAL_RESOLUTION * CORE2_LCD_DRAW_BUFFER_HEIGHT)
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -0,0 +1,27 @@
#include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h>
constexpr auto CORE2_SDCARD_PIN_CS = GPIO_NUM_4;
constexpr auto CORE2_LCD_PIN_CS = GPIO_NUM_5;
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
CORE2_SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
tt::lvgl::getSyncLock(),
std::vector {
CORE2_LCD_PIN_CS
}
);
return std::make_shared<SpiSdCardDevice>(
std::move(configuration)
);
}

View File

@ -0,0 +1,7 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();

View File

@ -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 FT5x06 AXP2101 AW9523 driver vfs fatfs
)

View File

@ -0,0 +1,7 @@
# M5Stack CoreS3
Reference implementations:
- [ESP-BSP](https://github.com/espressif/esp-bsp/tree/master/bsp/m5stack_core_s3)
Docs:
- [M5Stack.com](https://docs.m5stack.com/en/core/CoreS3)

View File

@ -0,0 +1,153 @@
#include "InitBoot.h"
#include <Tactility/Log.h>
#include <Tactility/kernel/Kernel.h>
constexpr auto* TAG = "CoreS3";
std::shared_ptr<Axp2101> axp2101;
std::shared_ptr<Aw9523> aw9523;
/**
* For details see https://github.com/espressif/esp-bsp/blob/master/bsp/m5stack_core_s3/m5stack_core_s3.c
* and schematic: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/core/K128%20CoreS3/Sch_M5_CoreS3_v1.0.pdf
*/
bool initGpioExpander() {
TT_LOG_I(TAG, "AW9523 init");
/**
* P0 pins:
* 0: Touch reset
* 1: Bus out enable
* 2: AW88298 reset (I2S)
* 3: ES7210 interrupt (Audio ADC)
* 4: SD Card SW(itch on?)
* 5: USB OTG enable
* 6: /
* 7: /
*/
/**
* P1 pins:
* 0: Cam reset
* 1: LCD reset
* 2: Touch interrupt
* 3: AW88298 interrupt (I2S)
* 4: /
* 5: /
* 6: /
* 7: Boost enable
*/
uint8_t p0_state = 0U;
uint8_t p1_state = 0U;
// Enable touch
p0_state |= (1U);
// Bus out enable
p0_state |= (1U << 1U);
// I2S
p0_state |= (1U << 2U);
// SD card
p0_state |= (1U << 4U);
// Enable LCD
p1_state |= (1U << 1U);
// Boost enable
p1_state |= (1U << 7U);
/* AW9523 P0 is in push-pull mode */
if (!aw9523->writeCTL(0x10)) {
TT_LOG_E(TAG, "AW9523: Failed to set CTL");
return false;
}
if (!aw9523->writeP0(p0_state)) {
TT_LOG_E(TAG, "AW9523: Failed to set P0");
return false;
}
if (!aw9523->writeP1(p1_state)) {
TT_LOG_E(TAG, "AW9523: Failed to set P1");
return false;
}
if (axp2101->isVBus()) {
float voltage = 0.0f;
axp2101->getVBusVoltage(voltage);
TT_LOG_I(TAG, "AXP2101: VBus at %.2f", voltage);
} else {
TT_LOG_W(TAG, "AXP2101: VBus disabled");
}
return true;
}
bool initPowerControl() {
TT_LOG_I(TAG, "Init power control (AXP2101)");
// Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/Power_Class.cpp#L61
aw9523->bitOnP1(0b10000000); // SY7088 boost enable
/** AXP2101 usage
Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/README.md?plain=1#L223
| |M5Stack<BR>CoreS3<BR>CoreS3SE| |
|:---------:|:-----------------:|:---------:|
| ALDO1 |VDD 1v8 | ALDO1 |
| ALDO2 |VDDA 3v3 | ALDO2 |
| ALDO3 |CAM 3v3 | ALDO3 |
| ALDO4 |TF 3v3 | ALDO4 |
| BLDO1 |AVDD | BLDO1 |
| BLDO2 |DVDD | BLDO2 |
| DLDO1/DC1 |LCD BL | DLDO1/DC1 |
| DLDO2/DC2 | --- | DLDO2/DC2 |
| BACKUP |RTC BAT | BACKUP |
*/
/**
* 0x92 = ALD01
* 0x93 = ALD02
* 0x94 = ALD03
* 0x95 = ALD04
* 0x96 = BLD01
* 0x97 = BLD02
*
* DCDC1 : 0.7-3.5V 25mV/step 1200mA
* DCDC2 : 0.7-2.275V25mV/step 1600mA
* DCDC3 : 0.7-3.5V 25mV/step 700mA
* LDOio0: 1.8-3.3V, 100mV/step 50mA
* LDO1 : 30mA always on
* LDO2 : 1.8-3.3V 100mV/step 200mA
* LDO3 : 1.8-3.3V 100mV/step 200mA
*/
// Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/Power_Class.cpp#L64
static constexpr uint8_t reg_data_array[] = {
0x90U, 0xBFU, // LDOS ON/OFF control 0 (backlight)
0x92U, 18U -5U, // ALDO1 set to 1.8v // for AW88298
0x93U, 33U -5U, // ALDO2 set to 3.3v // for ES7210
0x94U, 33U -5U, // ALDO3 set to 3.3v // for camera
0x95U, 33U -5U, // ALDO3 set to 3.3v // for TF card slot
0x27, 0x00, // PowerKey Hold=1sec / PowerOff=4sec
0x69, 0x11, // CHGLED setting
0x10, 0x30, // PMU common config
0x30, 0x0F // ADC enabled (for voltage measurement)
};
if (axp2101->setRegisters((uint8_t*)reg_data_array, sizeof(reg_data_array))) {
TT_LOG_I(TAG, "AXP2101 initialized with %d registers", sizeof(reg_data_array) / 2);
return true;
} else {
TT_LOG_E(TAG, "AXP2101: Failed to set registers");
return false;
}
}
bool initBoot() {
TT_LOG_I(TAG, "initBoot()");
axp2101 = std::make_shared<Axp2101>(I2C_NUM_0);
aw9523 = std::make_shared<Aw9523>(I2C_NUM_0);
return initPowerControl() && initGpioExpander();
}

View File

@ -0,0 +1,9 @@
#pragma once
#include <Axp2101.h>
#include <Aw9523.h>
extern std::shared_ptr<Axp2101> axp2101;
extern std::shared_ptr<Aw9523> aw9523;
bool initBoot();

View File

@ -0,0 +1,193 @@
#include "M5stackCoreS3.h"
#include "InitBoot.h"
#include "devices/Display.h"
#include "devices/SdCard.h"
#include <Axp2101Power.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/uart/Uart.h>
#define CORES3_TRANSACTION_SIZE (CORES3_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
using namespace tt::hal;
static DeviceVector createDevices() {
return {
axp2101,
aw9523,
std::make_shared<Axp2101Power>(axp2101),
createSdCard(),
createDisplay()
};
}
const Configuration m5stack_cores3 = {
.initBoot = initBoot,
.createDevices = createDevices,
.i2c = {
i2c::Configuration {
.name = "Internal",
.port = I2C_NUM_0,
.initMode = i2c::InitMode::ByTactility,
.isMutable = false,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_12,
.scl_io_num = GPIO_NUM_11,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
},
i2c::Configuration {
.name = "Port A", // Grove
.port = I2C_NUM_1,
.initMode = i2c::InitMode::Disabled,
.isMutable = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_2,
.scl_io_num = GPIO_NUM_1,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
},
i2c::Configuration {
.name = "Port B", // Grove
.port = I2C_NUM_1,
.initMode = i2c::InitMode::Disabled,
.isMutable = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_9,
.scl_io_num = GPIO_NUM_8,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
},
i2c::Configuration {
.name = "Port C", // Grove
.port = I2C_NUM_1,
.initMode = i2c::InitMode::Disabled,
.isMutable = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_18,
.scl_io_num = GPIO_NUM_17,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
}
},
.spi {
spi::Configuration {
.device = SPI3_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_37,
.miso_io_num = GPIO_NUM_35,
.sclk_io_num = GPIO_NUM_36,
.data2_io_num = GPIO_NUM_NC,
.data3_io_num = GPIO_NUM_NC,
.data4_io_num = GPIO_NUM_NC,
.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 = CORES3_TRANSACTION_SIZE,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = spi::InitMode::ByTactility,
.isMutable = false,
.lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display
}
},
.uart {
uart::Configuration {
.name = "Port A",
.port = UART_NUM_1,
.rxPin = GPIO_NUM_2,
.txPin = GPIO_NUM_1,
.rtsPin = GPIO_NUM_NC,
.ctsPin = GPIO_NUM_NC,
.rxBufferSize = 1024,
.txBufferSize = 1024,
.config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_DEFAULT,
.flags = {
.allow_pd = 0,
.backup_before_sleep = 0,
}
}
},
uart::Configuration {
.name = "Port B",
.port = UART_NUM_1,
.rxPin = GPIO_NUM_9,
.txPin = GPIO_NUM_8,
.rtsPin = GPIO_NUM_NC,
.ctsPin = GPIO_NUM_NC,
.rxBufferSize = 1024,
.txBufferSize = 1024,
.config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_DEFAULT,
.flags = {
.allow_pd = 0,
.backup_before_sleep = 0,
}
}
},
uart::Configuration {
.name = "Port C",
.port = UART_NUM_1,
.rxPin = GPIO_NUM_18,
.txPin = GPIO_NUM_17,
.rtsPin = GPIO_NUM_NC,
.ctsPin = GPIO_NUM_NC,
.rxBufferSize = 1024,
.txBufferSize = 1024,
.config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_DEFAULT,
.flags = {
.allow_pd = 0,
.backup_before_sleep = 0,
}
}
}
}
};

View File

@ -0,0 +1,5 @@
#pragma once
#include <Tactility/hal/Configuration.h>
extern const tt::hal::Configuration m5stack_cores3;

View File

@ -0,0 +1,51 @@
#include "Display.h"
#include <Axp2101.h>
#include <Ft5x06Touch.h>
#include <Ili934xDisplay.h>
#include <Tactility/Log.h>
#include <Tactility/hal/i2c/I2c.h>
constexpr auto* TAG = "CoreS3Display";
static void setBacklightDuty(uint8_t backlightDuty) {
const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100] - under 20 is too dark
// TODO: Refactor to use Axp2102 driver subproject. Reference: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/AXP2101_Class.cpp#L42
if (!tt::hal::i2c::masterWriteRegister(I2C_NUM_0, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000)) { // Sets DLD01
TT_LOG_E(TAG, "Failed to set display backlight voltage");
}
}
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 48 and interrupt pin is 47
auto configuration = std::make_unique<Ft5x06Touch::Configuration>(
I2C_NUM_0,
320,
240
);
auto touch = std::make_shared<Ft5x06Touch>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::touch::TouchDevice>(touch);
}
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto touch = createTouch();
auto configuration = std::make_unique<Ili934xDisplay::Configuration>(
SPI3_HOST,
GPIO_NUM_3,
GPIO_NUM_35,
320,
240,
touch,
false,
false,
false,
true
);
configuration->backlightDutyFunction = ::setBacklightDuty;
auto display = std::make_shared<Ili934xDisplay>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
}

View File

@ -0,0 +1,14 @@
#pragma once
#include <Tactility/hal/display/DisplayDevice.h>
// Display
#define CORES3_LCD_SPI_HOST SPI3_HOST
#define CORES3_LCD_PIN_CS GPIO_NUM_3
#define CORES3_LCD_PIN_DC GPIO_NUM_35
#define CORES3_LCD_HORIZONTAL_RESOLUTION 320
#define CORES3_LCD_VERTICAL_RESOLUTION 240
#define CORES3_LCD_DRAW_BUFFER_HEIGHT (CORES3_LCD_VERTICAL_RESOLUTION / 10)
#define CORES3_LCD_DRAW_BUFFER_SIZE (CORES3_LCD_HORIZONTAL_RESOLUTION * CORES3_LCD_DRAW_BUFFER_HEIGHT)
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -0,0 +1,28 @@
#include "SdCard.h"
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
constexpr auto CORES3_SDCARD_PIN_CS = GPIO_NUM_4;
constexpr auto CORES3_LCD_PIN_CS = GPIO_NUM_3;
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
CORES3_SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
tt::lvgl::getSyncLock(),
std::vector {
CORES3_LCD_PIN_CS
},
SPI3_HOST
);
return std::make_shared<SpiSdCardDevice>(
std::move(configuration)
);
}

View File

@ -0,0 +1,7 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();

View File

@ -51,6 +51,8 @@ function(INIT_TACTILITY_GLOBALS SDKCONFIG_FILE)
set(TACTILITY_BOARD_PROJECT ElecrowCrowpanelBasic50)
elseif (board_id STREQUAL "lilygo-tdeck")
set(TACTILITY_BOARD_PROJECT LilygoTdeck)
elseif (board_id STREQUAL "lilygo-tdongle-s3")
set(TACTILITY_BOARD_PROJECT LilygoTdongleS3)
elseif (board_id STREQUAL "lilygo-tlora-pager")
set(TACTILITY_BOARD_PROJECT LilygoTLoraPager)
elseif (board_id STREQUAL "m5stack-cardputer")

View File

@ -0,0 +1,8 @@
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
idf_component_register(
SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Include"
PRIV_INCLUDE_DIRS "Private"
REQUIRES Tactility
)

View File

@ -0,0 +1,59 @@
#pragma once
#include <axp192/axp192.h>
#include <Tactility/hal/power/PowerDevice.h>
#include <Tactility/hal/i2c/I2c.h>
#include <memory>
class Axp192 final : public tt::hal::power::PowerDevice {
static int32_t i2cRead(void* handle, uint8_t address, uint8_t reg, uint8_t* buffer, uint16_t size);
static int32_t i2cWrite(void* handle, uint8_t address, uint8_t reg, const uint8_t* buffer, uint16_t size);
public:
struct Configuration {
i2c_port_t port;
TickType_t readTimeout = 50 / portTICK_PERIOD_MS;
TickType_t writeTimeout = 50 / portTICK_PERIOD_MS;
};
private:
std::unique_ptr<Configuration> configuration;
axp192_t axpDevice = {
.read = i2cRead,
.write = i2cWrite,
.handle = this
};
bool isInitialized = false;
public:
explicit Axp192(std::unique_ptr<Configuration> configuration) : configuration(std::move(configuration)) {}
~Axp192() override {}
/**
* @warning Must call this function before device can operate!
* @param onInit
*/
bool init(const std::function<bool(axp192_t*)>& onInit) {
isInitialized = onInit(&axpDevice);
return isInitialized;
}
axp192_t* getAxp192() { return &axpDevice; }
std::string getName() const override { return "AXP192"; }
std::string getDescription() const override { return "AXP192 power management via I2C"; }
bool supportsMetric(MetricType type) const override;
bool getMetric(MetricType type, MetricData& data) override;
bool supportsChargeControl() const override { return true; }
bool isAllowedToCharge() const override;
void setAllowedToCharge(bool canCharge) override;
};

5
Drivers/AXP192/README.md Normal file
View File

@ -0,0 +1,5 @@
# AXP192
Power management with I2C interface. Used on M5Stack Core2 and StickCPlus.
It includes driver code from https://github.com/tuupola/axp192, Copyright (c) 2019-2021 Mika Tuupola, MIT License

View File

@ -0,0 +1,117 @@
#include "Axp192.h"
constexpr auto TAG = "Axp192Power";
int32_t Axp192::i2cRead(void* handle, uint8_t address, uint8_t reg, uint8_t* buffer, uint16_t size) {
const auto* device = static_cast<Axp192*>(handle);
if (tt::hal::i2c::masterReadRegister(device->configuration->port, address, reg, buffer, size, device->configuration->readTimeout)) {
return AXP192_OK;
} else {
return 1;
}
}
int32_t Axp192::i2cWrite(void* handle, uint8_t address, uint8_t reg, const uint8_t* buffer, uint16_t size) {
const auto* device = static_cast<Axp192*>(handle);
if (tt::hal::i2c::masterWriteRegister(device->configuration->port, address, reg, buffer, size, device->configuration->writeTimeout)) {
return AXP192_OK;
} else {
return 1;
}
}
bool Axp192::supportsMetric(MetricType type) const {
if (!isInitialized) {
return false;
}
switch (type) {
using enum MetricType;
case BatteryVoltage:
case ChargeLevel:
case IsCharging:
return true;
default:
return false;
}
}
bool Axp192::getMetric(MetricType type, MetricData& data) {
switch (type) {
using enum MetricType;
case BatteryVoltage: {
float voltage;
if (axp192_read(&axpDevice, AXP192_BATTERY_VOLTAGE, &voltage) == ESP_OK) {
data.valueAsUint32 = (uint32_t)std::max((voltage * 1000.f), 0.0f);
return true;
} else {
return false;
}
}
case ChargeLevel: {
float vbat, charge_current;
if (
axp192_read(&axpDevice, AXP192_BATTERY_VOLTAGE, &vbat) == ESP_OK &&
axp192_read(&axpDevice, AXP192_CHARGE_CURRENT, &charge_current) == ESP_OK
) {
float max_voltage = 4.20f;
float min_voltage = 2.69f; // From M5Unified
float voltage_correction = (charge_current > 0.01f) ? -0.1f : 0.f; // Roughly 0.1V drop when ccharging
float corrected_voltage = vbat + voltage_correction;
if (corrected_voltage > 2.69f) {
float charge_factor = (corrected_voltage - min_voltage) / (max_voltage - min_voltage);
data.valueAsUint8 = (uint8_t)(charge_factor * 100.f);
} else {
data.valueAsUint8 = 0;
}
return true;
} else {
return false;
}
}
case IsCharging: {
float charge_current;
if (axp192_read(&axpDevice, AXP192_CHARGE_CURRENT, &charge_current) == ESP_OK) {
data.valueAsBool = charge_current > 0.001f;
return true;
} else {
return false;
}
}
case Current: {
float charge_current, discharge_current;
if (
axp192_read(&axpDevice, AXP192_CHARGE_CURRENT, &charge_current) == ESP_OK &&
axp192_read(&axpDevice, AXP192_DISCHARGE_CURRENT, &discharge_current) == ESP_OK
) {
if (charge_current > 0.0f) {
data.valueAsInt32 = (int32_t) (charge_current * 1000.0f);
} else {
data.valueAsInt32 = -(int32_t) (discharge_current * 1000.0f);
}
return true;
} else {
return false;
}
}
default:
return false;
}
}
bool Axp192::isAllowedToCharge() const {
uint8_t buffer;
if (axp192_read(&axpDevice, AXP192_CHARGE_CONTROL_1, &buffer) == ESP_OK) {
return buffer & 0x80;
} else {
return false;
}
}
void Axp192::setAllowedToCharge(bool canCharge) {
uint8_t buffer;
if (axp192_read(&axpDevice, AXP192_CHARGE_CONTROL_1, &buffer) == ESP_OK) {
buffer = (buffer & 0x7F) + (canCharge ? 0x80 : 0x00);
axp192_write(&axpDevice, AXP192_CHARGE_CONTROL_1, buffer);
}
}

View File

@ -35,8 +35,8 @@ Version: 0.6.0
#include <stdarg.h>
#include <stdint.h>
#include "axp192_config.h"
#include "axp192.h"
#include "axp192/axp192_config.h"
#include "axp192/axp192.h"
static axp192_err_t read_coloumb_counter(const axp192_t *axp, float *buffer);
static axp192_err_t read_battery_power(const axp192_t *axp, float *buffer);

View File

@ -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 driver
)

View File

@ -0,0 +1,3 @@
# Button Control
A driver for navigating apps with 1 or more GPIO buttons.

View File

@ -0,0 +1,162 @@
#include "ButtonControl.h"
#include <Tactility/Log.h>
#include <esp_lvgl_port.h>
constexpr auto* TAG = "ButtonControl";
ButtonControl::ButtonControl(const std::vector<PinConfiguration>& pinConfigurations) : pinConfigurations(pinConfigurations) {
pinStates.resize(pinConfigurations.size());
for (const auto& pinConfiguration : pinConfigurations) {
tt::hal::gpio::configure(pinConfiguration.pin, tt::hal::gpio::Mode::Input, false, false);
}
}
ButtonControl::~ButtonControl() {
if (driverThread != nullptr && driverThread->getState() != tt::Thread::State::Stopped) {
interruptDriverThread = true;
driverThread->join();
}
}
void ButtonControl::readCallback(lv_indev_t* indev, lv_indev_data_t* data) {
// Defaults
data->enc_diff = 0;
data->state = LV_INDEV_STATE_RELEASED;
auto* self = static_cast<ButtonControl*>(lv_indev_get_driver_data(indev));
if (self->mutex.lock(20)) {
for (int i = 0; i < self->pinConfigurations.size(); i++) {
const auto& config = self->pinConfigurations[i];
std::vector<PinState>::reference state = self->pinStates[i];
const bool trigger = (config.event == Event::ShortPress && state.triggerShortPress) ||
(config.event == Event::LongPress && state.triggerLongPress);
state.triggerShortPress = false;
state.triggerLongPress = false;
if (trigger) {
switch (config.action) {
case Action::UiSelectNext:
data->enc_diff = 1;
break;
case Action::UiSelectPrevious:
data->enc_diff = -1;
break;
case Action::UiPressSelected:
data->state = LV_INDEV_STATE_PRESSED;
break;
case Action::AppClose:
// TODO: implement
break;
}
}
}
self->mutex.unlock();
}
}
void ButtonControl::updatePin(std::vector<PinConfiguration>::const_reference configuration, std::vector<PinState>::reference state) {
if (tt::hal::gpio::getLevel(configuration.pin)) { // if pressed
if (state.pressState) {
// check time for long press trigger
auto time_passed = tt::kernel::getMillis() - state.pressStartTime;
if (time_passed > 500) {
// state.triggerLongPress = true;
}
} else {
state.pressStartTime = tt::kernel::getMillis();
state.pressState = true;
}
} else { // released
if (state.pressState) {
auto time_passed = tt::kernel::getMillis() - state.pressStartTime;
if (time_passed < 500) {
TT_LOG_W(TAG, "Trigger short press");
state.triggerShortPress = true;
}
state.pressState = false;
}
}
}
void ButtonControl::driverThreadMain() {
while (!shouldInterruptDriverThread()) {
if (mutex.lock(100)) {
for (int i = 0; i < pinConfigurations.size(); i++) {
updatePin(pinConfigurations[i], pinStates[i]);
}
mutex.unlock();
}
tt::kernel::delayMillis(5);
}
}
bool ButtonControl::shouldInterruptDriverThread() const {
bool interrupt = false;
if (mutex.lock(50 / portTICK_PERIOD_MS)) {
interrupt = interruptDriverThread;
mutex.unlock();
}
return interrupt;
}
void ButtonControl::startThread() {
TT_LOG_I(TAG, "Start");
mutex.lock();
interruptDriverThread = false;
driverThread = std::make_shared<tt::Thread>("ButtonControl", 4096, [this] {
driverThreadMain();
return 0;
});
driverThread->start();
mutex.unlock();
}
void ButtonControl::stopThread() {
TT_LOG_I(TAG, "Stop");
mutex.lock();
interruptDriverThread = true;
mutex.unlock();
driverThread->join();
mutex.lock();
driverThread = nullptr;
mutex.unlock();
}
bool ButtonControl::startLvgl(lv_display_t* display) {
if (deviceHandle != nullptr) {
return false;
}
startThread();
deviceHandle = lv_indev_create();
lv_indev_set_type(deviceHandle, LV_INDEV_TYPE_ENCODER);
lv_indev_set_driver_data(deviceHandle, this);
lv_indev_set_read_cb(deviceHandle, readCallback);
return true;
}
bool ButtonControl::stopLvgl() {
if (deviceHandle == nullptr) {
return false;
}
lv_indev_delete(deviceHandle);
deviceHandle = nullptr;
stopThread();
return true;
}

View File

@ -0,0 +1,110 @@
#pragma once
#include <Tactility/hal/encoder/EncoderDevice.h>
#include <Tactility/hal/gpio/Gpio.h>
#include <Tactility/TactilityCore.h>
class ButtonControl final : public tt::hal::encoder::EncoderDevice {
public:
enum class Event {
ShortPress,
LongPress
};
enum class Action {
UiSelectNext,
UiSelectPrevious,
UiPressSelected,
AppClose,
};
struct PinConfiguration {
tt::hal::gpio::Pin pin;
Event event;
Action action;
};
private:
struct PinState {
long pressStartTime = 0;
long pressReleaseTime = 0;
bool pressState = false;
bool triggerShortPress = false;
bool triggerLongPress = false;
};
lv_indev_t* _Nullable deviceHandle = nullptr;
std::shared_ptr<tt::Thread> driverThread;
bool interruptDriverThread = false;
tt::Mutex mutex;
std::vector<PinConfiguration> pinConfigurations;
std::vector<PinState> pinStates;
bool shouldInterruptDriverThread() const;
static void updatePin(std::vector<PinConfiguration>::const_reference value, std::vector<PinState>::reference pin_state);
void driverThreadMain();
static void readCallback(lv_indev_t* indev, lv_indev_data_t* data);
void startThread();
void stopThread();
public:
explicit ButtonControl(const std::vector<PinConfiguration>& pinConfigurations);
~ButtonControl() override;
std::string getName() const override { return "ButtonControl"; }
std::string getDescription() const override { return "ButtonControl input driver"; }
bool startLvgl(lv_display_t* display) override;
bool stopLvgl() override;
lv_indev_t* _Nullable getLvglIndev() override { return deviceHandle; }
static std::shared_ptr<ButtonControl> createOneButtonControl(tt::hal::gpio::Pin pin) {
return std::make_shared<ButtonControl>(std::vector {
PinConfiguration {
.pin = pin,
.event = Event::ShortPress,
.action = Action::UiSelectNext
},
PinConfiguration {
.pin = pin,
.event = Event::LongPress,
.action = Action::UiPressSelected
}
});
}
static std::shared_ptr<ButtonControl> createTwoButtonControl(tt::hal::gpio::Pin primaryPin, tt::hal::gpio::Pin secondaryPin) {
return std::make_shared<ButtonControl>(std::vector {
PinConfiguration {
.pin = primaryPin,
.event = Event::ShortPress,
.action = Action::UiPressSelected
},
PinConfiguration {
.pin = primaryPin,
.event = Event::LongPress,
.action = Action::AppClose
},
PinConfiguration {
.pin = secondaryPin,
.event = Event::ShortPress,
.action = Action::UiSelectNext
},
PinConfiguration {
.pin = secondaryPin,
.event = Event::LongPress,
.action = Action::UiSelectPrevious
}
});
}
};

View File

@ -0,0 +1,5 @@
idf_component_register(
SRC_DIRS "Source"
INCLUDE_DIRS "Source"
REQUIRES Tactility driver EspLcdCompat esp_lcd_st7735
)

3
Drivers/ST7735/README.md Normal file
View File

@ -0,0 +1,3 @@
# ST7735
A basic ESP32 LVGL driver for ST7735 displays.

View File

@ -0,0 +1,170 @@
#include "St7735Display.h"
#include <Tactility/Log.h>
#include <esp_lcd_panel_commands.h>
#include <esp_lcd_panel_dev.h>
#include <esp_lcd_st7735.h>
#include <esp_lvgl_port.h>
constexpr auto TAG = "ST7735";
bool St7735Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
TT_LOG_I(TAG, "Starting");
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,
.cs_ena_pretrans = 0,
.cs_ena_posttrans = 0,
.flags = {
.dc_high_on_cmd = 0,
.dc_low_on_data = 0,
.dc_low_on_param = 0,
.octal_mode = 0,
.quad_mode = 0,
.sio_mode = 1,
.lsb_first = 0,
.cs_high_active = 0
}
};
if (esp_lcd_new_panel_io_spi(configuration->spiHostDevice, &panel_io_config, &outHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create panel");
return false;
}
return true;
}
bool St7735Display::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,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR,
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
.bits_per_pixel = 16,
.flags = {
.reset_active_high = false
},
.vendor_config = nullptr
};
if (esp_lcd_new_panel_st7735(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to invert");
return false;
}
// Warning: it looks like LVGL rotation is broken when "gap" is set and the screen is moved to a non-default orientation
int gap_x = configuration->swapXY ? configuration->gapY : configuration->gapX;
int gap_y = configuration->swapXY ? configuration->gapX : configuration->gapY;
if (esp_lcd_panel_set_gap(panelHandle, gap_x, gap_y) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel gap");
return false;
}
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to swap XY ");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on");
return false;
}
return true;
}
lvgl_port_display_cfg_t St7735Display::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,
.trans_size = 0,
.hres = configuration->horizontalResolution,
.vres = configuration->verticalResolution,
.monochrome = false,
.rotation = {
.swap_xy = configuration->swapXY,
.mirror_x = configuration->mirrorX,
.mirror_y = configuration->mirrorY,
},
.color_format = LV_COLOR_FORMAT_RGB565,
.flags = {
.buff_dma = true,
.buff_spiram = false,
.sw_rotate = false,
.swap_bytes = true,
.full_refresh = false,
.direct_mode = false
}
};
}
/**
* Note:
* The datasheet implies this should work, but it doesn't:
* https://www.digikey.com/htmldatasheets/production/1640716/0/0/1/ILI9341-Datasheet.pdf
*
* This repo claims it only has 1 curve:
* https://github.com/brucemack/hello-ili9341
*
* I'm leaving it in as I'm not sure if it's just my hardware that's problematic.
*/
void St7735Display::setGammaCurve(uint8_t index) {
uint8_t gamma_curve;
switch (index) {
case 0:
gamma_curve = 0x01;
break;
case 1:
gamma_curve = 0x04;
break;
case 2:
gamma_curve = 0x02;
break;
case 3:
gamma_curve = 0x08;
break;
default:
return;
}
const uint8_t param[] = {
gamma_curve
};
auto io_handle = getIoHandle();
assert(io_handle != nullptr);
if (esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_GAMSET, param, 1) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set gamma");
}
}

View File

@ -0,0 +1,116 @@
#pragma once
#include "Tactility/hal/spi/Spi.h"
#include <EspLcdDisplay.h>
#include <Tactility/hal/display/DisplayDevice.h>
#include <driver/gpio.h>
#include <esp_lcd_panel_io.h>
#include <esp_lcd_types.h>
#include <functional>
#include <lvgl.h>
class St7735Display final : public EspLcdDisplay {
std::shared_ptr<tt::Lock> lock;
public:
class Configuration {
public:
Configuration(
spi_host_device_t spiHostDevice,
gpio_num_t csPin,
gpio_num_t dcPin,
gpio_num_t resetPin,
unsigned int horizontalResolution,
unsigned int verticalResolution,
std::shared_ptr<tt::hal::touch::TouchDevice> touch,
bool swapXY = false,
bool mirrorX = false,
bool mirrorY = false,
bool invertColor = false,
uint32_t bufferSize = 0, // Size in pixel count. 0 means default, which is 1/10 of the screen size
int gapX = 0,
int gapY = 0
) : spiHostDevice(spiHostDevice),
csPin(csPin),
dcPin(dcPin),
resetPin(resetPin),
horizontalResolution(horizontalResolution),
verticalResolution(verticalResolution),
gapX(gapX),
gapY(gapY),
swapXY(swapXY),
mirrorX(mirrorX),
mirrorY(mirrorY),
invertColor(invertColor),
bufferSize(bufferSize),
touch(std::move(touch))
{
if (this->bufferSize == 0) {
this->bufferSize = horizontalResolution * verticalResolution / 10;
}
}
spi_host_device_t spiHostDevice;
gpio_num_t csPin;
gpio_num_t dcPin;
gpio_num_t resetPin = GPIO_NUM_NC;
unsigned int pixelClockFrequency = 27'000'000; // Hertz
size_t transactionQueueDepth = 10;
unsigned int horizontalResolution;
unsigned int verticalResolution;
int gapX;
int gapY;
bool swapXY = false;
bool mirrorX = false;
bool mirrorY = false;
bool invertColor = false;
uint32_t bufferSize = 0; // Size in pixel count. 0 means default, which is 1/10 of the screen size
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 St7735Display(std::unique_ptr<Configuration> inConfiguration) :
EspLcdDisplay(tt::hal::spi::getLock(inConfiguration->spiHostDevice)),
configuration(std::move(inConfiguration)
) {
assert(configuration != nullptr);
assert(getLock() != nullptr);
}
std::string getName() const override { return "ST7735"; }
std::string getDescription() const override { return "ST7735 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; }
void setGammaCurve(uint8_t index) override;
uint8_t getGammaCurveCount() const override { return 4; };
};
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -41,6 +41,8 @@ menu "Tactility App"
bool "Elecrow CrowPanel Basic 5.0"
config TT_BOARD_LILYGO_TDECK
bool "LilyGo T-Deck"
config TT_BOARD_LILYGO_TDONGLE_S3
bool "LilyGo T-Dongle S3"
config TT_BOARD_LILYGO_TLORA_PAGER
bool "LilyGo T-Lora Pager"
config TT_BOARD_M5STACK_CARDPUTER

View File

@ -8,6 +8,9 @@
#if defined(CONFIG_TT_BOARD_LILYGO_TDECK)
#include "LilygoTdeck.h"
#define TT_BOARD_HARDWARE &lilygo_tdeck
#elif defined(CONFIG_TT_BOARD_LILYGO_TDONGLE_S3)
#include "LilygoTdongleS3.h"
#define TT_BOARD_HARDWARE &lilygo_tdongle_s3
#elif defined(CONFIG_TT_BOARD_LILYGO_TLORA_PAGER)
#include "LilygoTloraPager.h"
#define TT_BOARD_HARDWARE &lilygo_tlora_pager

View File

@ -1,6 +1,7 @@
dependencies:
espressif/esp_lcd_ili9341: "2.0.1"
atanisoft/esp_lcd_ili9488: "1.0.10"
teriyakigod/esp_lcd_st7735: "0.0.1"
espressif/esp_lcd_touch: "1.1.2"
atanisoft/esp_lcd_touch_xpt2046: "1.0.5"
espressif/esp_lcd_touch_cst816s: "1.0.3"

View File

@ -0,0 +1,91 @@
#ifdef ESP_PLATFORM
#pragma once
#include "SdCardDevice.h"
#include <Tactility/hal/spi/Spi.h>
#include <sd_protocol_types.h>
#include <utility>
#include <vector>
#include <Tactility/hal/Device.h>
#include <hal/spi_types.h>
#include <soc/gpio_num.h>
namespace tt::hal::sdcard {
/**
* SD card interface for the SDMMC interface.
*/
class SdmmcDevice final : public SdCardDevice {
std::shared_ptr<Mutex> mutex = std::make_shared<Mutex>(Mutex::Type::Recursive);
public:
struct Config {
Config(
gpio_num_t pinClock,
gpio_num_t pinCmd,
gpio_num_t pinD0,
gpio_num_t pinD1,
gpio_num_t pinD2,
gpio_num_t pinD3,
MountBehaviour mountBehaviourAtBoot
) :
pinClock(pinClock),
pinCmd(pinCmd),
pinD0(pinD0),
pinD1(pinD1),
pinD2(pinD2),
pinD3(pinD3),
mountBehaviourAtBoot(mountBehaviourAtBoot)
{}
int spiFrequencyKhz;
gpio_num_t pinClock;
gpio_num_t pinCmd;
gpio_num_t pinD0;
gpio_num_t pinD1;
gpio_num_t pinD2;
gpio_num_t pinD3;
MountBehaviour mountBehaviourAtBoot;
bool formatOnMountFailed = false;
uint16_t maxOpenFiles = 4;
uint16_t allocUnitSize = 16 * 1024;
bool statusCheckEnabled = false;
};
private:
std::string mountPath;
sdmmc_card_t* card = nullptr;
std::shared_ptr<Config> config;
bool applyGpioWorkAround();
bool mountInternal(const std::string& mountPath);
public:
explicit SdmmcDevice(std::unique_ptr<Config> config) : SdCardDevice(config->mountBehaviourAtBoot),
config(std::move(config))
{}
std::string getName() const override { return "SDMMC"; }
std::string getDescription() const override { return "SD card via SDMMC interface"; }
bool mount(const std::string& mountPath) override;
bool unmount() override;
std::string getMountPath() const override { return mountPath; }
std::shared_ptr<Lock> getLock() const override { return mutex; }
State getState(TickType_t timeout) const override;
sdmmc_card_t* _Nullable getCard() { return card; }
};
}
#endif

View File

@ -4,6 +4,6 @@
namespace tt {
void initFromBootApp();
void registerApps();
}

View File

@ -201,6 +201,13 @@ static void registerInstalledAppsFromSdCards() {
}
}
static void registerInstalledAppsFromData() {
auto app_path = "/data/app";
if (file::isDirectory(app_path)) {
registerInstalledApps(app_path);
}
}
static void registerAndStartSecondaryServices() {
TT_LOG_I(TAG, "Registering and starting system services");
addService(service::loader::manifest);
@ -214,7 +221,9 @@ static void registerAndStartSecondaryServices() {
static void registerAndStartPrimaryServices() {
TT_LOG_I(TAG, "Registering and starting system services");
addService(service::gps::manifest);
addService(service::sdcard::manifest);
if (hal::hasDevice(hal::Device::Type::SdCard)) {
addService(service::sdcard::manifest);
}
addService(service::wifi::manifest);
#ifdef ESP_PLATFORM
addService(service::development::manifest);
@ -222,13 +231,14 @@ static void registerAndStartPrimaryServices() {
#endif
}
void initFromBootApp() {
void registerApps() {
registerInternalApps();
auto data_apps_path = std::format("{}/apps", file::MOUNT_POINT_DATA);
if (file::isDirectory(data_apps_path)) {
registerInstalledApps(data_apps_path);
}
registerInstalledAppsFromSdCards();
registerInstalledAppsFromData();
}
void run(const Configuration& config) {

View File

@ -108,7 +108,7 @@ class BootApp : public App {
if (!setupUsbBootMode()) {
TT_LOG_I(TAG, "initFromBootApp");
initFromBootApp();
registerApps();
waitForMinimalSplashDuration(start_time);
stop(manifest.appId);
startNextApp();

View File

@ -24,12 +24,17 @@ static int getButtonSize(hal::UiScale scale) {
class LauncherApp final : public App {
static lv_obj_t* createAppButton(lv_obj_t* parent, hal::UiScale uiScale, const char* imageFile, const char* appId, int32_t horizontalMargin) {
static lv_obj_t* createAppButton(lv_obj_t* parent, hal::UiScale uiScale, const char* imageFile, const char* appId, int32_t itemMargin, bool isLandscape) {
auto button_size = getButtonSize(uiScale);
auto* apps_button = lv_button_create(parent);
lv_obj_set_style_pad_all(apps_button, 0, LV_STATE_DEFAULT);
lv_obj_set_style_margin_hor(apps_button, horizontalMargin, LV_STATE_DEFAULT);
if (isLandscape) {
lv_obj_set_style_margin_hor(apps_button, itemMargin, LV_STATE_DEFAULT);
} else {
lv_obj_set_style_margin_ver(apps_button, itemMargin, LV_STATE_DEFAULT);
}
lv_obj_set_style_shadow_width(apps_button, 0, LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(apps_button, 0, LV_STATE_DEFAULT);
@ -110,7 +115,7 @@ public:
lv_obj_set_flex_flow(buttons_wrapper, LV_FLEX_FLOW_COLUMN);
}
const int32_t available_width = lv_display_get_horizontal_resolution(display) - (3 * button_size);
const int32_t available_width = std::max<int32_t>(0, lv_display_get_horizontal_resolution(display) - (3 * button_size));
const int32_t margin = is_landscape_display ? std::min<int32_t>(available_width / 16, button_size) : 0;
const auto paths = app.getPaths();
@ -118,9 +123,9 @@ public:
const auto files_icon_path = lvgl::PATH_PREFIX + paths->getAssetsPath("icon_files.png");
const auto settings_icon_path = lvgl::PATH_PREFIX + paths->getAssetsPath("icon_settings.png");
createAppButton(buttons_wrapper, ui_scale, apps_icon_path.c_str(), "AppList", margin);
createAppButton(buttons_wrapper, ui_scale, files_icon_path.c_str(), "Files", margin);
createAppButton(buttons_wrapper, ui_scale, settings_icon_path.c_str(), "Settings", margin);
createAppButton(buttons_wrapper, ui_scale, apps_icon_path.c_str(), "AppList", margin, is_landscape_display);
createAppButton(buttons_wrapper, ui_scale, files_icon_path.c_str(), "Files", margin, is_landscape_display);
createAppButton(buttons_wrapper, ui_scale, settings_icon_path.c_str(), "Settings", margin, is_landscape_display);
if (shouldShowPowerButton()) {
auto* power_button = lv_btn_create(parent);

View File

@ -0,0 +1,113 @@
#ifdef ESP_PLATFORM
#include <Tactility/hal/sdcard/SdmmcDevice.h>
#include <Tactility/Log.h>
#include <esp_vfs_fat.h>
#include <sdmmc_cmd.h>
#include <driver/sdmmc_host.h>
namespace tt::hal::sdcard {
constexpr auto* TAG = "SdmmcDevice";
bool SdmmcDevice::mountInternal(const std::string& newMountPath) {
TT_LOG_I(TAG, "Mounting %s", newMountPath.c_str());
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
.format_if_mount_failed = config->formatOnMountFailed,
.max_files = config->maxOpenFiles,
.allocation_unit_size = config->allocUnitSize,
.disk_status_check_enable = config->statusCheckEnabled,
.use_one_fat = false
};
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
sdmmc_slot_config_t slot_config = {
.clk = config->pinClock,
.cmd = config->pinCmd,
.d0 = config->pinD0,
.d1 = config->pinD1,
.d2 = config->pinD2,
.d3 = config->pinD3,
.d4 = static_cast<gpio_num_t>(0),
.d5 = static_cast<gpio_num_t>(0),
.d6 = static_cast<gpio_num_t>(0),
.d7 = static_cast<gpio_num_t>(0),
.cd = GPIO_NUM_NC,
.wp = GPIO_NUM_NC,
.width = 4,
.flags = 0
};
esp_err_t result = esp_vfs_fat_sdmmc_mount(newMountPath.c_str(), &host, &slot_config, &mount_config, &card);
if (result != ESP_OK || card == nullptr) {
if (result == ESP_FAIL) {
TT_LOG_E(TAG, "Mounting failed. Ensure the card is formatted with FAT.");
} else {
TT_LOG_E(TAG, "Mounting failed (%s)", esp_err_to_name(result));
}
return false;
}
mountPath = newMountPath;
return true;
}
bool SdmmcDevice::mount(const std::string& newMountPath) {
if (mountInternal(newMountPath)) {
TT_LOG_I(TAG, "Mounted at %s", newMountPath.c_str());
sdmmc_card_print_info(stdout, card);
return true;
} else {
TT_LOG_E(TAG, "Mount failed for %s", newMountPath.c_str());
return false;
}
}
bool SdmmcDevice::unmount() {
if (card == nullptr) {
TT_LOG_E(TAG, "Can't unmount: not mounted");
return false;
}
if (esp_vfs_fat_sdcard_unmount(mountPath.c_str(), card) != ESP_OK) {
TT_LOG_E(TAG, "Unmount failed for %s", mountPath.c_str());
return false;
}
TT_LOG_I(TAG, "Unmounted %s", mountPath.c_str());
mountPath = "";
card = nullptr;
return true;
}
SdmmcDevice::State SdmmcDevice::getState(TickType_t timeout) const {
if (card == nullptr) {
return State::Unmounted;
}
/**
* The SD card and the screen are on the same SPI bus.
* Writing and reading to the bus from 2 devices at the same time causes crashes.
* This work-around ensures that this check is only happening when LVGL isn't rendering.
*/
auto lock = getLock()->asScopedLock();
bool locked = lock.lock(timeout);
if (!locked) {
return State::Timeout;
}
if (sdmmc_get_status(card) != ESP_OK) {
return State::Error;
}
return State::Mounted;
}
}
#endif

View File

@ -20,7 +20,10 @@ namespace tt {
class Mutex final : public Lock {
public:
/**
* A "Normal" mutex can only be locked once. Even from within the same task/thread.
* A "Recursive" mutex can be locked again from the same task/thread.
*/
enum class Type {
Normal,
Recursive,

View File

@ -0,0 +1,53 @@
# Software defaults
# Increase stack size for WiFi (fixes crash after scan)
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=3072
CONFIG_LV_FONT_MONTSERRAT_14=y
CONFIG_LV_FONT_MONTSERRAT_18=y
CONFIG_LV_USE_USER_DATA=y
CONFIG_LV_USE_FS_STDIO=y
CONFIG_LV_FS_STDIO_LETTER=65
CONFIG_LV_FS_STDIO_PATH=""
CONFIG_LV_FS_STDIO_CACHE_SIZE=4096
CONFIG_LV_USE_LODEPNG=y
CONFIG_LV_USE_BUILTIN_MALLOC=n
CONFIG_LV_USE_CLIB_MALLOC=y
CONFIG_LV_USE_MSGBOX=n
CONFIG_LV_USE_SPINNER=n
CONFIG_LV_USE_WIN=n
CONFIG_LV_USE_SNAPSHOT=y
CONFIG_FREERTOS_HZ=1000
CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=2
CONFIG_FREERTOS_SMP=n
CONFIG_FREERTOS_UNICORE=n
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=5120
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FATFS_LFN_HEAP=y
CONFIG_FATFS_VOLUME_COUNT=3
CONFIG_FATFS_SECTOR_512=y
CONFIG_WL_SECTOR_SIZE_512=y
CONFIG_WL_SECTOR_SIZE=512
CONFIG_WL_SECTOR_MODE_SAFE=y
CONFIG_WL_SECTOR_MODE=1
# Hardware: Main
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-16mb.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions-16mb.csv"
CONFIG_TT_BOARD_LILYGO_TDONGLE_S3=y
CONFIG_TT_BOARD_NAME="LilyGo T-Dongle S3"
CONFIG_TT_BOARD_ID="lilygo-tdongle-s3"
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_FLASHMODE_QIO=y
# SPI Flash (can set back to 80MHz after ESP-IDF bug is resolved)
CONFIG_ESPTOOLPY_FLASHFREQ_120M=y
# LVGL
CONFIG_LV_DPI_DEF=186
CONFIG_LV_DISP_DEF_REFR_PERIOD=10
CONFIG_LV_THEME_DEFAULT_DARK=y
# USB
CONFIG_TINYUSB_MSC_ENABLED=y
CONFIG_TINYUSB_MSC_MOUNT_PATH="/sdcard"

View File

@ -0,0 +1,54 @@
# Software defaults
# Increase stack size for WiFi (fixes crash after scan)
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=3072
CONFIG_LV_FONT_MONTSERRAT_14=y
CONFIG_LV_FONT_MONTSERRAT_18=y
CONFIG_LV_USE_USER_DATA=y
CONFIG_LV_USE_FS_STDIO=y
CONFIG_LV_FS_STDIO_LETTER=65
CONFIG_LV_FS_STDIO_PATH=""
CONFIG_LV_FS_STDIO_CACHE_SIZE=4096
CONFIG_LV_USE_LODEPNG=y
CONFIG_LV_USE_BUILTIN_MALLOC=n
CONFIG_LV_USE_CLIB_MALLOC=y
CONFIG_LV_USE_MSGBOX=n
CONFIG_LV_USE_SPINNER=n
CONFIG_LV_USE_WIN=n
CONFIG_LV_USE_SNAPSHOT=y
CONFIG_FREERTOS_HZ=1000
CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=2
CONFIG_FREERTOS_SMP=n
CONFIG_FREERTOS_UNICORE=n
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=5120
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FATFS_LFN_HEAP=y
CONFIG_FATFS_VOLUME_COUNT=3
CONFIG_FATFS_SECTOR_512=y
CONFIG_WL_SECTOR_SIZE_512=y
CONFIG_WL_SECTOR_SIZE=512
CONFIG_WL_SECTOR_MODE_SAFE=y
CONFIG_WL_SECTOR_MODE=1
# Hardware: Main
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4mb.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions-4mb.csv"
CONFIG_TT_BOARD_M5STACK_STICKC_PLUS=y
CONFIG_TT_BOARD_NAME="M5Stack StickC Plus"
CONFIG_TT_BOARD_ID="m5stack-stickc-plus"
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
CONFIG_IDF_TARGET="esp32"
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_FLASHMODE_QIO=y
# LVGL
CONFIG_LV_DISP_DEF_REFR_PERIOD=10
CONFIG_LV_DPI_DEF=241
CONFIG_LV_THEME_DEFAULT_DARK=y
# Fix for IRAM
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y
CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH=y
CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y

View File

@ -0,0 +1,56 @@
# Software defaults
# Increase stack size for WiFi (fixes crash after scan)
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=3072
CONFIG_LV_FONT_MONTSERRAT_14=y
CONFIG_LV_FONT_MONTSERRAT_18=y
CONFIG_LV_USE_USER_DATA=y
CONFIG_LV_USE_FS_STDIO=y
CONFIG_LV_FS_STDIO_LETTER=65
CONFIG_LV_FS_STDIO_PATH=""
CONFIG_LV_FS_STDIO_CACHE_SIZE=4096
CONFIG_LV_USE_LODEPNG=y
CONFIG_LV_USE_BUILTIN_MALLOC=n
CONFIG_LV_USE_CLIB_MALLOC=y
CONFIG_LV_USE_MSGBOX=n
CONFIG_LV_USE_SPINNER=n
CONFIG_LV_USE_WIN=n
CONFIG_LV_USE_SNAPSHOT=y
CONFIG_FREERTOS_HZ=1000
CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=2
CONFIG_FREERTOS_SMP=n
CONFIG_FREERTOS_UNICORE=n
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=5120
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FATFS_LFN_HEAP=y
CONFIG_FATFS_VOLUME_COUNT=3
CONFIG_FATFS_SECTOR_512=y
CONFIG_WL_SECTOR_SIZE_512=y
CONFIG_WL_SECTOR_SIZE=512
CONFIG_WL_SECTOR_MODE_SAFE=y
CONFIG_WL_SECTOR_MODE=1
# Hardware: Main
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8mb.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions-8mb.csv"
CONFIG_TT_BOARD_LILYGO_TDECK=y
CONFIG_TT_BOARD_NAME="M5Stack StickC Plus2"
CONFIG_TT_BOARD_ID="m5stack-stickc-plus2"
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_FLASHMODE_QIO=y
# Hardware: SPI RAM
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_SPEED_120M=y
CONFIG_SPIRAM_USE_MALLOC=y
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
# SPI Flash (can set back to 80MHz after ESP-IDF bug is resolved)
CONFIG_ESPTOOLPY_FLASHFREQ_120M=y
# LVGL
CONFIG_LV_DPI_DEF=241
CONFIG_LV_DISP_DEF_REFR_PERIOD=10
CONFIG_LV_THEME_DEFAULT_DARK=y