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:
committed by
GitHub
parent
25b966a340
commit
4f635d38e3
@@ -12,8 +12,8 @@
|
||||
#include <esp_random.h>
|
||||
#include <tt_lvgl_keyboard.h>
|
||||
|
||||
#include <tactility/lvgl_module.h>
|
||||
#include <tactility/lvgl_fonts.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <lvgl/lvgl_fonts.h>
|
||||
|
||||
constexpr auto* TAG = "Breakout";
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ manifest.version=0.2
|
||||
target.sdk=0.8.0-dev
|
||||
target.platforms=esp32,esp32s3,esp32c6,esp32p4
|
||||
app.id=one.tactility.breakout
|
||||
app.version.name=0.5.0
|
||||
app.version.code=5
|
||||
app.version.name=0.6.0
|
||||
app.version.code=6
|
||||
app.name=Breakout
|
||||
app.description=Classic brick-breaking arcade game
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <tt_app_alertdialog.h>
|
||||
#include <tt_lock.h>
|
||||
#include <tt_lvgl.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <tt_lvgl_toolbar.h>
|
||||
|
||||
#include <esp_random.h>
|
||||
@@ -87,9 +87,9 @@ void Diceware::startJob(uint32_t jobWordCount) {
|
||||
}
|
||||
|
||||
void Diceware::onFinishJob(std::string result) {
|
||||
tt_lvgl_lock(tt::kernel::MAX_TICKS);
|
||||
lvgl_lock();
|
||||
lv_label_set_text(resultLabel, result.c_str());
|
||||
tt_lvgl_unlock();
|
||||
lvgl_unlock();
|
||||
}
|
||||
|
||||
void Diceware::onClickGenerate(lv_event_t* e) {
|
||||
|
||||
@@ -2,6 +2,6 @@ manifest.version=0.2
|
||||
target.sdk=0.8.0-dev
|
||||
target.platforms=esp32,esp32s3,esp32c6,esp32p4
|
||||
app.id=one.tactility.diceware
|
||||
app.version.name=0.6.0
|
||||
app.version.code=6
|
||||
app.version.name=0.7.0
|
||||
app.version.code=7
|
||||
app.name=Diceware
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <tt_app_fileselection.h>
|
||||
#include <tt_bundle.h>
|
||||
#include <tt_lock.h>
|
||||
#include <tt_lvgl.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <tt_lvgl_toolbar.h>
|
||||
|
||||
#include <esp_app_desc.h>
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#include <tactility/log.h>
|
||||
|
||||
constexpr TickType_t LVGL_DEFAULT_LOCK_TIME = 500; // 500 ticks = 500 ms
|
||||
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
|
||||
@@ -283,12 +285,12 @@ struct UiDispatchPayload {
|
||||
void EspNowBridge::dispatchToUi(void (*work)(EspNowBridge&, void*), void* context, void (*freeContext)(void*)) {
|
||||
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
|
||||
// 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
|
||||
// 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
|
||||
// co-processor link...").
|
||||
bool locked = tt_lvgl_lock(TT_LVGL_DEFAULT_LOCK_TIME);
|
||||
bool locked = lvgl_try_lock(LVGL_DEFAULT_LOCK_TIME);
|
||||
if (!locked) {
|
||||
// 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
|
||||
@@ -310,7 +312,7 @@ void EspNowBridge::dispatchToUi(void (*work)(EspNowBridge&, void*), void* contex
|
||||
}
|
||||
delete payload;
|
||||
}, payload);
|
||||
tt_lvgl_unlock();
|
||||
lvgl_unlock();
|
||||
|
||||
if (result != LV_RESULT_OK) {
|
||||
if (freeContext != nullptr) {
|
||||
|
||||
@@ -2,7 +2,7 @@ manifest.version=0.2
|
||||
target.sdk=0.8.0-dev
|
||||
target.platforms=esp32p4
|
||||
app.id=one.tactility.espnowbridge
|
||||
app.version.name=0.1.0
|
||||
app.version.code=1
|
||||
app.version.name=0.2.0
|
||||
app.version.code=2
|
||||
app.name=ESP-NOW Bridge
|
||||
app.description=Companion app for updating P4 device C6 co-processor firmware to enable ESP-NOW bridge support.
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
|
||||
#include <tt_lvgl.h>
|
||||
#include <tt_lvgl_toolbar.h>
|
||||
|
||||
#include <tactility/lvgl_module.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
#include <esp_log.h>
|
||||
#include <driver/gpio.h>
|
||||
@@ -20,7 +19,7 @@ void Gpio::updatePinStates() {
|
||||
}
|
||||
|
||||
void Gpio::updatePinWidgets() {
|
||||
tt_lvgl_lock(tt::kernel::MAX_TICKS);
|
||||
lvgl_lock();
|
||||
for (int j = 0; j < pinStates.size(); ++j) {
|
||||
int level = pinStates[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) {
|
||||
|
||||
@@ -2,6 +2,6 @@ manifest.version=0.2
|
||||
target.sdk=0.8.0-dev
|
||||
target.platforms=esp32,esp32s3,esp32c6,esp32p4
|
||||
app.id=one.tactility.gpio
|
||||
app.version.name=0.7.0
|
||||
app.version.code=7
|
||||
app.version.name=0.8.0
|
||||
app.version.code=8
|
||||
app.name=GPIO
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
#include "drivers/Colors.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <tt_hal_display.h>
|
||||
#include <tactility/drivers/display.h>
|
||||
|
||||
class PixelBuffer {
|
||||
uint16_t pixelWidth;
|
||||
uint16_t pixelHeight;
|
||||
ColorFormat colorFormat;
|
||||
enum DisplayColorFormat colorFormat;
|
||||
uint8_t* data;
|
||||
|
||||
public:
|
||||
|
||||
PixelBuffer(uint16_t pixelWidth, uint16_t pixelHeight, ColorFormat colorFormat) :
|
||||
PixelBuffer(uint16_t pixelWidth, uint16_t pixelHeight, enum DisplayColorFormat colorFormat) :
|
||||
pixelWidth(pixelWidth),
|
||||
pixelHeight(pixelHeight),
|
||||
colorFormat(colorFormat)
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
return pixelHeight;
|
||||
}
|
||||
|
||||
ColorFormat getColorFormat() const {
|
||||
enum DisplayColorFormat getColorFormat() const {
|
||||
return colorFormat;
|
||||
}
|
||||
|
||||
@@ -58,14 +58,14 @@ public:
|
||||
|
||||
uint8_t getPixelSize() const {
|
||||
switch (colorFormat) {
|
||||
case COLOR_FORMAT_MONOCHROME:
|
||||
case DISPLAY_COLOR_FORMAT_MONOCHROME:
|
||||
return 1;
|
||||
case COLOR_FORMAT_BGR565:
|
||||
case COLOR_FORMAT_BGR565_SWAPPED:
|
||||
case COLOR_FORMAT_RGB565:
|
||||
case COLOR_FORMAT_RGB565_SWAPPED:
|
||||
case DISPLAY_COLOR_FORMAT_BGR565:
|
||||
case DISPLAY_COLOR_FORMAT_BGR565_SWAPPED:
|
||||
case DISPLAY_COLOR_FORMAT_RGB565:
|
||||
case DISPLAY_COLOR_FORMAT_RGB565_SWAPPED:
|
||||
return 2;
|
||||
case COLOR_FORMAT_RGB888:
|
||||
case DISPLAY_COLOR_FORMAT_RGB888:
|
||||
return 3;
|
||||
default:
|
||||
// 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 {
|
||||
auto address = getPixelAddress(x, y);
|
||||
switch (colorFormat) {
|
||||
case COLOR_FORMAT_MONOCHROME:
|
||||
case DISPLAY_COLOR_FORMAT_MONOCHROME:
|
||||
*address = (uint8_t)((uint16_t)r + (uint16_t)g + (uint16_t)b / 3);
|
||||
break;
|
||||
case COLOR_FORMAT_BGR565:
|
||||
case DISPLAY_COLOR_FORMAT_BGR565:
|
||||
Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address));
|
||||
break;
|
||||
case COLOR_FORMAT_BGR565_SWAPPED: {
|
||||
case DISPLAY_COLOR_FORMAT_BGR565_SWAPPED: {
|
||||
// TODO: Make proper conversion function
|
||||
Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address));
|
||||
uint8_t temp = *address;
|
||||
@@ -96,11 +96,11 @@ public:
|
||||
*(address + 1) = temp;
|
||||
break;
|
||||
}
|
||||
case COLOR_FORMAT_RGB565: {
|
||||
case DISPLAY_COLOR_FORMAT_RGB565: {
|
||||
Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address));
|
||||
break;
|
||||
}
|
||||
case COLOR_FORMAT_RGB565_SWAPPED: {
|
||||
case DISPLAY_COLOR_FORMAT_RGB565_SWAPPED: {
|
||||
// TODO: Make proper conversion function
|
||||
Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address));
|
||||
uint8_t temp = *address;
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
*(address + 1) = temp;
|
||||
break;
|
||||
}
|
||||
case COLOR_FORMAT_RGB888: {
|
||||
case DISPLAY_COLOR_FORMAT_RGB888: {
|
||||
uint8_t pixel[3] = { r, g, b };
|
||||
memcpy(address, pixel, 3);
|
||||
break;
|
||||
|
||||
@@ -1,49 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
#include <tt_hal_display.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/display.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
|
||||
/**
|
||||
* Wrapper for tt_hal_display_driver_*
|
||||
* Wrapper for display_* device driver functions
|
||||
*/
|
||||
class DisplayDriver {
|
||||
|
||||
DisplayDriverHandle handle = nullptr;
|
||||
struct Device* device;
|
||||
|
||||
public:
|
||||
|
||||
explicit DisplayDriver(DeviceId id) {
|
||||
assert(tt_hal_display_driver_supported(id));
|
||||
handle = tt_hal_display_driver_alloc(id);
|
||||
assert(handle != nullptr);
|
||||
explicit DisplayDriver(struct Device* device) : device(device) {
|
||||
device_get(device);
|
||||
}
|
||||
|
||||
~DisplayDriver() {
|
||||
tt_hal_display_driver_free(handle);
|
||||
device_put(device);
|
||||
}
|
||||
|
||||
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 {
|
||||
tt_hal_display_driver_unlock(handle);
|
||||
device_unlock(device);
|
||||
}
|
||||
|
||||
uint16_t getWidth() const {
|
||||
return tt_hal_display_driver_get_pixel_width(handle);
|
||||
return display_get_resolution_x(device);
|
||||
}
|
||||
|
||||
uint16_t getHeight() const {
|
||||
return tt_hal_display_driver_get_pixel_height(handle);
|
||||
return display_get_resolution_y(device);
|
||||
}
|
||||
|
||||
ColorFormat getColorFormat() const {
|
||||
return tt_hal_display_driver_get_colorformat(handle);
|
||||
enum DisplayColorFormat getColorFormat() const {
|
||||
return display_get_color_format(device);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
#include <cassert>
|
||||
#include <tt_hal_touch.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/pointer.h>
|
||||
|
||||
/**
|
||||
* Wrapper for tt_hal_touch_driver_*
|
||||
* Wrapper for pointer_* device driver functions
|
||||
*/
|
||||
class TouchDriver {
|
||||
|
||||
TouchDriverHandle handle = nullptr;
|
||||
struct Device* device;
|
||||
|
||||
public:
|
||||
|
||||
explicit TouchDriver(DeviceId id) {
|
||||
assert(tt_hal_touch_driver_supported(id));
|
||||
handle = tt_hal_touch_driver_alloc(id);
|
||||
assert(handle != nullptr);
|
||||
explicit TouchDriver(struct Device* device) : device(device) {
|
||||
device_get(device);
|
||||
}
|
||||
|
||||
~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 {
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,65 +6,44 @@
|
||||
|
||||
#include <tt_app.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";
|
||||
|
||||
/** 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) {
|
||||
DeviceId display_id;
|
||||
if (!findUsableDisplay(display_id)) {
|
||||
struct Device* display_device;
|
||||
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_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;
|
||||
}
|
||||
|
||||
DeviceId touch_id;
|
||||
if (!findUsableTouch(touch_id)) {
|
||||
struct Device* touch_device;
|
||||
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_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;
|
||||
}
|
||||
|
||||
// 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");
|
||||
auto display = new DisplayDriver(display_id);
|
||||
auto display = new DisplayDriver(display_device);
|
||||
device_put(display_device);
|
||||
|
||||
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
|
||||
ESP_LOGI(TAG, "Running application");
|
||||
@@ -82,9 +61,9 @@ static void onCreate(AppHandle appHandle, void* data) {
|
||||
|
||||
static void onDestroy(AppHandle appHandle, void* data) {
|
||||
// Restart LVGL to resume rendering of regular apps
|
||||
if (!tt_lvgl_is_started()) {
|
||||
if (!module_is_started(&lvgl_module)) {
|
||||
ESP_LOGI(TAG, "Restarting LVGL");
|
||||
tt_lvgl_start();
|
||||
module_start(&lvgl_module);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "M5UnitTest.h"
|
||||
#include "UiScale.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) {
|
||||
app_ = app;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <lvgl.h>
|
||||
#include <tactility/lvgl_icon_shared.h>
|
||||
#include <lvgl/lvgl_icon_shared.h>
|
||||
#include <tt_app.h>
|
||||
|
||||
class M5UnitTest;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "GroveLookup.h"
|
||||
#include "UiScale.h"
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/lvgl_fonts.h>
|
||||
#include <lvgl/lvgl_fonts.h>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "GroveLookup.h"
|
||||
#include "UiScale.h"
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/lvgl_fonts.h>
|
||||
#include <lvgl/lvgl_fonts.h>
|
||||
#include <cstring>
|
||||
|
||||
void TestUnitByteButton::onStart(lv_obj_t* parent, AppHandle handle, M5UnitTest* app) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "UiScale.h"
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/uart_controller.h>
|
||||
#include <tactility/lvgl_fonts.h>
|
||||
#include <lvgl/lvgl_fonts.h>
|
||||
#include <cstring>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "TestUnitDualButton.h"
|
||||
#include "UiScale.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_MAX = 57;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "GroveLookup.h"
|
||||
#include "UiScale.h"
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/lvgl_fonts.h>
|
||||
#include <lvgl/lvgl_fonts.h>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "GroveLookup.h"
|
||||
#include "UiScale.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) {
|
||||
app_ = app;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "GroveLookup.h"
|
||||
#include "UiScale.h"
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/lvgl_fonts.h>
|
||||
#include <lvgl/lvgl_fonts.h>
|
||||
#include <esp_timer.h>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "GroveLookup.h"
|
||||
#include "UiScale.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) {
|
||||
app_ = app;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "UiScale.h"
|
||||
#include <tactility/device.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) {
|
||||
app_ = app;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "GroveLookup.h"
|
||||
#include "UiScale.h"
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/lvgl_fonts.h>
|
||||
#include <lvgl/lvgl_fonts.h>
|
||||
#include <tt_lvgl_toolbar.h>
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "GroveLookup.h"
|
||||
#include "UiScale.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) {
|
||||
app_ = app;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "M5UnitTest.h"
|
||||
#include "UiScale.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* toolbar = tt_lvgl_toolbar_create_for_app(parent, handle);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include <lvgl.h>
|
||||
#include <tactility/lvgl_fonts.h>
|
||||
#include <lvgl/lvgl_fonts.h>
|
||||
|
||||
// Device screen widths in default (portrait) orientation:
|
||||
// tiny < 200 : small OLEDs, custom breadboard devices
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <esp_heap_caps.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
#include <tactility/lvgl_fonts.h>
|
||||
#include <tt_lvgl.h>
|
||||
#include <lvgl/lvgl_fonts.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <tt_lvgl_toolbar.h>
|
||||
|
||||
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) {
|
||||
// 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)
|
||||
if (self->_radioEnabling) {
|
||||
self->startHid();
|
||||
}
|
||||
tt_lvgl_unlock();
|
||||
lvgl_unlock();
|
||||
}
|
||||
} else if (event.radio_state == BT_RADIO_STATE_OFF && self->_isEnabled) {
|
||||
// Radio dropped while we were active - revert UI
|
||||
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();
|
||||
self->_hidDevice = nullptr;
|
||||
self->_isEnabled = false;
|
||||
self->_radioEnabling = false;
|
||||
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);
|
||||
tt_lvgl_unlock();
|
||||
lvgl_unlock();
|
||||
}
|
||||
}
|
||||
} else if (event.type == BT_EVENT_PROFILE_STATE_CHANGED && event.profile_state.profile == BT_PROFILE_HID_DEVICE) {
|
||||
|
||||
@@ -2,7 +2,7 @@ manifest.version=0.2
|
||||
target.sdk=0.8.0-dev
|
||||
target.platforms=esp32s3,esp32p4
|
||||
app.id=one.tactility.mediakeys
|
||||
app.version.name=0.4.0
|
||||
app.version.code=4
|
||||
app.version.name=0.5.0
|
||||
app.version.code=5
|
||||
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.
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
#include "drivers/Colors.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <tt_hal_display.h>
|
||||
#include <tactility/drivers/display.h>
|
||||
|
||||
class PixelBuffer {
|
||||
uint16_t pixelWidth;
|
||||
uint16_t pixelHeight;
|
||||
ColorFormat colorFormat;
|
||||
enum DisplayColorFormat colorFormat;
|
||||
uint8_t* data;
|
||||
|
||||
public:
|
||||
|
||||
PixelBuffer(uint16_t pixelWidth, uint16_t pixelHeight, ColorFormat colorFormat) :
|
||||
PixelBuffer(uint16_t pixelWidth, uint16_t pixelHeight, enum DisplayColorFormat colorFormat) :
|
||||
pixelWidth(pixelWidth),
|
||||
pixelHeight(pixelHeight),
|
||||
colorFormat(colorFormat)
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
return pixelHeight;
|
||||
}
|
||||
|
||||
ColorFormat getColorFormat() const {
|
||||
enum DisplayColorFormat getColorFormat() const {
|
||||
return colorFormat;
|
||||
}
|
||||
|
||||
@@ -58,14 +58,14 @@ public:
|
||||
|
||||
uint8_t getPixelSize() const {
|
||||
switch (colorFormat) {
|
||||
case COLOR_FORMAT_MONOCHROME:
|
||||
case DISPLAY_COLOR_FORMAT_MONOCHROME:
|
||||
return 1;
|
||||
case COLOR_FORMAT_BGR565:
|
||||
case COLOR_FORMAT_BGR565_SWAPPED:
|
||||
case COLOR_FORMAT_RGB565:
|
||||
case COLOR_FORMAT_RGB565_SWAPPED:
|
||||
case DISPLAY_COLOR_FORMAT_BGR565:
|
||||
case DISPLAY_COLOR_FORMAT_BGR565_SWAPPED:
|
||||
case DISPLAY_COLOR_FORMAT_RGB565:
|
||||
case DISPLAY_COLOR_FORMAT_RGB565_SWAPPED:
|
||||
return 2;
|
||||
case COLOR_FORMAT_RGB888:
|
||||
case DISPLAY_COLOR_FORMAT_RGB888:
|
||||
return 3;
|
||||
default:
|
||||
// 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 {
|
||||
auto address = getPixelAddress(x, y);
|
||||
switch (colorFormat) {
|
||||
case COLOR_FORMAT_MONOCHROME:
|
||||
case DISPLAY_COLOR_FORMAT_MONOCHROME:
|
||||
*address = (uint8_t)((uint16_t)r + (uint16_t)g + (uint16_t)b / 3);
|
||||
break;
|
||||
case COLOR_FORMAT_BGR565:
|
||||
case DISPLAY_COLOR_FORMAT_BGR565:
|
||||
Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address));
|
||||
break;
|
||||
case COLOR_FORMAT_BGR565_SWAPPED: {
|
||||
case DISPLAY_COLOR_FORMAT_BGR565_SWAPPED: {
|
||||
// TODO: Make proper conversion function
|
||||
Colors::rgb888ToBgr565(r, g, b, reinterpret_cast<uint16_t*>(address));
|
||||
uint8_t temp = *address;
|
||||
@@ -96,11 +96,11 @@ public:
|
||||
*(address + 1) = temp;
|
||||
break;
|
||||
}
|
||||
case COLOR_FORMAT_RGB565: {
|
||||
case DISPLAY_COLOR_FORMAT_RGB565: {
|
||||
Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address));
|
||||
break;
|
||||
}
|
||||
case COLOR_FORMAT_RGB565_SWAPPED: {
|
||||
case DISPLAY_COLOR_FORMAT_RGB565_SWAPPED: {
|
||||
// TODO: Make proper conversion function
|
||||
Colors::rgb888ToRgb565(r, g, b, reinterpret_cast<uint16_t*>(address));
|
||||
uint8_t temp = *address;
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
*(address + 1) = temp;
|
||||
break;
|
||||
}
|
||||
case COLOR_FORMAT_RGB888: {
|
||||
case DISPLAY_COLOR_FORMAT_RGB888: {
|
||||
uint8_t pixel[3] = { r, g, b };
|
||||
memcpy(address, pixel, 3);
|
||||
break;
|
||||
|
||||
@@ -1,49 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
#include <tt_hal_display.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/display.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
|
||||
/**
|
||||
* Wrapper for tt_hal_display_driver_*
|
||||
* Wrapper for display_* device driver functions
|
||||
*/
|
||||
class DisplayDriver {
|
||||
|
||||
DisplayDriverHandle handle = nullptr;
|
||||
struct Device* device;
|
||||
|
||||
public:
|
||||
|
||||
explicit DisplayDriver(DeviceId id) {
|
||||
assert(tt_hal_display_driver_supported(id));
|
||||
handle = tt_hal_display_driver_alloc(id);
|
||||
assert(handle != nullptr);
|
||||
explicit DisplayDriver(struct Device* device) : device(device) {
|
||||
device_get(device);
|
||||
}
|
||||
|
||||
~DisplayDriver() {
|
||||
tt_hal_display_driver_free(handle);
|
||||
device_put(device);
|
||||
}
|
||||
|
||||
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 {
|
||||
tt_hal_display_driver_unlock(handle);
|
||||
device_unlock(device);
|
||||
}
|
||||
|
||||
uint16_t getWidth() const {
|
||||
return tt_hal_display_driver_get_pixel_width(handle);
|
||||
return display_get_resolution_x(device);
|
||||
}
|
||||
|
||||
uint16_t getHeight() const {
|
||||
return tt_hal_display_driver_get_pixel_height(handle);
|
||||
return display_get_resolution_y(device);
|
||||
}
|
||||
|
||||
ColorFormat getColorFormat() const {
|
||||
return tt_hal_display_driver_get_colorformat(handle);
|
||||
enum DisplayColorFormat getColorFormat() const {
|
||||
return display_get_color_format(device);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
#include <cassert>
|
||||
#include <tt_hal_touch.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/pointer.h>
|
||||
|
||||
/**
|
||||
* Wrapper for tt_hal_touch_driver_*
|
||||
* Wrapper for pointer_* device driver functions
|
||||
*/
|
||||
class TouchDriver {
|
||||
|
||||
TouchDriverHandle handle = nullptr;
|
||||
struct Device* device;
|
||||
|
||||
public:
|
||||
|
||||
explicit TouchDriver(DeviceId id) {
|
||||
assert(tt_hal_touch_driver_supported(id));
|
||||
handle = tt_hal_touch_driver_alloc(id);
|
||||
assert(handle != nullptr);
|
||||
explicit TouchDriver(struct Device* device) : device(device) {
|
||||
device_get(device);
|
||||
}
|
||||
|
||||
~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 {
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,65 +6,44 @@
|
||||
|
||||
#include <tt_app.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";
|
||||
|
||||
/** 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) {
|
||||
DeviceId display_id;
|
||||
if (!findUsableDisplay(display_id)) {
|
||||
struct Device* display_device;
|
||||
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_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;
|
||||
}
|
||||
|
||||
DeviceId touch_id;
|
||||
if (!findUsableTouch(touch_id)) {
|
||||
struct Device* touch_device;
|
||||
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_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;
|
||||
}
|
||||
|
||||
// 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");
|
||||
auto display = new DisplayDriver(display_id);
|
||||
auto display = new DisplayDriver(display_device);
|
||||
device_put(display_device);
|
||||
|
||||
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
|
||||
ESP_LOGI(TAG, "Running application");
|
||||
@@ -82,9 +61,9 @@ static void onCreate(AppHandle appHandle, void* data) {
|
||||
|
||||
static void onDestroy(AppHandle appHandle, void* data) {
|
||||
// Restart LVGL to resume rendering of regular apps
|
||||
if (!tt_lvgl_is_started()) {
|
||||
if (!module_is_started(&lvgl_module)) {
|
||||
ESP_LOGI(TAG, "Restarting LVGL");
|
||||
tt_lvgl_start();
|
||||
module_start(&lvgl_module);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@ manifest.version=0.2
|
||||
target.sdk=0.8.0-dev
|
||||
target.platforms=esp32,esp32s3,esp32c6,esp32p4
|
||||
app.id=one.tactility.mystifydemo
|
||||
app.version.name=0.6.0
|
||||
app.version.code=6
|
||||
app.version.name=0.7.0
|
||||
app.version.code=7
|
||||
app.name=Mystify Demo
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
#include <functional>
|
||||
|
||||
#include <tt_app_alertdialog.h>
|
||||
#include <tt_lvgl.h>
|
||||
#include <TactilityCpp/LvglLock.h>
|
||||
#include <TactilityCpp/Preferences.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/uart_controller.h>
|
||||
|
||||
constexpr TickType_t LVGL_DEFAULT_LOCK_TIME = 500; // 500 ticks = 500 ms
|
||||
|
||||
class ConnectView final : public View {
|
||||
|
||||
public:
|
||||
@@ -45,7 +46,7 @@ private:
|
||||
|
||||
void onConnect() {
|
||||
auto lock = lvglLock.asScopedLock();
|
||||
if (!lock.lock(TT_LVGL_DEFAULT_LOCK_TIME)) {
|
||||
if (!lock.lock(LVGL_DEFAULT_LOCK_TIME)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include <sstream>
|
||||
#include <lvgl.h>
|
||||
|
||||
#include <tt_lvgl.h>
|
||||
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/Thread.h>
|
||||
#include <TactilityCpp/LvglLock.h>
|
||||
|
||||
@@ -2,6 +2,6 @@ manifest.version=0.2
|
||||
target.sdk=0.8.0-dev
|
||||
target.platforms=esp32,esp32s3,esp32c6,esp32p4
|
||||
app.id=one.tactility.serialconsole
|
||||
app.version.name=0.7.0
|
||||
app.version.code=7
|
||||
app.version.name=0.8.0
|
||||
app.version.code=8
|
||||
app.name=Serial Console
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
#include <TactilityCpp/LvglLock.h>
|
||||
|
||||
#include <tactility/lvgl_module.h>
|
||||
#include <tactility/lvgl_fonts.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <lvgl/lvgl_fonts.h>
|
||||
|
||||
constexpr auto* TAG = "Snake";
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ manifest.version=0.2
|
||||
target.sdk=0.8.0-dev
|
||||
target.platforms=esp32,esp32s3,esp32c6,esp32p4
|
||||
app.id=one.tactility.snake
|
||||
app.version.name=0.8.0
|
||||
app.version.code=8
|
||||
app.version.name=0.9.0
|
||||
app.version.code=9
|
||||
app.name=Snake
|
||||
app.description=Classic Snake game
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <tt_lvgl_toolbar.h>
|
||||
#include <tt_lvgl_keyboard.h>
|
||||
#include <tactility/lvgl_module.h>
|
||||
#include <tactility/lvgl_fonts.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <lvgl/lvgl_fonts.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -2,7 +2,7 @@ manifest.version=0.2
|
||||
target.sdk=0.8.0-dev
|
||||
target.platforms=esp32,esp32s3,esp32c6,esp32p4
|
||||
app.id=one.tactility.todolist
|
||||
app.version.name=0.5.0
|
||||
app.version.code=5
|
||||
app.version.name=0.6.0
|
||||
app.version.code=6
|
||||
app.name=Todo List
|
||||
app.description=Simple task list manager
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include <tt_app_alertdialog.h>
|
||||
#include <tt_app_selectiondialog.h>
|
||||
#include <tt_preferences.h>
|
||||
#include <tactility/lvgl_module.h>
|
||||
#include <tactility/lvgl_fonts.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <lvgl/lvgl_fonts.h>
|
||||
#include <TactilityCpp/LvglLock.h>
|
||||
|
||||
constexpr auto* TAG = "TwoEleven";
|
||||
|
||||
@@ -2,7 +2,7 @@ manifest.version=0.2
|
||||
target.sdk=0.8.0-dev
|
||||
target.platforms=esp32,esp32s3,esp32c6,esp32p4
|
||||
app.id=one.tactility.twoeleven
|
||||
app.version.name=0.7.0
|
||||
app.version.code=7
|
||||
app.version.name=0.8.0
|
||||
app.version.code=8
|
||||
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).
|
||||
|
||||
@@ -10,13 +10,15 @@ UnitDualButton::~UnitDualButton() {
|
||||
bool UnitDualButton::begin(Device* controller, gpio_pin_t pinA, gpio_pin_t pinB) {
|
||||
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_) {
|
||||
ESP_LOGW(TAG, "Failed to acquire pin %d", (int)pinA);
|
||||
return false;
|
||||
}
|
||||
|
||||
descB_ = gpio_descriptor_acquire(controller, pinB, GPIO_OWNER_GPIO);
|
||||
descB_ = gpio_descriptor_acquire(controller, pinB, flags, GPIO_OWNER_GPIO);
|
||||
if (!descB_) {
|
||||
ESP_LOGW(TAG, "Failed to acquire pin %d", (int)pinB);
|
||||
gpio_descriptor_release(descA_);
|
||||
@@ -24,20 +26,6 @@ bool UnitDualButton::begin(Device* controller, gpio_pin_t pinA, gpio_pin_t pinB)
|
||||
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;
|
||||
ESP_LOGI(TAG, "DualButton ready on pins %d/%d", (int)pinA, (int)pinB);
|
||||
return true;
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/Lock.h>
|
||||
#include <tt_lvgl.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
class LvglLock final : public tt::Lock {
|
||||
|
||||
public:
|
||||
|
||||
bool lock(TickType_t timeout = tt::kernel::MAX_TICKS) const override {
|
||||
return tt_lvgl_lock(timeout);
|
||||
using tt::Lock::lock;
|
||||
|
||||
bool lock(TickType_t timeout) const override {
|
||||
return lvgl_try_lock(timeout);
|
||||
}
|
||||
|
||||
|
||||
void unlock() const override {
|
||||
tt_lvgl_unlock();
|
||||
lvgl_unlock();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user