Updates for removal of deprecated HAL (#37)

Update all apps to replace deprecated LVGL code and to use the new kernel APIs.
This commit is contained in:
Ken Van Hoeylandt
2026-07-26 12:47:03 +02:00
committed by GitHub
parent 25b966a340
commit 4f635d38e3
45 changed files with 200 additions and 257 deletions
+2 -2
View File
@@ -12,8 +12,8 @@
#include <esp_random.h> #include <esp_random.h>
#include <tt_lvgl_keyboard.h> #include <tt_lvgl_keyboard.h>
#include <tactility/lvgl_module.h> #include <lvgl/lvgl.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
constexpr auto* TAG = "Breakout"; constexpr auto* TAG = "Breakout";
+2 -2
View File
@@ -2,7 +2,7 @@ manifest.version=0.2
target.sdk=0.8.0-dev target.sdk=0.8.0-dev
target.platforms=esp32,esp32s3,esp32c6,esp32p4 target.platforms=esp32,esp32s3,esp32c6,esp32p4
app.id=one.tactility.breakout app.id=one.tactility.breakout
app.version.name=0.5.0 app.version.name=0.6.0
app.version.code=5 app.version.code=6
app.name=Breakout app.name=Breakout
app.description=Classic brick-breaking arcade game app.description=Classic brick-breaking arcade game
+3 -3
View File
@@ -2,7 +2,7 @@
#include <tt_app_alertdialog.h> #include <tt_app_alertdialog.h>
#include <tt_lock.h> #include <tt_lock.h>
#include <tt_lvgl.h> #include <lvgl/lvgl.h>
#include <tt_lvgl_toolbar.h> #include <tt_lvgl_toolbar.h>
#include <esp_random.h> #include <esp_random.h>
@@ -87,9 +87,9 @@ void Diceware::startJob(uint32_t jobWordCount) {
} }
void Diceware::onFinishJob(std::string result) { void Diceware::onFinishJob(std::string result) {
tt_lvgl_lock(tt::kernel::MAX_TICKS); lvgl_lock();
lv_label_set_text(resultLabel, result.c_str()); lv_label_set_text(resultLabel, result.c_str());
tt_lvgl_unlock(); lvgl_unlock();
} }
void Diceware::onClickGenerate(lv_event_t* e) { void Diceware::onClickGenerate(lv_event_t* e) {
+2 -2
View File
@@ -2,6 +2,6 @@ manifest.version=0.2
target.sdk=0.8.0-dev target.sdk=0.8.0-dev
target.platforms=esp32,esp32s3,esp32c6,esp32p4 target.platforms=esp32,esp32s3,esp32c6,esp32p4
app.id=one.tactility.diceware app.id=one.tactility.diceware
app.version.name=0.6.0 app.version.name=0.7.0
app.version.code=6 app.version.code=7
app.name=Diceware app.name=Diceware
@@ -9,7 +9,7 @@
#include <tt_app_fileselection.h> #include <tt_app_fileselection.h>
#include <tt_bundle.h> #include <tt_bundle.h>
#include <tt_lock.h> #include <tt_lock.h>
#include <tt_lvgl.h> #include <lvgl/lvgl.h>
#include <tt_lvgl_toolbar.h> #include <tt_lvgl_toolbar.h>
#include <esp_app_desc.h> #include <esp_app_desc.h>
@@ -18,6 +18,8 @@
#include <tactility/log.h> #include <tactility/log.h>
constexpr TickType_t LVGL_DEFAULT_LOCK_TIME = 500; // 500 ticks = 500 ms
#include <freertos/FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include <freertos/task.h> #include <freertos/task.h>
@@ -283,12 +285,12 @@ struct UiDispatchPayload {
void EspNowBridge::dispatchToUi(void (*work)(EspNowBridge&, void*), void* context, void (*freeContext)(void*)) { void EspNowBridge::dispatchToUi(void (*work)(EspNowBridge&, void*), void* context, void (*freeContext)(void*)) {
auto* payload = new UiDispatchPayload{this, work, context, freeContext}; auto* payload = new UiDispatchPayload{this, work, context, freeContext};
// lv_async_call() itself is an LVGL operation and must be lock-guarded when called from a // lv_async_call() itself is an LVGL operation and must be lock-guarded when called from a
// non-LVGL task (see tt_lvgl_lock()'s doc comment) - the OTA worker task calls dispatchToUi() // non-LVGL task (see lvgl_lock()'s doc comment) - the OTA worker task calls dispatchToUi()
// repeatedly during the transfer, and without this lock most of those calls were silently // repeatedly during the transfer, and without this lock most of those calls were silently
// racing LVGL's own task and getting lost (only the very last status update, right before // racing LVGL's own task and getting lost (only the very last status update, right before
// esp_restart(), happened to land - everything else stayed stuck at "Waiting for // esp_restart(), happened to land - everything else stayed stuck at "Waiting for
// co-processor link..."). // co-processor link...").
bool locked = tt_lvgl_lock(TT_LVGL_DEFAULT_LOCK_TIME); bool locked = lvgl_try_lock(LVGL_DEFAULT_LOCK_TIME);
if (!locked) { if (!locked) {
// Without the lock, lv_async_call() itself would be touching LVGL's internal timer list // Without the lock, lv_async_call() itself would be touching LVGL's internal timer list
// unguarded - and if it happened to still enqueue successfully, the callback below would // unguarded - and if it happened to still enqueue successfully, the callback below would
@@ -310,7 +312,7 @@ void EspNowBridge::dispatchToUi(void (*work)(EspNowBridge&, void*), void* contex
} }
delete payload; delete payload;
}, payload); }, payload);
tt_lvgl_unlock(); lvgl_unlock();
if (result != LV_RESULT_OK) { if (result != LV_RESULT_OK) {
if (freeContext != nullptr) { if (freeContext != nullptr) {
+2 -2
View File
@@ -2,7 +2,7 @@ manifest.version=0.2
target.sdk=0.8.0-dev target.sdk=0.8.0-dev
target.platforms=esp32p4 target.platforms=esp32p4
app.id=one.tactility.espnowbridge app.id=one.tactility.espnowbridge
app.version.name=0.1.0 app.version.name=0.2.0
app.version.code=1 app.version.code=2
app.name=ESP-NOW Bridge app.name=ESP-NOW Bridge
app.description=Companion app for updating P4 device C6 co-processor firmware to enable ESP-NOW bridge support. app.description=Companion app for updating P4 device C6 co-processor firmware to enable ESP-NOW bridge support.
+3 -4
View File
@@ -2,10 +2,9 @@
#include <Tactility/kernel/Kernel.h> #include <Tactility/kernel/Kernel.h>
#include <tt_lvgl.h>
#include <tt_lvgl_toolbar.h> #include <tt_lvgl_toolbar.h>
#include <tactility/lvgl_module.h> #include <lvgl/lvgl.h>
#include <esp_log.h> #include <esp_log.h>
#include <driver/gpio.h> #include <driver/gpio.h>
@@ -20,7 +19,7 @@ void Gpio::updatePinStates() {
} }
void Gpio::updatePinWidgets() { void Gpio::updatePinWidgets() {
tt_lvgl_lock(tt::kernel::MAX_TICKS); lvgl_lock();
for (int j = 0; j < pinStates.size(); ++j) { for (int j = 0; j < pinStates.size(); ++j) {
int level = pinStates[j]; int level = pinStates[j];
lv_obj_t* label = pinWidgets[j]; lv_obj_t* label = pinWidgets[j];
@@ -35,7 +34,7 @@ void Gpio::updatePinWidgets() {
} }
} }
} }
tt_lvgl_unlock(); lvgl_unlock();
} }
lv_obj_t* Gpio::createGpioRowWrapper(lv_obj_t* parent) { lv_obj_t* Gpio::createGpioRowWrapper(lv_obj_t* parent) {
+2 -2
View File
@@ -2,6 +2,6 @@ manifest.version=0.2
target.sdk=0.8.0-dev target.sdk=0.8.0-dev
target.platforms=esp32,esp32s3,esp32c6,esp32p4 target.platforms=esp32,esp32s3,esp32c6,esp32p4
app.id=one.tactility.gpio app.id=one.tactility.gpio
app.version.name=0.7.0 app.version.name=0.8.0
app.version.code=7 app.version.code=8
app.name=GPIO app.name=GPIO
+16 -16
View File
@@ -4,17 +4,17 @@
#include "drivers/Colors.h" #include "drivers/Colors.h"
#include <cstring> #include <cstring>
#include <tt_hal_display.h> #include <tactility/drivers/display.h>
class PixelBuffer { class PixelBuffer {
uint16_t pixelWidth; uint16_t pixelWidth;
uint16_t pixelHeight; uint16_t pixelHeight;
ColorFormat colorFormat; enum DisplayColorFormat colorFormat;
uint8_t* data; uint8_t* data;
public: public:
PixelBuffer(uint16_t pixelWidth, uint16_t pixelHeight, ColorFormat colorFormat) : PixelBuffer(uint16_t pixelWidth, uint16_t pixelHeight, enum DisplayColorFormat colorFormat) :
pixelWidth(pixelWidth), pixelWidth(pixelWidth),
pixelHeight(pixelHeight), pixelHeight(pixelHeight),
colorFormat(colorFormat) colorFormat(colorFormat)
@@ -35,7 +35,7 @@ public:
return pixelHeight; return pixelHeight;
} }
ColorFormat getColorFormat() const { enum DisplayColorFormat getColorFormat() const {
return colorFormat; return colorFormat;
} }
@@ -58,14 +58,14 @@ public:
uint8_t getPixelSize() const { uint8_t getPixelSize() const {
switch (colorFormat) { switch (colorFormat) {
case COLOR_FORMAT_MONOCHROME: case DISPLAY_COLOR_FORMAT_MONOCHROME:
return 1; return 1;
case COLOR_FORMAT_BGR565: case DISPLAY_COLOR_FORMAT_BGR565:
case COLOR_FORMAT_BGR565_SWAPPED: case DISPLAY_COLOR_FORMAT_BGR565_SWAPPED:
case COLOR_FORMAT_RGB565: case DISPLAY_COLOR_FORMAT_RGB565:
case COLOR_FORMAT_RGB565_SWAPPED: case DISPLAY_COLOR_FORMAT_RGB565_SWAPPED:
return 2; return 2;
case COLOR_FORMAT_RGB888: case DISPLAY_COLOR_FORMAT_RGB888:
return 3; return 3;
default: default:
// TODO: Crash with error // TODO: Crash with error
@@ -82,13 +82,13 @@ public:
void setPixel(uint16_t x, uint16_t y, uint8_t r, uint8_t g, uint8_t b) const { void setPixel(uint16_t x, uint16_t y, uint8_t r, uint8_t g, uint8_t b) const {
auto address = getPixelAddress(x, y); auto address = getPixelAddress(x, y);
switch (colorFormat) { switch (colorFormat) {
case COLOR_FORMAT_MONOCHROME: case DISPLAY_COLOR_FORMAT_MONOCHROME:
*address = (uint8_t)((uint16_t)r + (uint16_t)g + (uint16_t)b / 3); *address = (uint8_t)((uint16_t)r + (uint16_t)g + (uint16_t)b / 3);
break; break;
case COLOR_FORMAT_BGR565: case DISPLAY_COLOR_FORMAT_BGR565:
Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address)); Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address));
break; break;
case COLOR_FORMAT_BGR565_SWAPPED: { case DISPLAY_COLOR_FORMAT_BGR565_SWAPPED: {
// TODO: Make proper conversion function // TODO: Make proper conversion function
Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address)); Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address));
uint8_t temp = *address; uint8_t temp = *address;
@@ -96,11 +96,11 @@ public:
*(address + 1) = temp; *(address + 1) = temp;
break; break;
} }
case COLOR_FORMAT_RGB565: { case DISPLAY_COLOR_FORMAT_RGB565: {
Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address)); Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address));
break; break;
} }
case COLOR_FORMAT_RGB565_SWAPPED: { case DISPLAY_COLOR_FORMAT_RGB565_SWAPPED: {
// TODO: Make proper conversion function // TODO: Make proper conversion function
Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address)); Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address));
uint8_t temp = *address; uint8_t temp = *address;
@@ -108,7 +108,7 @@ public:
*(address + 1) = temp; *(address + 1) = temp;
break; break;
} }
case COLOR_FORMAT_RGB888: { case DISPLAY_COLOR_FORMAT_RGB888: {
uint8_t pixel[3] = { r, g, b }; uint8_t pixel[3] = { r, g, b };
memcpy(address, pixel, 3); memcpy(address, pixel, 3);
break; break;
@@ -1,49 +1,47 @@
#pragma once #pragma once
#include <cassert> #include <tactility/device.h>
#include <tt_hal_display.h> #include <tactility/drivers/display.h>
#include <Tactility/kernel/Kernel.h> #include <Tactility/kernel/Kernel.h>
/** /**
* Wrapper for tt_hal_display_driver_* * Wrapper for display_* device driver functions
*/ */
class DisplayDriver { class DisplayDriver {
DisplayDriverHandle handle = nullptr; struct Device* device;
public: public:
explicit DisplayDriver(DeviceId id) { explicit DisplayDriver(struct Device* device) : device(device) {
assert(tt_hal_display_driver_supported(id)); device_get(device);
handle = tt_hal_display_driver_alloc(id);
assert(handle != nullptr);
} }
~DisplayDriver() { ~DisplayDriver() {
tt_hal_display_driver_free(handle); device_put(device);
} }
bool lock(TickType_t timeout = tt::kernel::MAX_TICKS) const { bool lock(TickType_t timeout = tt::kernel::MAX_TICKS) const {
return tt_hal_display_driver_lock(handle, timeout); return device_try_lock(device, timeout);
} }
void unlock() const { void unlock() const {
tt_hal_display_driver_unlock(handle); device_unlock(device);
} }
uint16_t getWidth() const { uint16_t getWidth() const {
return tt_hal_display_driver_get_pixel_width(handle); return display_get_resolution_x(device);
} }
uint16_t getHeight() const { uint16_t getHeight() const {
return tt_hal_display_driver_get_pixel_height(handle); return display_get_resolution_y(device);
} }
ColorFormat getColorFormat() const { enum DisplayColorFormat getColorFormat() const {
return tt_hal_display_driver_get_colorformat(handle); return display_get_color_format(device);
} }
void drawBitmap(int xStart, int yStart, int xEnd, int yEnd, const void* pixelData) const { void drawBitmap(int xStart, int yStart, int xEnd, int yEnd, const void* pixelData) const {
tt_hal_display_driver_draw_bitmap(handle, xStart, yStart, xEnd, yEnd, pixelData); display_draw_bitmap(device, xStart, yStart, xEnd, yEnd, pixelData);
} }
}; };
@@ -1,28 +1,28 @@
#pragma once #pragma once
#include <cassert> #include <tactility/device.h>
#include <tt_hal_touch.h> #include <tactility/drivers/pointer.h>
/** /**
* Wrapper for tt_hal_touch_driver_* * Wrapper for pointer_* device driver functions
*/ */
class TouchDriver { class TouchDriver {
TouchDriverHandle handle = nullptr; struct Device* device;
public: public:
explicit TouchDriver(DeviceId id) { explicit TouchDriver(struct Device* device) : device(device) {
assert(tt_hal_touch_driver_supported(id)); device_get(device);
handle = tt_hal_touch_driver_alloc(id);
assert(handle != nullptr);
} }
~TouchDriver() { ~TouchDriver() {
tt_hal_touch_driver_free(handle); device_put(device);
} }
bool getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* count, uint8_t maxCount) const { bool getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* count, uint8_t maxCount) const {
return tt_hal_touch_driver_get_touched_points(handle, x, y, strength, count, maxCount); // Poll without blocking: perform one read attempt, then report whatever is cached.
pointer_read_data(device, 0);
return pointer_get_touched_points(device, x, y, strength, count, maxCount);
} }
}; };
+23 -44
View File
@@ -6,65 +6,44 @@
#include <tt_app.h> #include <tt_app.h>
#include <tt_app_alertdialog.h> #include <tt_app_alertdialog.h>
#include <tt_lvgl.h>
#include <tactility/device.h>
#include <tactility/drivers/display.h>
#include <tactility/drivers/pointer.h>
#include <lvgl/lvgl.h>
#include <lvgl/module.h>
#include <tactility/module.h>
constexpr auto TAG = "Main"; constexpr auto TAG = "Main";
/** Find a DisplayDevice that supports the DisplayDriver interface */
static bool findUsableDisplay(DeviceId& deviceId) {
uint16_t display_count = 0;
if (!tt_hal_device_find(DEVICE_TYPE_DISPLAY, &deviceId, &display_count, 1)) {
ESP_LOGE(TAG, "No display device found");
return false;
}
if (!tt_hal_display_driver_supported(deviceId)) {
ESP_LOGE(TAG, "Display doesn't support driver mode");
return false;
}
return true;
}
/** Find a TouchDevice that supports the TouchDriver interface */
static bool findUsableTouch(DeviceId& deviceId) {
uint16_t touch_count = 0;
if (!tt_hal_device_find(DEVICE_TYPE_TOUCH, &deviceId, &touch_count, 1)) {
ESP_LOGE(TAG, "No touch device found");
return false;
}
if (!tt_hal_touch_driver_supported(deviceId)) {
ESP_LOGE(TAG, "Touch doesn't support driver mode");
return false;
}
return true;
}
static void onCreate(AppHandle appHandle, void* data) { static void onCreate(AppHandle appHandle, void* data) {
DeviceId display_id; struct Device* display_device;
if (!findUsableDisplay(display_id)) { if (device_get_first_active_by_type(&DISPLAY_TYPE, &display_device) != ERROR_NONE) {
ESP_LOGE(TAG, "No display device found");
tt_app_stop(); tt_app_stop();
tt_app_alertdialog_start("Error", "The display doesn't support the required features.", nullptr, 0); tt_app_alertdialog_start("Error", "No display device was found.", nullptr, 0);
return; return;
} }
DeviceId touch_id; struct Device* touch_device;
if (!findUsableTouch(touch_id)) { if (device_get_first_active_by_type(&POINTER_TYPE, &touch_device) != ERROR_NONE) {
ESP_LOGE(TAG, "No touch device found");
device_put(display_device);
tt_app_stop(); tt_app_stop();
tt_app_alertdialog_start("Error", "The touch driver doesn't support the required features.", nullptr, 0); tt_app_alertdialog_start("Error", "No touch device was found.", nullptr, 0);
return; return;
} }
// Stop LVGL first (because it's currently using the drivers we want to use) // Stop LVGL first (because it's currently using the drivers we want to use)
tt_lvgl_stop(); module_stop(&lvgl_module);
ESP_LOGI(TAG, "Creating display driver"); ESP_LOGI(TAG, "Creating display driver");
auto display = new DisplayDriver(display_id); auto display = new DisplayDriver(display_device);
device_put(display_device);
ESP_LOGI(TAG, "Creating touch driver"); ESP_LOGI(TAG, "Creating touch driver");
auto touch = new TouchDriver(touch_id); auto touch = new TouchDriver(touch_device);
device_put(touch_device);
// Run the main logic // Run the main logic
ESP_LOGI(TAG, "Running application"); ESP_LOGI(TAG, "Running application");
@@ -82,9 +61,9 @@ static void onCreate(AppHandle appHandle, void* data) {
static void onDestroy(AppHandle appHandle, void* data) { static void onDestroy(AppHandle appHandle, void* data) {
// Restart LVGL to resume rendering of regular apps // Restart LVGL to resume rendering of regular apps
if (!tt_lvgl_is_started()) { if (!module_is_started(&lvgl_module)) {
ESP_LOGI(TAG, "Restarting LVGL"); ESP_LOGI(TAG, "Restarting LVGL");
tt_lvgl_start(); module_start(&lvgl_module);
} }
} }
+1 -1
View File
@@ -2,7 +2,7 @@
#include "M5UnitTest.h" #include "M5UnitTest.h"
#include "UiScale.h" #include "UiScale.h"
#include <tt_lvgl_toolbar.h> #include <tt_lvgl_toolbar.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
void TestListView::onStart(lv_obj_t* parent, AppHandle handle, M5UnitTest* app) { void TestListView::onStart(lv_obj_t* parent, AppHandle handle, M5UnitTest* app) {
app_ = app; app_ = app;
+1 -1
View File
@@ -2,7 +2,7 @@
#include <array> #include <array>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/lvgl_icon_shared.h> #include <lvgl/lvgl_icon_shared.h>
#include <tt_app.h> #include <tt_app.h>
class M5UnitTest; class M5UnitTest;
@@ -2,7 +2,7 @@
#include "GroveLookup.h" #include "GroveLookup.h"
#include "UiScale.h" #include "UiScale.h"
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
#include <cstring> #include <cstring>
@@ -2,7 +2,7 @@
#include "GroveLookup.h" #include "GroveLookup.h"
#include "UiScale.h" #include "UiScale.h"
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
#include <cstring> #include <cstring>
void TestUnitByteButton::onStart(lv_obj_t* parent, AppHandle handle, M5UnitTest* app) { void TestUnitByteButton::onStart(lv_obj_t* parent, AppHandle handle, M5UnitTest* app) {
@@ -3,7 +3,7 @@
#include "UiScale.h" #include "UiScale.h"
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/drivers/uart_controller.h> #include <tactility/drivers/uart_controller.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
#include <cstring> #include <cstring>
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -1,7 +1,7 @@
#include "TestUnitDualButton.h" #include "TestUnitDualButton.h"
#include "UiScale.h" #include "UiScale.h"
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
static constexpr gpio_pin_t PIN_MIN = 0; static constexpr gpio_pin_t PIN_MIN = 0;
static constexpr gpio_pin_t PIN_MAX = 57; static constexpr gpio_pin_t PIN_MAX = 57;
@@ -2,7 +2,7 @@
#include "GroveLookup.h" #include "GroveLookup.h"
#include "UiScale.h" #include "UiScale.h"
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
+1 -1
View File
@@ -2,7 +2,7 @@
#include "GroveLookup.h" #include "GroveLookup.h"
#include "UiScale.h" #include "UiScale.h"
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
void TestUnitLcd::onStart(lv_obj_t* parent, AppHandle handle, M5UnitTest* app) { void TestUnitLcd::onStart(lv_obj_t* parent, AppHandle handle, M5UnitTest* app) {
app_ = app; app_ = app;
@@ -2,7 +2,7 @@
#include "GroveLookup.h" #include "GroveLookup.h"
#include "UiScale.h" #include "UiScale.h"
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
#include <esp_timer.h> #include <esp_timer.h>
#include <cstring> #include <cstring>
#include <cstdio> #include <cstdio>
+1 -1
View File
@@ -2,7 +2,7 @@
#include "GroveLookup.h" #include "GroveLookup.h"
#include "UiScale.h" #include "UiScale.h"
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
void TestUnitMidi::onStart(lv_obj_t* parent, AppHandle handle, M5UnitTest* app) { void TestUnitMidi::onStart(lv_obj_t* parent, AppHandle handle, M5UnitTest* app) {
app_ = app; app_ = app;
@@ -3,7 +3,7 @@
#include "UiScale.h" #include "UiScale.h"
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/drivers/i2c_controller.h> #include <tactility/drivers/i2c_controller.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
void TestUnitPaHub::onStart(lv_obj_t* parent, AppHandle handle, M5UnitTest* app) { void TestUnitPaHub::onStart(lv_obj_t* parent, AppHandle handle, M5UnitTest* app) {
app_ = app; app_ = app;
@@ -2,7 +2,7 @@
#include "GroveLookup.h" #include "GroveLookup.h"
#include "UiScale.h" #include "UiScale.h"
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
#include <tt_lvgl_toolbar.h> #include <tt_lvgl_toolbar.h>
#include <algorithm> #include <algorithm>
#include <cstdio> #include <cstdio>
@@ -2,7 +2,7 @@
#include "GroveLookup.h" #include "GroveLookup.h"
#include "UiScale.h" #include "UiScale.h"
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
void TestUnitScroll::onStart(lv_obj_t* parent, AppHandle handle, M5UnitTest* app) { void TestUnitScroll::onStart(lv_obj_t* parent, AppHandle handle, M5UnitTest* app) {
app_ = app; app_ = app;
+1 -1
View File
@@ -2,7 +2,7 @@
#include "M5UnitTest.h" #include "M5UnitTest.h"
#include "UiScale.h" #include "UiScale.h"
#include <tt_lvgl_toolbar.h> #include <tt_lvgl_toolbar.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
lv_obj_t* TestViewBase::createToolbar(lv_obj_t* parent, AppHandle handle, const char* title) { lv_obj_t* TestViewBase::createToolbar(lv_obj_t* parent, AppHandle handle, const char* title) {
lv_obj_t* toolbar = tt_lvgl_toolbar_create_for_app(parent, handle); lv_obj_t* toolbar = tt_lvgl_toolbar_create_for_app(parent, handle);
+1 -1
View File
@@ -1,6 +1,6 @@
#pragma once #pragma once
#include <lvgl.h> #include <lvgl.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
// Device screen widths in default (portrait) orientation: // Device screen widths in default (portrait) orientation:
// tiny < 200 : small OLEDs, custom breadboard devices // tiny < 200 : small OLEDs, custom breadboard devices
+6 -6
View File
@@ -4,8 +4,8 @@
#include <esp_heap_caps.h> #include <esp_heap_caps.h>
#include <freertos/FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include <freertos/task.h> #include <freertos/task.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
#include <tt_lvgl.h> #include <lvgl/lvgl.h>
#include <tt_lvgl_toolbar.h> #include <tt_lvgl_toolbar.h>
static const char* TAG = "MediaKeys"; static const char* TAG = "MediaKeys";
@@ -154,24 +154,24 @@ void MediaKeys::btEventCallback(struct Device* /*device*/, void* context, struct
if (event.radio_state == BT_RADIO_STATE_ON) { if (event.radio_state == BT_RADIO_STATE_ON) {
// Radio is now up - start HID (needs LVGL lock for UI update) // Radio is now up - start HID (needs LVGL lock for UI update)
if (tt_lvgl_lock(1000)) { if (lvgl_try_lock(1000)) {
// Re-check inside lock to avoid TOCTOU race with handleSwitchToggle(false) // Re-check inside lock to avoid TOCTOU race with handleSwitchToggle(false)
if (self->_radioEnabling) { if (self->_radioEnabling) {
self->startHid(); self->startHid();
} }
tt_lvgl_unlock(); lvgl_unlock();
} }
} else if (event.radio_state == BT_RADIO_STATE_OFF && self->_isEnabled) { } else if (event.radio_state == BT_RADIO_STATE_OFF && self->_isEnabled) {
// Radio dropped while we were active - revert UI // Radio dropped while we were active - revert UI
LOG_I(TAG, "BT radio turned off, disabling HID"); LOG_I(TAG, "BT radio turned off, disabling HID");
if (tt_lvgl_lock(1000)) { if (lvgl_try_lock(1000)) {
if (tt_lvgl_hardware_keyboard_is_available()) self->exitKeyMode(); if (tt_lvgl_hardware_keyboard_is_available()) self->exitKeyMode();
self->_hidDevice = nullptr; self->_hidDevice = nullptr;
self->_isEnabled = false; self->_isEnabled = false;
self->_radioEnabling = false; self->_radioEnabling = false;
if (self->_switchWidget) lv_obj_remove_state(self->_switchWidget, LV_STATE_CHECKED); if (self->_switchWidget) lv_obj_remove_state(self->_switchWidget, LV_STATE_CHECKED);
if (self->_mainWrapper) lv_obj_add_flag(self->_mainWrapper, LV_OBJ_FLAG_HIDDEN); if (self->_mainWrapper) lv_obj_add_flag(self->_mainWrapper, LV_OBJ_FLAG_HIDDEN);
tt_lvgl_unlock(); lvgl_unlock();
} }
} }
} else if (event.type == BT_EVENT_PROFILE_STATE_CHANGED && event.profile_state.profile == BT_PROFILE_HID_DEVICE) { } else if (event.type == BT_EVENT_PROFILE_STATE_CHANGED && event.profile_state.profile == BT_PROFILE_HID_DEVICE) {
+2 -2
View File
@@ -2,7 +2,7 @@ manifest.version=0.2
target.sdk=0.8.0-dev target.sdk=0.8.0-dev
target.platforms=esp32s3,esp32p4 target.platforms=esp32s3,esp32p4
app.id=one.tactility.mediakeys app.id=one.tactility.mediakeys
app.version.name=0.4.0 app.version.name=0.5.0
app.version.code=4 app.version.code=5
app.name=Media Keys app.name=Media Keys
app.description=Bluetooth media keys. Touch or Physical Keyboard control\nB - previous, P - play/pause, N - next, M - mute, D - volume down, U - volume up.\nQ or ESC to exit focus. app.description=Bluetooth media keys. Touch or Physical Keyboard control\nB - previous, P - play/pause, N - next, M - mute, D - volume down, U - volume up.\nQ or ESC to exit focus.
+16 -16
View File
@@ -4,17 +4,17 @@
#include "drivers/Colors.h" #include "drivers/Colors.h"
#include <cstring> #include <cstring>
#include <tt_hal_display.h> #include <tactility/drivers/display.h>
class PixelBuffer { class PixelBuffer {
uint16_t pixelWidth; uint16_t pixelWidth;
uint16_t pixelHeight; uint16_t pixelHeight;
ColorFormat colorFormat; enum DisplayColorFormat colorFormat;
uint8_t* data; uint8_t* data;
public: public:
PixelBuffer(uint16_t pixelWidth, uint16_t pixelHeight, ColorFormat colorFormat) : PixelBuffer(uint16_t pixelWidth, uint16_t pixelHeight, enum DisplayColorFormat colorFormat) :
pixelWidth(pixelWidth), pixelWidth(pixelWidth),
pixelHeight(pixelHeight), pixelHeight(pixelHeight),
colorFormat(colorFormat) colorFormat(colorFormat)
@@ -35,7 +35,7 @@ public:
return pixelHeight; return pixelHeight;
} }
ColorFormat getColorFormat() const { enum DisplayColorFormat getColorFormat() const {
return colorFormat; return colorFormat;
} }
@@ -58,14 +58,14 @@ public:
uint8_t getPixelSize() const { uint8_t getPixelSize() const {
switch (colorFormat) { switch (colorFormat) {
case COLOR_FORMAT_MONOCHROME: case DISPLAY_COLOR_FORMAT_MONOCHROME:
return 1; return 1;
case COLOR_FORMAT_BGR565: case DISPLAY_COLOR_FORMAT_BGR565:
case COLOR_FORMAT_BGR565_SWAPPED: case DISPLAY_COLOR_FORMAT_BGR565_SWAPPED:
case COLOR_FORMAT_RGB565: case DISPLAY_COLOR_FORMAT_RGB565:
case COLOR_FORMAT_RGB565_SWAPPED: case DISPLAY_COLOR_FORMAT_RGB565_SWAPPED:
return 2; return 2;
case COLOR_FORMAT_RGB888: case DISPLAY_COLOR_FORMAT_RGB888:
return 3; return 3;
default: default:
// TODO: Crash with error // TODO: Crash with error
@@ -82,13 +82,13 @@ public:
void setPixel(uint16_t x, uint16_t y, uint8_t r, uint8_t g, uint8_t b) const { void setPixel(uint16_t x, uint16_t y, uint8_t r, uint8_t g, uint8_t b) const {
auto address = getPixelAddress(x, y); auto address = getPixelAddress(x, y);
switch (colorFormat) { switch (colorFormat) {
case COLOR_FORMAT_MONOCHROME: case DISPLAY_COLOR_FORMAT_MONOCHROME:
*address = (uint8_t)((uint16_t)r + (uint16_t)g + (uint16_t)b / 3); *address = (uint8_t)((uint16_t)r + (uint16_t)g + (uint16_t)b / 3);
break; break;
case COLOR_FORMAT_BGR565: case DISPLAY_COLOR_FORMAT_BGR565:
Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address)); Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address));
break; break;
case COLOR_FORMAT_BGR565_SWAPPED: { case DISPLAY_COLOR_FORMAT_BGR565_SWAPPED: {
// TODO: Make proper conversion function // TODO: Make proper conversion function
Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address)); Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address));
uint8_t temp = *address; uint8_t temp = *address;
@@ -96,11 +96,11 @@ public:
*(address + 1) = temp; *(address + 1) = temp;
break; break;
} }
case COLOR_FORMAT_RGB565: { case DISPLAY_COLOR_FORMAT_RGB565: {
Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address)); Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address));
break; break;
} }
case COLOR_FORMAT_RGB565_SWAPPED: { case DISPLAY_COLOR_FORMAT_RGB565_SWAPPED: {
// TODO: Make proper conversion function // TODO: Make proper conversion function
Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address)); Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address));
uint8_t temp = *address; uint8_t temp = *address;
@@ -108,7 +108,7 @@ public:
*(address + 1) = temp; *(address + 1) = temp;
break; break;
} }
case COLOR_FORMAT_RGB888: { case DISPLAY_COLOR_FORMAT_RGB888: {
uint8_t pixel[3] = { r, g, b }; uint8_t pixel[3] = { r, g, b };
memcpy(address, pixel, 3); memcpy(address, pixel, 3);
break; break;
@@ -1,49 +1,47 @@
#pragma once #pragma once
#include <cassert> #include <tactility/device.h>
#include <tt_hal_display.h> #include <tactility/drivers/display.h>
#include <Tactility/kernel/Kernel.h> #include <Tactility/kernel/Kernel.h>
/** /**
* Wrapper for tt_hal_display_driver_* * Wrapper for display_* device driver functions
*/ */
class DisplayDriver { class DisplayDriver {
DisplayDriverHandle handle = nullptr; struct Device* device;
public: public:
explicit DisplayDriver(DeviceId id) { explicit DisplayDriver(struct Device* device) : device(device) {
assert(tt_hal_display_driver_supported(id)); device_get(device);
handle = tt_hal_display_driver_alloc(id);
assert(handle != nullptr);
} }
~DisplayDriver() { ~DisplayDriver() {
tt_hal_display_driver_free(handle); device_put(device);
} }
bool lock(TickType_t timeout = tt::kernel::MAX_TICKS) const { bool lock(TickType_t timeout = tt::kernel::MAX_TICKS) const {
return tt_hal_display_driver_lock(handle, timeout); return device_try_lock(device, timeout);
} }
void unlock() const { void unlock() const {
tt_hal_display_driver_unlock(handle); device_unlock(device);
} }
uint16_t getWidth() const { uint16_t getWidth() const {
return tt_hal_display_driver_get_pixel_width(handle); return display_get_resolution_x(device);
} }
uint16_t getHeight() const { uint16_t getHeight() const {
return tt_hal_display_driver_get_pixel_height(handle); return display_get_resolution_y(device);
} }
ColorFormat getColorFormat() const { enum DisplayColorFormat getColorFormat() const {
return tt_hal_display_driver_get_colorformat(handle); return display_get_color_format(device);
} }
void drawBitmap(int xStart, int yStart, int xEnd, int yEnd, const void* pixelData) const { void drawBitmap(int xStart, int yStart, int xEnd, int yEnd, const void* pixelData) const {
tt_hal_display_driver_draw_bitmap(handle, xStart, yStart, xEnd, yEnd, pixelData); display_draw_bitmap(device, xStart, yStart, xEnd, yEnd, pixelData);
} }
}; };
@@ -1,28 +1,28 @@
#pragma once #pragma once
#include <cassert> #include <tactility/device.h>
#include <tt_hal_touch.h> #include <tactility/drivers/pointer.h>
/** /**
* Wrapper for tt_hal_touch_driver_* * Wrapper for pointer_* device driver functions
*/ */
class TouchDriver { class TouchDriver {
TouchDriverHandle handle = nullptr; struct Device* device;
public: public:
explicit TouchDriver(DeviceId id) { explicit TouchDriver(struct Device* device) : device(device) {
assert(tt_hal_touch_driver_supported(id)); device_get(device);
handle = tt_hal_touch_driver_alloc(id);
assert(handle != nullptr);
} }
~TouchDriver() { ~TouchDriver() {
tt_hal_touch_driver_free(handle); device_put(device);
} }
bool getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* count, uint8_t maxCount) const { bool getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* count, uint8_t maxCount) const {
return tt_hal_touch_driver_get_touched_points(handle, x, y, strength, count, maxCount); // Poll without blocking: perform one read attempt, then report whatever is cached.
pointer_read_data(device, 0);
return pointer_get_touched_points(device, x, y, strength, count, maxCount);
} }
}; };
+23 -44
View File
@@ -6,65 +6,44 @@
#include <tt_app.h> #include <tt_app.h>
#include <tt_app_alertdialog.h> #include <tt_app_alertdialog.h>
#include <tt_lvgl.h>
#include <tactility/device.h>
#include <tactility/drivers/display.h>
#include <tactility/drivers/pointer.h>
#include <lvgl/lvgl.h>
#include <lvgl/module.h>
#include <tactility/module.h>
constexpr auto TAG = "Main"; constexpr auto TAG = "Main";
/** Find a DisplayDevice that supports the DisplayDriver interface */
static bool findUsableDisplay(DeviceId& deviceId) {
uint16_t display_count = 0;
if (!tt_hal_device_find(DEVICE_TYPE_DISPLAY, &deviceId, &display_count, 1)) {
ESP_LOGE(TAG, "No display device found");
return false;
}
if (!tt_hal_display_driver_supported(deviceId)) {
ESP_LOGE(TAG, "Display doesn't support driver mode");
return false;
}
return true;
}
/** Find a TouchDevice that supports the TouchDriver interface */
static bool findUsableTouch(DeviceId& deviceId) {
uint16_t touch_count = 0;
if (!tt_hal_device_find(DEVICE_TYPE_TOUCH, &deviceId, &touch_count, 1)) {
ESP_LOGE(TAG, "No touch device found");
return false;
}
if (!tt_hal_touch_driver_supported(deviceId)) {
ESP_LOGE(TAG, "Touch doesn't support driver mode");
return false;
}
return true;
}
static void onCreate(AppHandle appHandle, void* data) { static void onCreate(AppHandle appHandle, void* data) {
DeviceId display_id; struct Device* display_device;
if (!findUsableDisplay(display_id)) { if (device_get_first_active_by_type(&DISPLAY_TYPE, &display_device) != ERROR_NONE) {
ESP_LOGE(TAG, "No display device found");
tt_app_stop(); tt_app_stop();
tt_app_alertdialog_start("Error", "The display doesn't support the required features.", nullptr, 0); tt_app_alertdialog_start("Error", "No display device was found.", nullptr, 0);
return; return;
} }
DeviceId touch_id; struct Device* touch_device;
if (!findUsableTouch(touch_id)) { if (device_get_first_active_by_type(&POINTER_TYPE, &touch_device) != ERROR_NONE) {
ESP_LOGE(TAG, "No touch device found");
device_put(display_device);
tt_app_stop(); tt_app_stop();
tt_app_alertdialog_start("Error", "The touch driver doesn't support the required features.", nullptr, 0); tt_app_alertdialog_start("Error", "No touch device was found.", nullptr, 0);
return; return;
} }
// Stop LVGL first (because it's currently using the drivers we want to use) // Stop LVGL first (because it's currently using the drivers we want to use)
tt_lvgl_stop(); module_stop(&lvgl_module);
ESP_LOGI(TAG, "Creating display driver"); ESP_LOGI(TAG, "Creating display driver");
auto display = new DisplayDriver(display_id); auto display = new DisplayDriver(display_device);
device_put(display_device);
ESP_LOGI(TAG, "Creating touch driver"); ESP_LOGI(TAG, "Creating touch driver");
auto touch = new TouchDriver(touch_id); auto touch = new TouchDriver(touch_device);
device_put(touch_device);
// Run the main logic // Run the main logic
ESP_LOGI(TAG, "Running application"); ESP_LOGI(TAG, "Running application");
@@ -82,9 +61,9 @@ static void onCreate(AppHandle appHandle, void* data) {
static void onDestroy(AppHandle appHandle, void* data) { static void onDestroy(AppHandle appHandle, void* data) {
// Restart LVGL to resume rendering of regular apps // Restart LVGL to resume rendering of regular apps
if (!tt_lvgl_is_started()) { if (!module_is_started(&lvgl_module)) {
ESP_LOGI(TAG, "Restarting LVGL"); ESP_LOGI(TAG, "Restarting LVGL");
tt_lvgl_start(); module_start(&lvgl_module);
} }
} }
+2 -2
View File
@@ -2,6 +2,6 @@ manifest.version=0.2
target.sdk=0.8.0-dev target.sdk=0.8.0-dev
target.platforms=esp32,esp32s3,esp32c6,esp32p4 target.platforms=esp32,esp32s3,esp32c6,esp32p4
app.id=one.tactility.mystifydemo app.id=one.tactility.mystifydemo
app.version.name=0.6.0 app.version.name=0.7.0
app.version.code=6 app.version.code=7
app.name=Mystify Demo app.name=Mystify Demo
+3 -2
View File
@@ -8,12 +8,13 @@
#include <functional> #include <functional>
#include <tt_app_alertdialog.h> #include <tt_app_alertdialog.h>
#include <tt_lvgl.h>
#include <TactilityCpp/LvglLock.h> #include <TactilityCpp/LvglLock.h>
#include <TactilityCpp/Preferences.h> #include <TactilityCpp/Preferences.h>
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/drivers/uart_controller.h> #include <tactility/drivers/uart_controller.h>
constexpr TickType_t LVGL_DEFAULT_LOCK_TIME = 500; // 500 ticks = 500 ms
class ConnectView final : public View { class ConnectView final : public View {
public: public:
@@ -45,7 +46,7 @@ private:
void onConnect() { void onConnect() {
auto lock = lvglLock.asScopedLock(); auto lock = lvglLock.asScopedLock();
if (!lock.lock(TT_LVGL_DEFAULT_LOCK_TIME)) { if (!lock.lock(LVGL_DEFAULT_LOCK_TIME)) {
return; return;
} }
@@ -7,8 +7,6 @@
#include <sstream> #include <sstream>
#include <lvgl.h> #include <lvgl.h>
#include <tt_lvgl.h>
#include <Tactility/RecursiveMutex.h> #include <Tactility/RecursiveMutex.h>
#include <Tactility/Thread.h> #include <Tactility/Thread.h>
#include <TactilityCpp/LvglLock.h> #include <TactilityCpp/LvglLock.h>
+2 -2
View File
@@ -2,6 +2,6 @@ manifest.version=0.2
target.sdk=0.8.0-dev target.sdk=0.8.0-dev
target.platforms=esp32,esp32s3,esp32c6,esp32p4 target.platforms=esp32,esp32s3,esp32c6,esp32p4
app.id=one.tactility.serialconsole app.id=one.tactility.serialconsole
app.version.name=0.7.0 app.version.name=0.8.0
app.version.code=7 app.version.code=8
app.name=Serial Console app.name=Serial Console
+2 -2
View File
@@ -12,8 +12,8 @@
#include <TactilityCpp/LvglLock.h> #include <TactilityCpp/LvglLock.h>
#include <tactility/lvgl_module.h> #include <lvgl/lvgl.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
constexpr auto* TAG = "Snake"; constexpr auto* TAG = "Snake";
+2 -2
View File
@@ -2,7 +2,7 @@ manifest.version=0.2
target.sdk=0.8.0-dev target.sdk=0.8.0-dev
target.platforms=esp32,esp32s3,esp32c6,esp32p4 target.platforms=esp32,esp32s3,esp32c6,esp32p4
app.id=one.tactility.snake app.id=one.tactility.snake
app.version.name=0.8.0 app.version.name=0.9.0
app.version.code=8 app.version.code=9
app.name=Snake app.name=Snake
app.description=Classic Snake game app.description=Classic Snake game
+2 -2
View File
@@ -4,8 +4,8 @@
#include <Tactility/kernel/Kernel.h> #include <Tactility/kernel/Kernel.h>
#include <tt_lvgl_toolbar.h> #include <tt_lvgl_toolbar.h>
#include <tt_lvgl_keyboard.h> #include <tt_lvgl_keyboard.h>
#include <tactility/lvgl_module.h> #include <lvgl/lvgl.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
+2 -2
View File
@@ -2,7 +2,7 @@ manifest.version=0.2
target.sdk=0.8.0-dev target.sdk=0.8.0-dev
target.platforms=esp32,esp32s3,esp32c6,esp32p4 target.platforms=esp32,esp32s3,esp32c6,esp32p4
app.id=one.tactility.todolist app.id=one.tactility.todolist
app.version.name=0.5.0 app.version.name=0.6.0
app.version.code=5 app.version.code=6
app.name=Todo List app.name=Todo List
app.description=Simple task list manager app.description=Simple task list manager
+2 -2
View File
@@ -9,8 +9,8 @@
#include <tt_app_alertdialog.h> #include <tt_app_alertdialog.h>
#include <tt_app_selectiondialog.h> #include <tt_app_selectiondialog.h>
#include <tt_preferences.h> #include <tt_preferences.h>
#include <tactility/lvgl_module.h> #include <lvgl/lvgl.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/lvgl_fonts.h>
#include <TactilityCpp/LvglLock.h> #include <TactilityCpp/LvglLock.h>
constexpr auto* TAG = "TwoEleven"; constexpr auto* TAG = "TwoEleven";
+2 -2
View File
@@ -2,7 +2,7 @@ manifest.version=0.2
target.sdk=0.8.0-dev target.sdk=0.8.0-dev
target.platforms=esp32,esp32s3,esp32c6,esp32p4 target.platforms=esp32,esp32s3,esp32c6,esp32p4
app.id=one.tactility.twoeleven app.id=one.tactility.twoeleven
app.version.name=0.7.0 app.version.name=0.8.0
app.version.code=7 app.version.code=8
app.name=2048 app.name=2048
app.description=A fun, customizable 2048 sliding tile game for tactility!\nSlide tiles to combine numbers and reach 2048.\nChoose grid sizes: 3x3 (easy), 4x4 (classic), 5x5, or 6x6 (expert). app.description=A fun, customizable 2048 sliding tile game for tactility!\nSlide tiles to combine numbers and reach 2048.\nChoose grid sizes: 3x3 (easy), 4x4 (classic), 5x5, or 6x6 (expert).
@@ -10,13 +10,15 @@ UnitDualButton::~UnitDualButton() {
bool UnitDualButton::begin(Device* controller, gpio_pin_t pinA, gpio_pin_t pinB) { bool UnitDualButton::begin(Device* controller, gpio_pin_t pinA, gpio_pin_t pinB) {
if (!controller) return false; if (!controller) return false;
descA_ = gpio_descriptor_acquire(controller, pinA, GPIO_OWNER_GPIO); gpio_flags_t flags = GPIO_FLAG_DIRECTION_INPUT | GPIO_FLAG_PULL_UP;
descA_ = gpio_descriptor_acquire(controller, pinA, flags, GPIO_OWNER_GPIO);
if (!descA_) { if (!descA_) {
ESP_LOGW(TAG, "Failed to acquire pin %d", (int)pinA); ESP_LOGW(TAG, "Failed to acquire pin %d", (int)pinA);
return false; return false;
} }
descB_ = gpio_descriptor_acquire(controller, pinB, GPIO_OWNER_GPIO); descB_ = gpio_descriptor_acquire(controller, pinB, flags, GPIO_OWNER_GPIO);
if (!descB_) { if (!descB_) {
ESP_LOGW(TAG, "Failed to acquire pin %d", (int)pinB); ESP_LOGW(TAG, "Failed to acquire pin %d", (int)pinB);
gpio_descriptor_release(descA_); gpio_descriptor_release(descA_);
@@ -24,20 +26,6 @@ bool UnitDualButton::begin(Device* controller, gpio_pin_t pinA, gpio_pin_t pinB)
return false; return false;
} }
gpio_flags_t flags = GPIO_FLAG_DIRECTION_INPUT | GPIO_FLAG_PULL_UP;
if (gpio_descriptor_set_flags(descA_, flags) != ERROR_NONE) {
ESP_LOGW(TAG, "Failed to configure pin %d flags", (int)pinA);
gpio_descriptor_release(descA_); gpio_descriptor_release(descB_);
descA_ = descB_ = nullptr;
return false;
}
if (gpio_descriptor_set_flags(descB_, flags) != ERROR_NONE) {
ESP_LOGW(TAG, "Failed to configure pin %d flags", (int)pinB);
gpio_descriptor_release(descA_); gpio_descriptor_release(descB_);
descA_ = descB_ = nullptr;
return false;
}
ready_ = true; ready_ = true;
ESP_LOGI(TAG, "DualButton ready on pins %d/%d", (int)pinA, (int)pinB); ESP_LOGI(TAG, "DualButton ready on pins %d/%d", (int)pinA, (int)pinB);
return true; return true;
@@ -1,19 +1,20 @@
#pragma once #pragma once
#include <Tactility/Lock.h> #include <Tactility/Lock.h>
#include <tt_lvgl.h> #include <lvgl/lvgl.h>
class LvglLock final : public tt::Lock { class LvglLock final : public tt::Lock {
public: public:
bool lock(TickType_t timeout = tt::kernel::MAX_TICKS) const override { using tt::Lock::lock;
return tt_lvgl_lock(timeout);
bool lock(TickType_t timeout) const override {
return lvgl_try_lock(timeout);
} }
void unlock() const override { void unlock() const override {
tt_lvgl_unlock(); lvgl_unlock();
} }
}; };