2 Commits

Author SHA1 Message Date
Ken Van Hoeylandt b1e7eb999a Update apps for SDK updates (#38)
The updates mainly relate to lvgl-module changes.
2026-07-26 17:20:01 +02:00
Ken Van Hoeylandt 4f635d38e3 Updates for removal of deprecated HAL (#37)
Update all apps to replace deprecated LVGL code and to use the new kernel APIs.
2026-07-26 12:47:03 +02:00
66 changed files with 338 additions and 407 deletions
+4 -4
View File
@@ -1,6 +1,6 @@
#include "Brainfuck.h" #include "Brainfuck.h"
#include <tt_app.h> #include <tt_app.h>
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
#include <dirent.h> #include <dirent.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -399,11 +399,11 @@ void Brainfuck::onShow(AppHandle app, lv_obj_t* parent) {
lv_obj_remove_flag(parent, LV_OBJ_FLAG_SCROLLABLE); lv_obj_remove_flag(parent, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
lv_obj_t* toolbar = tt_lvgl_toolbar_create_for_app(parent, app); lv_obj_t* toolbar = lvgl_toolbar_create(parent, "Brainfuck interpreter");
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
clrBtn = tt_lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_TRASH, onClearClicked, nullptr); clrBtn = lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_TRASH, onClearClicked, nullptr);
lv_obj_add_flag(clrBtn, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(clrBtn, LV_OBJ_FLAG_HIDDEN);
tt_lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_LIST, onExamplesClicked, nullptr); lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_LIST, onExamplesClicked, nullptr);
lv_obj_t* cont = lv_obj_create(parent); lv_obj_t* cont = lv_obj_create(parent);
lv_obj_set_width(cont, LV_PCT(100)); lv_obj_set_width(cont, LV_PCT(100));
+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.brainfuck app.id=one.tactility.brainfuck
app.version.name=0.5.0 app.version.name=0.6.0
app.version.code=5 app.version.code=6
app.name=Brainfuck interpreter app.name=Brainfuck interpreter
app.description=Brainfuck esoteric language interpreter app.description=Brainfuck esoteric language interpreter
+7 -6
View File
@@ -7,13 +7,14 @@
#include <cstdio> #include <cstdio>
#include <cmath> #include <cmath>
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
#include <tt_preferences.h> #include <tt_preferences.h>
#include <esp_random.h> #include <esp_random.h>
#include <tt_lvgl_keyboard.h> #include <tactility/device.h>
#include <tactility/drivers/keyboard.h>
#include <tactility/lvgl_module.h> #include <lvgl/lvgl.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/fonts.h>
constexpr auto* TAG = "Breakout"; constexpr auto* TAG = "Breakout";
@@ -128,7 +129,7 @@ void Breakout::onShow(AppHandle appHandle, lv_obj_t* parent) {
} }
// Toolbar // Toolbar
lv_obj_t* toolbar = tt_lvgl_toolbar_create_for_app(parent, appHandle); lv_obj_t* toolbar = lvgl_toolbar_create(parent, "Breakout");
// Score wrapper in toolbar // Score wrapper in toolbar
lv_obj_t* scoreWrap = lv_obj_create(toolbar); lv_obj_t* scoreWrap = lv_obj_create(toolbar);
@@ -1329,7 +1330,7 @@ void Breakout::updateMessage() {
case GameState::Ready: { case GameState::Ready: {
char buf[64]; char buf[64];
const char* input_hint = "Touch"; const char* input_hint = "Touch";
if (tt_lvgl_hardware_keyboard_is_available()) { if (device_has_active_by_type(&KEYBOARD_TYPE)) {
input_hint = "Space"; input_hint = "Space";
} }
if (level > 1) { if (level > 1) {
+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.7.0
app.version.code=5 app.version.code=7
app.name=Breakout app.name=Breakout
app.description=Classic brick-breaking arcade game app.description=Classic brick-breaking arcade game
+2 -2
View File
@@ -2,7 +2,7 @@
#include <cstdio> #include <cstdio>
#include <ctype.h> #include <ctype.h>
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
#include <stack> #include <stack>
#include <cstring> #include <cstring>
@@ -148,7 +148,7 @@ void Calculator::onShow(AppHandle appHandle, lv_obj_t* parent) {
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
lv_obj_t* toolbar = tt_lvgl_toolbar_create_for_app(parent, appHandle); lv_obj_t* toolbar = lvgl_toolbar_create(parent, "Calculator");
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
lv_obj_t* wrapper = lv_obj_create(parent); lv_obj_t* wrapper = lv_obj_create(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.calculator app.id=one.tactility.calculator
app.version.name=0.6.0 app.version.name=0.7.0
app.version.code=6 app.version.code=7
app.name=Calculator app.name=Calculator
+17 -18
View File
@@ -1,9 +1,9 @@
#include "Diceware.h" #include "Diceware.h"
#include <tt_app_alertdialog.h> #include <tt_app_alertdialog.h>
#include <tt_lock.h> #include <tactility/filesystem/file_mutex.h>
#include <tt_lvgl.h> #include <lvgl/lvgl.h>
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
#include <esp_random.h> #include <esp_random.h>
#include <esp_log.h> #include <esp_log.h>
@@ -39,18 +39,17 @@ static std::string readWordAtLine(const AppHandle handle, const int lineIndex) {
return ""; return "";
} }
auto lock = tt_lock_alloc_for_path(path); struct FileMutex mutex;
file_mutex_get(&mutex, path);
std::string word; std::string word;
if (tt_lock_acquire(lock, tt::kernel::MAX_TICKS)) { file_mutex_lock(&mutex);
FILE* file = fopen(path, "r"); FILE* file = fopen(path, "r");
if (file != nullptr) { if (file != nullptr) {
skipNewlines(file, lineIndex); skipNewlines(file, lineIndex);
word = readWord(file); word = readWord(file);
fclose(file); fclose(file);
} else { ESP_LOGE(TAG, "Failed to open %s", path); } } else { ESP_LOGE(TAG, "Failed to open %s", path); }
tt_lock_release(lock); file_mutex_unlock(&mutex);
} else { ESP_LOGE(TAG, "Failed to acquire lock for %s", path); }
tt_lock_free(lock);
return word; return word;
} }
@@ -87,9 +86,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) {
@@ -123,8 +122,8 @@ void Diceware::onShow(AppHandle appHandle, lv_obj_t* parent) {
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
auto* toolbar = tt_lvgl_toolbar_create_for_app(parent, appHandle); auto* toolbar = lvgl_toolbar_create(parent, "Diceware");
tt_lvgl_toolbar_add_text_button_action(toolbar, "?", onHelpClicked, nullptr); lvgl_toolbar_add_text_button_action(toolbar, "?", onHelpClicked, nullptr);
auto* wrapper = lv_obj_create(parent); auto* wrapper = lv_obj_create(parent);
lv_obj_set_style_border_width(wrapper, 0, LV_STATE_DEFAULT); lv_obj_set_style_border_width(wrapper, 0, LV_STATE_DEFAULT);
+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.8.0
app.version.code=6 app.version.code=8
app.name=Diceware app.name=Diceware
+2 -2
View File
@@ -1,7 +1,7 @@
#include "EpubReader.h" #include "EpubReader.h"
#include "HtmlStrip.h" // stripHtmlToText #include "HtmlStrip.h" // stripHtmlToText
#include <tt_bundle.h> #include <tt_bundle.h>
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
#include <tt_app_alertdialog.h> #include <tt_app_alertdialog.h>
#include <tt_app_selectiondialog.h> #include <tt_app_selectiondialog.h>
#include <tactility/log.h> #include <tactility/log.h>
@@ -239,7 +239,7 @@ void EpubReader::onShow(AppHandle app, lv_obj_t* parent) {
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
lv_obj_remove_flag(parent, LV_OBJ_FLAG_SCROLLABLE); lv_obj_remove_flag(parent, LV_OBJ_FLAG_SCROLLABLE);
toolbar_ = tt_lvgl_toolbar_create_for_app(parent, app); toolbar_ = lvgl_toolbar_create(parent, "Epub Reader");
wrapperWidget_ = lv_obj_create(parent); wrapperWidget_ = lv_obj_create(parent);
lv_obj_set_width(wrapperWidget_, LV_PCT(100)); lv_obj_set_width(wrapperWidget_, LV_PCT(100));
@@ -1,6 +1,6 @@
#include "EpubReader.h" #include "EpubReader.h"
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
#include <tt_lock.h> #include <tactility/filesystem/file_mutex.h>
#include <tactility/log.h> #include <tactility/log.h>
#include <Tactility/kernel/Kernel.h> #include <Tactility/kernel/Kernel.h>
#include <freertos/FreeRTOS.h> #include <freertos/FreeRTOS.h>
@@ -43,7 +43,7 @@ void EpubReader::spawnOpenTask(EpubReader* self, bool restore) {
// Show a brief placeholder so old content doesn't linger during the open // Show a brief placeholder so old content doesn't linger during the open
lv_obj_clean(self->wrapperWidget_); lv_obj_clean(self->wrapperWidget_);
tt_lvgl_toolbar_clear_actions(self->toolbar_); lvgl_toolbar_clear_actions(self->toolbar_);
lv_obj_t* lbl = lv_label_create(self->wrapperWidget_); lv_obj_t* lbl = lv_label_create(self->wrapperWidget_);
lv_obj_set_style_pad_all(lbl, 8, 0); lv_obj_set_style_pad_all(lbl, 8, 0);
lv_label_set_text(lbl, restore ? "Loading..." : "Opening..."); lv_label_set_text(lbl, restore ? "Loading..." : "Opening...");
@@ -115,14 +115,9 @@ void EpubReader::backgroundOpenTask(void* data) {
// Acquire the filesystem lock before any SD card I/O - prevents concurrent // Acquire the filesystem lock before any SD card I/O - prevents concurrent
// SDMMC access from the background and LVGL tasks (bus errors 0x107/0x108). // SDMMC access from the background and LVGL tasks (bus errors 0x107/0x108).
auto lock = tt_lock_alloc_for_path(a->filePath.c_str()); struct FileMutex mutex;
if (!tt_lock_acquire(lock, tt::kernel::MAX_TICKS)) { file_mutex_get(&mutex, a->filePath.c_str());
LOG_E(TAG, "FS lock timed out, skipping open: %s", a->filePath.c_str()); file_mutex_lock(&mutex);
tt_lock_free(lock);
lv_async_call(asyncOpenComplete, a);
vTaskDelete(nullptr);
return;
}
if (isTextFile(a->filePath)) { if (isTextFile(a->filePath)) {
// Read the entire text file here (under the lock) so asyncOpenComplete // Read the entire text file here (under the lock) so asyncOpenComplete
@@ -146,8 +141,7 @@ void EpubReader::backgroundOpenTask(void* data) {
a->epub = EpubService::open(a->filePath); a->epub = EpubService::open(a->filePath);
} }
tt_lock_release(lock); file_mutex_unlock(&mutex);
tt_lock_free(lock);
// Signal the LVGL task that the work is done // Signal the LVGL task that the work is done
lv_async_call(asyncOpenComplete, a); lv_async_call(asyncOpenComplete, a);
+8 -8
View File
@@ -1,5 +1,5 @@
#include "EpubReader.h" #include "EpubReader.h"
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
#include <tactility/log.h> #include <tactility/log.h>
#include <esp_heap_caps.h> #include <esp_heap_caps.h>
#include <dirent.h> #include <dirent.h>
@@ -37,20 +37,20 @@ static void setListBtnLongMode(lv_obj_t* btn, lv_label_long_mode_t mode) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void EpubReader::setReaderToolbarButtons() { void EpubReader::setReaderToolbarButtons() {
tt_lvgl_toolbar_clear_actions(toolbar_); lvgl_toolbar_clear_actions(toolbar_);
tt_lvgl_toolbar_add_text_button_action(toolbar_, LV_SYMBOL_PREV, onPrevPressed, this); lvgl_toolbar_add_text_button_action(toolbar_, LV_SYMBOL_PREV, onPrevPressed, this);
if (!textMode_) { if (!textMode_) {
tt_lvgl_toolbar_add_text_button_action(toolbar_, LV_SYMBOL_LIST, onTocPressed, this); lvgl_toolbar_add_text_button_action(toolbar_, LV_SYMBOL_LIST, onTocPressed, this);
} }
tt_lvgl_toolbar_add_text_button_action(toolbar_, LV_SYMBOL_NEXT, onNextPressed, this); lvgl_toolbar_add_text_button_action(toolbar_, LV_SYMBOL_NEXT, onNextPressed, this);
tt_lvgl_toolbar_add_text_button_action(toolbar_, LV_SYMBOL_DIRECTORY, onBrowsePressed, this); lvgl_toolbar_add_text_button_action(toolbar_, LV_SYMBOL_DIRECTORY, onBrowsePressed, this);
} }
void EpubReader::setBrowserToolbarButtons() { void EpubReader::setBrowserToolbarButtons() {
tt_lvgl_toolbar_clear_actions(toolbar_); lvgl_toolbar_clear_actions(toolbar_);
// Show "Use Folder" button when the current browse path isn't already the saved books folder // Show "Use Folder" button when the current browse path isn't already the saved books folder
if (browsePath_ != booksPath_) { if (browsePath_ != booksPath_) {
tt_lvgl_toolbar_add_text_button_action(toolbar_, LV_SYMBOL_DIRECTORY, onSetBooksFolder, this); lvgl_toolbar_add_text_button_action(toolbar_, LV_SYMBOL_DIRECTORY, onSetBooksFolder, this);
} }
} }
+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.epubreader app.id=one.tactility.epubreader
app.version.name=0.4.0 app.version.name=0.5.0
app.version.code=4 app.version.code=5
app.name=Epub Reader app.name=Epub Reader
app.description=Epub and text file reader. Requires PSRAM! app.description=Epub and text file reader. Requires PSRAM!
@@ -8,9 +8,8 @@
#include <tt_app.h> #include <tt_app.h>
#include <tt_app_fileselection.h> #include <tt_app_fileselection.h>
#include <tt_bundle.h> #include <tt_bundle.h>
#include <tt_lock.h> #include <lvgl/lvgl.h>
#include <tt_lvgl.h> #include <lvgl/widgets/toolbar.h>
#include <tt_lvgl_toolbar.h>
#include <esp_app_desc.h> #include <esp_app_desc.h>
#include <esp_app_format.h> #include <esp_app_format.h>
@@ -18,6 +17,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 +284,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 +311,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) {
@@ -654,7 +655,7 @@ void EspNowBridge::onShow(AppHandle app, lv_obj_t* parent) {
lv_obj_remove_flag(parent, LV_OBJ_FLAG_SCROLLABLE); lv_obj_remove_flag(parent, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
lv_obj_t* toolbar = tt_lvgl_toolbar_create_for_app(parent, app); lv_obj_t* toolbar = lvgl_toolbar_create(parent, "ESP-NOW Bridge");
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
auto* wrapper = lv_obj_create(parent); auto* wrapper = lv_obj_create(parent);
+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.3.0
app.version.code=1 app.version.code=3
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.
+5 -6
View File
@@ -2,10 +2,9 @@
#include <Tactility/kernel/Kernel.h> #include <Tactility/kernel/Kernel.h>
#include <tt_lvgl.h> #include <lvgl/widgets/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) {
@@ -79,7 +78,7 @@ void Gpio::onShow(AppHandle app, lv_obj_t* parent) {
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
auto* toolbar = tt_lvgl_toolbar_create_for_app(parent, app); auto* toolbar = lvgl_toolbar_create(parent, "GPIO");
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
// Main content wrapper, enables scrolling content without scrolling the toolbar // Main content wrapper, enables scrolling content without scrolling the toolbar
+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.9.0
app.version.code=7 app.version.code=9
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);
} }
} }
+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.graphicsdemo app.id=one.tactility.graphicsdemo
app.version.name=0.6.0 app.version.name=0.7.0
app.version.code=6 app.version.code=7
app.name=Graphics Demo app.name=Graphics Demo
+2 -2
View File
@@ -1,12 +1,12 @@
#include <tt_app.h> #include <tt_app.h>
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
/** /**
* Note: LVGL and Tactility methods need to be exposed manually from TactilityC/Source/tt_init.cpp * Note: LVGL and Tactility methods need to be exposed manually from TactilityC/Source/tt_init.cpp
* Only C is supported for now (C++ symbols fail to link) * Only C is supported for now (C++ symbols fail to link)
*/ */
static void onShowApp(AppHandle app, void* data, lv_obj_t* parent) { static void onShowApp(AppHandle app, void* data, lv_obj_t* parent) {
lv_obj_t* toolbar = tt_lvgl_toolbar_create_for_app(parent, app); lv_obj_t* toolbar = lvgl_toolbar_create(parent, "Hello World");
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
lv_obj_t* label = lv_label_create(parent); lv_obj_t* label = lv_label_create(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.helloworld app.id=one.tactility.helloworld
app.version.name=0.6.0 app.version.name=0.7.0
app.version.code=6 app.version.code=7
app.name=Hello World app.name=Hello World
@@ -14,7 +14,6 @@
#include "TestUnitLcdGfx.h" #include "TestUnitLcdGfx.h"
#include <tactility/device.h> #include <tactility/device.h>
#include <tt_lvgl_toolbar.h>
#include <esp_log.h> #include <esp_log.h>
constexpr auto* TAG = "M5UnitTest"; constexpr auto* TAG = "M5UnitTest";
+3 -3
View File
@@ -1,13 +1,13 @@
#include "TestListView.h" #include "TestListView.h"
#include "M5UnitTest.h" #include "M5UnitTest.h"
#include "UiScale.h" #include "UiScale.h"
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
#include <tactility/lvgl_fonts.h> #include <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;
tt_lvgl_toolbar_create_for_app(parent, handle); lvgl_toolbar_create(parent, "M5 Unit Test");
list_ = lv_list_create(parent); list_ = lv_list_create(parent);
lv_obj_set_width(list_, LV_PCT(100)); lv_obj_set_width(list_, LV_PCT(100));
+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/icons/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/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/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/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/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/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/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/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/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/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,8 +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/fonts.h>
#include <tt_lvgl_toolbar.h>
#include <algorithm> #include <algorithm>
#include <cstdio> #include <cstdio>
#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/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;
+4 -5
View File
@@ -1,13 +1,12 @@
#include "TestViewBase.h" #include "TestViewBase.h"
#include "M5UnitTest.h" #include "M5UnitTest.h"
#include "UiScale.h" #include "UiScale.h"
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
#include <tactility/lvgl_fonts.h> #include <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 = lvgl_toolbar_create(parent, title);
tt_lvgl_toolbar_set_title(toolbar, title); lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_LEFT, onBackClicked, this);
tt_lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_LEFT, onBackClicked, this);
return toolbar; return toolbar;
} }
+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/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
+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=esp32s3,esp32p4 target.platforms=esp32s3,esp32p4
app.id=one.tactility.m5unittest app.id=one.tactility.m5unittest
app.version.name=0.4.0 app.version.name=0.5.0
app.version.code=4 app.version.code=5
app.name=M5 Unit Test app.name=M5 Unit Test
+7 -6
View File
@@ -1,6 +1,7 @@
#include "Magic8Ball.h" #include "Magic8Ball.h"
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
#include <tt_lvgl_keyboard.h> #include <tactility/device.h>
#include <tactility/drivers/keyboard.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
@@ -35,7 +36,7 @@ static const char* responses[] = {
#define NUM_RESPONSES (sizeof(responses) / sizeof(responses[0])) #define NUM_RESPONSES (sizeof(responses) / sizeof(responses[0]))
static const char* getInputHint() { static const char* getInputHint() {
if (tt_lvgl_hardware_keyboard_is_available()) { if (device_has_active_by_type(&KEYBOARD_TYPE)) {
return "Touch or Space to ask Q to exit"; return "Touch or Space to ask Q to exit";
} }
return "Touch the ball to ask"; return "Touch the ball to ask";
@@ -92,7 +93,7 @@ void Magic8Ball::onShow(AppHandle app, lv_obj_t* parent) {
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
/* Toolbar */ /* Toolbar */
lv_obj_t* toolbar = tt_lvgl_toolbar_create_for_app(parent, app); lv_obj_t* toolbar = lvgl_toolbar_create(parent, "Magic 8-Ball");
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
/* Main container */ /* Main container */
@@ -141,7 +142,7 @@ void Magic8Ball::onShow(AppHandle app, lv_obj_t* parent) {
lv_obj_add_event_cb(ballObj, onBallClick, LV_EVENT_CLICKED, this); lv_obj_add_event_cb(ballObj, onBallClick, LV_EVENT_CLICKED, this);
/* Keyboard support - no editing mode needed, just focus the ball */ /* Keyboard support - no editing mode needed, just focus the ball */
if (tt_lvgl_hardware_keyboard_is_available()) { if (device_has_active_by_type(&KEYBOARD_TYPE)) {
lv_group_t* grp = lv_group_get_default(); lv_group_t* grp = lv_group_get_default();
if (grp) { if (grp) {
lv_group_add_obj(grp, ballObj); lv_group_add_obj(grp, ballObj);
@@ -152,7 +153,7 @@ void Magic8Ball::onShow(AppHandle app, lv_obj_t* parent) {
} }
void Magic8Ball::onHide(AppHandle app) { void Magic8Ball::onHide(AppHandle app) {
if (tt_lvgl_hardware_keyboard_is_available() && ballObj) { if (device_has_active_by_type(&KEYBOARD_TYPE) && ballObj) {
lv_group_remove_obj(ballObj); lv_group_remove_obj(ballObj);
} }
answerLabel = nullptr; answerLabel = nullptr;
+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.magic8ball app.id=one.tactility.magic8ball
app.version.name=0.5.0 app.version.name=0.6.0
app.version.code=5 app.version.code=6
app.name=Magic 8-Ball app.name=Magic 8-Ball
+14 -14
View File
@@ -4,9 +4,9 @@
#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/fonts.h>
#include <tt_lvgl.h> #include <lvgl/lvgl.h>
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/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 (device_has_active_by_type(&KEYBOARD_TYPE)) 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) {
@@ -208,7 +208,7 @@ void MediaKeys::startHid() {
} }
if (_mainWrapper) lv_obj_remove_flag(_mainWrapper, LV_OBJ_FLAG_HIDDEN); if (_mainWrapper) lv_obj_remove_flag(_mainWrapper, LV_OBJ_FLAG_HIDDEN);
if (tt_lvgl_hardware_keyboard_is_available()) enterKeyMode(); if (device_has_active_by_type(&KEYBOARD_TYPE)) enterKeyMode();
} }
void MediaKeys::teardownBt() { void MediaKeys::teardownBt() {
@@ -276,7 +276,7 @@ void MediaKeys::handleSwitchToggle(bool enabled) {
} }
} else { } else {
_radioEnabling = false; _radioEnabling = false;
if (tt_lvgl_hardware_keyboard_is_available()) exitKeyMode(); if (device_has_active_by_type(&KEYBOARD_TYPE)) exitKeyMode();
// Explicit user toggle-off: stop HID cleanly (safe here since we're on the // Explicit user toggle-off: stop HID cleanly (safe here since we're on the
// LVGL task and the user intentionally disabled, so no race with app teardown). // LVGL task and the user intentionally disabled, so no race with app teardown).
if (_hidDevice) bluetooth_hid_device_stop(_hidDevice); if (_hidDevice) bluetooth_hid_device_stop(_hidDevice);
@@ -307,10 +307,10 @@ void MediaKeys::onShow(AppHandle appHandle, lv_obj_t* parent) {
lv_obj_remove_flag(parent, LV_OBJ_FLAG_SCROLLABLE); lv_obj_remove_flag(parent, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
lv_obj_t* toolbar = tt_lvgl_toolbar_create_for_app(parent, appHandle); lv_obj_t* toolbar = lvgl_toolbar_create(parent, "Media Keys");
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
_switchWidget = tt_lvgl_toolbar_add_switch_action(toolbar); _switchWidget = lvgl_toolbar_add_switch_action(toolbar);
lv_obj_add_event_cb(_switchWidget, onSwitchToggled, LV_EVENT_VALUE_CHANGED, this); lv_obj_add_event_cb(_switchWidget, onSwitchToggled, LV_EVENT_VALUE_CHANGED, this);
_mainWrapper = lv_obj_create(parent); _mainWrapper = lv_obj_create(parent);
@@ -342,7 +342,7 @@ void MediaKeys::onShow(AppHandle appHandle, lv_obj_t* parent) {
lv_obj_add_event_cb(_buttonMatrix, onButtonPressed, LV_EVENT_VALUE_CHANGED, this); lv_obj_add_event_cb(_buttonMatrix, onButtonPressed, LV_EVENT_VALUE_CHANGED, this);
// Physical keyboard support: key events on the matrix (entered when BT enabled, Q/Esc exits) // Physical keyboard support: key events on the matrix (entered when BT enabled, Q/Esc exits)
if (tt_lvgl_hardware_keyboard_is_available()) { if (device_has_active_by_type(&KEYBOARD_TYPE)) {
lv_obj_add_event_cb(_buttonMatrix, onKeyEvent, LV_EVENT_KEY, this); lv_obj_add_event_cb(_buttonMatrix, onKeyEvent, LV_EVENT_KEY, this);
_keyHighlightTimer = lv_timer_create(onKeyHighlightTimer, 150, this); _keyHighlightTimer = lv_timer_create(onKeyHighlightTimer, 150, this);
lv_timer_pause(_keyHighlightTimer); lv_timer_pause(_keyHighlightTimer);
@@ -364,7 +364,7 @@ void MediaKeys::onShow(AppHandle appHandle, lv_obj_t* parent) {
void MediaKeys::onHide(AppHandle /*appHandle*/) { void MediaKeys::onHide(AppHandle /*appHandle*/) {
_radioEnabling = false; _radioEnabling = false;
_isEnabled = false; _isEnabled = false;
if (tt_lvgl_hardware_keyboard_is_available()) exitKeyMode(); if (device_has_active_by_type(&KEYBOARD_TYPE)) exitKeyMode();
teardownBt(); teardownBt();
if (_keyHighlightTimer) { if (_keyHighlightTimer) {
lv_timer_delete(_keyHighlightTimer); lv_timer_delete(_keyHighlightTimer);
+1 -1
View File
@@ -5,8 +5,8 @@
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/drivers/bluetooth.h> #include <tactility/drivers/bluetooth.h>
#include <tactility/drivers/bluetooth_hid_device.h> #include <tactility/drivers/bluetooth_hid_device.h>
#include <tactility/drivers/keyboard.h>
#include <tt_app.h> #include <tt_app.h>
#include <tt_lvgl_keyboard.h>
#include <atomic> #include <atomic>
class MediaKeys final : public App { class MediaKeys final : public App {
+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.6.0
app.version.code=4 app.version.code=6
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.8.0
app.version.code=6 app.version.code=8
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>
@@ -1,5 +1,5 @@
#include "SerialConsole.h" #include "SerialConsole.h"
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
constexpr auto* TAG = "SerialMonitor"; constexpr auto* TAG = "SerialMonitor";
@@ -43,9 +43,9 @@ void SerialConsole::onShow(AppHandle appHandle, lv_obj_t* parent) {
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
auto* toolbar = tt_lvgl_toolbar_create_for_app(parent, appHandle); auto* toolbar = lvgl_toolbar_create(parent, "Serial Console");
disconnectButton = tt_lvgl_toolbar_add_image_button_action(toolbar, LV_SYMBOL_POWER, onDisconnectPressed, this); disconnectButton = lvgl_toolbar_add_image_button_action(toolbar, LV_SYMBOL_POWER, onDisconnectPressed, this);
lv_obj_add_flag(disconnectButton, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(disconnectButton, LV_OBJ_FLAG_HIDDEN);
wrapperWidget = lv_obj_create(parent); wrapperWidget = lv_obj_create(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.serialconsole app.id=one.tactility.serialconsole
app.version.name=0.7.0 app.version.name=0.9.0
app.version.code=7 app.version.code=9
app.name=Serial Console app.name=Serial Console
+4 -4
View File
@@ -5,15 +5,15 @@
#include "Snake.h" #include "Snake.h"
#include <inttypes.h> #include <inttypes.h>
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
#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 <TactilityCpp/LvglLock.h> #include <TactilityCpp/LvglLock.h>
#include <tactility/lvgl_module.h> #include <lvgl/lvgl.h>
#include <tactility/lvgl_fonts.h> #include <lvgl/fonts.h>
constexpr auto* TAG = "Snake"; constexpr auto* TAG = "Snake";
@@ -245,7 +245,7 @@ void Snake::onShow(AppHandle appHandle, lv_obj_t* parent) {
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
// Create toolbar // Create toolbar
toolbar = tt_lvgl_toolbar_create_for_app(parent, appHandle); toolbar = lvgl_toolbar_create(parent, "Snake");
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
// Create main wrapper // Create main wrapper
+4 -3
View File
@@ -7,7 +7,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <tt_lvgl_keyboard.h> #include <tactility/device.h>
#include <tactility/drivers/keyboard.h>
// Forward declarations // Forward declarations
static void game_play_event(lv_event_t* e); static void game_play_event(lv_event_t* e);
@@ -36,7 +37,7 @@ static void delete_event(lv_event_t* e) {
} }
// Restore edit mode and remove from group before cleanup // Restore edit mode and remove from group before cleanup
if (tt_lvgl_hardware_keyboard_is_available()) { if (device_has_active_by_type(&KEYBOARD_TYPE)) {
lv_group_t* group = lv_group_get_default(); lv_group_t* group = lv_group_get_default();
if (group) lv_group_set_editing(group, false); if (group) lv_group_set_editing(group, false);
lv_group_remove_obj(game->container); lv_group_remove_obj(game->container);
@@ -397,7 +398,7 @@ lv_obj_t* snake_create(lv_obj_t* parent, uint16_t cell_size, bool wall_collision
lv_obj_add_event_cb(obj, delete_event, LV_EVENT_DELETE, NULL); lv_obj_add_event_cb(obj, delete_event, LV_EVENT_DELETE, NULL);
// Set up keyboard focus if available // Set up keyboard focus if available
if (tt_lvgl_hardware_keyboard_is_available()) { if (device_has_active_by_type(&KEYBOARD_TYPE)) {
lv_group_t* group = lv_group_get_default(); lv_group_t* group = lv_group_get_default();
if (group) { if (group) {
lv_group_add_obj(group, game->container); lv_group_add_obj(group, game->container);
+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.10.0
app.version.code=8 app.version.code=10
app.name=Snake app.name=Snake
app.description=Classic Snake game app.description=Classic Snake game
+5 -5
View File
@@ -5,7 +5,7 @@
#include "TamaTac.h" #include "TamaTac.h"
#include "SpriteData.h" #include "SpriteData.h"
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
#include <tt_app_alertdialog.h> #include <tt_app_alertdialog.h>
#include <Tactility/kernel/Kernel.h> #include <Tactility/kernel/Kernel.h>
#include <freertos/FreeRTOS.h> #include <freertos/FreeRTOS.h>
@@ -86,11 +86,11 @@ void TamaTac::onShow(AppHandle context, lv_obj_t* parent) {
lv_obj_set_style_pad_all(parent, 0, 0); lv_obj_set_style_pad_all(parent, 0, 0);
lv_obj_set_style_pad_row(parent, 0, 0); lv_obj_set_style_pad_row(parent, 0, 0);
toolbar = tt_lvgl_toolbar_create_for_app(parent, context); toolbar = lvgl_toolbar_create(parent, "TamaTac");
menuButton = tt_lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_LIST, onMenuClicked, this); menuButton = lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_LIST, onMenuClicked, this);
tt_lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_TRASH, onCleanClicked, this); lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_TRASH, onCleanClicked, this);
tt_lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_REFRESH, onResetClicked, this); lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_REFRESH, onResetClicked, this);
wrapperWidget = lv_obj_create(parent); wrapperWidget = lv_obj_create(parent);
lv_obj_set_width(wrapperWidget, LV_PCT(100)); lv_obj_set_width(wrapperWidget, LV_PCT(100));
+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.tamatac app.id=one.tactility.tamatac
app.version.name=0.4.0 app.version.name=0.5.0
app.version.code=4 app.version.code=5
app.name=TamaTac app.name=TamaTac
app.description=Virtual pet inspired by Tamagotchi. Only runs on devices with PSRAM. app.description=Virtual pet inspired by Tamagotchi. Only runs on devices with PSRAM.
+35 -40
View File
@@ -1,11 +1,10 @@
#include "TodoList.h" #include "TodoList.h"
#include <tt_app.h> #include <tt_app.h>
#include <tt_lock.h> #include <tactility/filesystem/file_mutex.h>
#include <Tactility/kernel/Kernel.h> #include <Tactility/kernel/Kernel.h>
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
#include <tt_lvgl_keyboard.h> #include <lvgl/lvgl.h>
#include <tactility/lvgl_module.h> #include <lvgl/fonts.h>
#include <tactility/lvgl_fonts.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -60,52 +59,48 @@ void TodoList::saveTodos() {
char savePath[256]; char savePath[256];
if (!getSaveFilePath(savePath, sizeof(savePath))) return; if (!getSaveFilePath(savePath, sizeof(savePath))) return;
auto lock = tt_lock_alloc_for_path(savePath); struct FileMutex mutex;
if (!lock) return; file_mutex_get(&mutex, savePath);
if (tt_lock_acquire(lock, tt::kernel::MAX_TICKS)) { file_mutex_lock(&mutex);
FILE* f = fopen(savePath, "w"); FILE* f = fopen(savePath, "w");
if (f) { if (f) {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
fprintf(f, "%c %s\n", items[i].done ? '+' : '-', items[i].text); fprintf(f, "%c %s\n", items[i].done ? '+' : '-', items[i].text);
}
fclose(f);
} }
tt_lock_release(lock); fclose(f);
} }
tt_lock_free(lock); file_mutex_unlock(&mutex);
} }
void TodoList::loadTodos() { void TodoList::loadTodos() {
char savePath[256]; char savePath[256];
if (!getSaveFilePath(savePath, sizeof(savePath))) return; if (!getSaveFilePath(savePath, sizeof(savePath))) return;
auto lock = tt_lock_alloc_for_path(savePath); struct FileMutex mutex;
if (!lock) return; file_mutex_get(&mutex, savePath);
if (tt_lock_acquire(lock, tt::kernel::MAX_TICKS)) { file_mutex_lock(&mutex);
count = 0; count = 0;
FILE* f = fopen(savePath, "r"); FILE* f = fopen(savePath, "r");
if (f) { if (f) {
char line[MAX_TEXT_LEN + 4]; char line[MAX_TEXT_LEN + 4];
while (count < MAX_TODOS && fgets(line, sizeof(line), f)) { while (count < MAX_TODOS && fgets(line, sizeof(line), f)) {
size_t len = strlen(line); size_t len = strlen(line);
while (len > 0 && (line[len - 1] == '\n' || line[len - 1] == '\r')) { while (len > 0 && (line[len - 1] == '\n' || line[len - 1] == '\r')) {
line[--len] = '\0'; line[--len] = '\0';
}
if (len < 3 || line[1] != ' ') continue;
TodoItem* item = &items[count];
item->done = (line[0] == '+');
strncpy(item->text, &line[2], MAX_TEXT_LEN - 1);
item->text[MAX_TEXT_LEN - 1] = '\0';
count++;
} }
fclose(f);
if (len < 3 || line[1] != ' ') continue;
TodoItem* item = &items[count];
item->done = (line[0] == '+');
strncpy(item->text, &line[2], MAX_TEXT_LEN - 1);
item->text[MAX_TEXT_LEN - 1] = '\0';
count++;
} }
tt_lock_release(lock); fclose(f);
} }
tt_lock_free(lock); file_mutex_unlock(&mutex);
} }
/* ── UI Helpers ───────────────────────────────────────────────────── */ /* ── UI Helpers ───────────────────────────────────────────────────── */
@@ -277,7 +272,7 @@ void TodoList::onShow(AppHandle app, lv_obj_t* parent) {
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
/* Toolbar */ /* Toolbar */
lv_obj_t* toolbar = tt_lvgl_toolbar_create_for_app(parent, app); lv_obj_t* toolbar = lvgl_toolbar_create(parent, "Todo List");
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
lv_obj_t* countWrapper = lv_obj_create(toolbar); lv_obj_t* countWrapper = lv_obj_create(toolbar);
+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.7.0
app.version.code=5 app.version.code=7
app.name=Todo List app.name=Todo List
app.description=Simple task list manager app.description=Simple task list manager
+4 -4
View File
@@ -5,12 +5,12 @@
#include "TwoEleven.h" #include "TwoEleven.h"
#include <inttypes.h> #include <inttypes.h>
#include <tt_lvgl_toolbar.h> #include <lvgl/widgets/toolbar.h>
#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/fonts.h>
#include <TactilityCpp/LvglLock.h> #include <TactilityCpp/LvglLock.h>
constexpr auto* TAG = "TwoEleven"; constexpr auto* TAG = "TwoEleven";
@@ -257,7 +257,7 @@ void TwoEleven::onShow(AppHandle appHandle, lv_obj_t* parent) {
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
// Create toolbar // Create toolbar
toolbar = tt_lvgl_toolbar_create_for_app(parent, appHandle); toolbar = lvgl_toolbar_create(parent, "2048");
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
// Create main wrapper // Create main wrapper
+4 -3
View File
@@ -3,7 +3,8 @@
#include "TwoElevenHelpers.h" #include "TwoElevenHelpers.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <tt_lvgl_keyboard.h> #include <tactility/device.h>
#include <tactility/drivers/keyboard.h>
static void game_play_event(lv_event_t * e); static void game_play_event(lv_event_t * e);
static void btnm_event_cb(lv_event_t * e); static void btnm_event_cb(lv_event_t * e);
@@ -18,7 +19,7 @@ static void delete_event(lv_event_t * e)
twoeleven_t * game_2048 = (twoeleven_t *)lv_obj_get_user_data(obj); twoeleven_t * game_2048 = (twoeleven_t *)lv_obj_get_user_data(obj);
if (game_2048) { if (game_2048) {
// Restore edit mode and remove from group before cleanup // Restore edit mode and remove from group before cleanup
if (tt_lvgl_hardware_keyboard_is_available()) { if (device_has_active_by_type(&KEYBOARD_TYPE)) {
lv_group_t* group = lv_group_get_default(); lv_group_t* group = lv_group_get_default();
if (group) lv_group_set_editing(group, false); if (group) lv_group_set_editing(group, false);
lv_group_remove_obj(game_2048->btnm); lv_group_remove_obj(game_2048->btnm);
@@ -140,7 +141,7 @@ lv_obj_t * twoeleven_create(lv_obj_t * parent, uint16_t matrix_size)
lv_obj_add_event_cb(game_2048->btnm, btnm_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL); lv_obj_add_event_cb(game_2048->btnm, btnm_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_event_cb(obj, delete_event, LV_EVENT_DELETE, NULL); lv_obj_add_event_cb(obj, delete_event, LV_EVENT_DELETE, NULL);
if (tt_lvgl_hardware_keyboard_is_available()) { if (device_has_active_by_type(&KEYBOARD_TYPE)) {
lv_group_t* group = lv_group_get_default(); lv_group_t* group = lv_group_get_default();
if (group) { if (group) {
lv_group_add_obj(group, game_2048->btnm); lv_group_add_obj(group, game_2048->btnm);
+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.9.0
app.version.code=7 app.version.code=9
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();
} }
}; };