Tactility.py 3.0.0 and SDK updates for 0.7.0-dev (#19)

- Remove `Libraries/Str`
- Replaced usage of `TactilityC` FreeRtos features with `TactilityFreeRtos` library
- Update `tactility.py`
- Removed redundant code from `TactilityCpp`
This commit is contained in:
Ken Van Hoeylandt
2026-01-04 02:20:06 +01:00
committed by GitHub
parent 3bc1e7a373
commit b6c27b64d4
41 changed files with 521 additions and 1329 deletions
-4
View File
@@ -1,15 +1,11 @@
file(GLOB_RECURSE SOURCE_FILES
Source/*.c*
# Library source files must be included directly,
# because all regular dependencies get stripped by elf_loader's cmake script
../../../Libraries/Str/Source/*.c**
)
idf_component_register(
SRCS ${SOURCE_FILES}
# Library headers must be included directly,
# because all regular dependencies get stripped by elf_loader's cmake script
INCLUDE_DIRS ../../../Libraries/Str/Include
INCLUDE_DIRS ../../../Libraries/TactilityCpp/Include
REQUIRES TactilitySDK
)
+22 -19
View File
@@ -8,6 +8,8 @@
#include <esp_random.h>
#include <esp_log.h>
#include <Tactility/kernel/Kernel.h>
constexpr char* TAG = "Diceware";
static void skipNewlines(FILE* file, const int count) {
@@ -20,15 +22,15 @@ static void skipNewlines(FILE* file, const int count) {
}
}
static Str readWord(FILE* file) {
static std::string readWord(FILE* file) {
char c;
Str result;
std::string result;
// Read word until newline
while (fread(&c, 1, 1, file) && c != '\n') { result.append(c); }
while (fread(&c, 1, 1, file) && c != '\n') { result += c; }
return result;
}
static Str readWordAtLine(const AppHandle handle, const int lineIndex) {
static std::string readWordAtLine(const AppHandle handle, const int lineIndex) {
char path[256];
size_t size = 256;
tt_app_get_assets_child_path(handle, "eff_large_wordlist.txt", path, &size);
@@ -38,8 +40,8 @@ static Str readWordAtLine(const AppHandle handle, const int lineIndex) {
}
auto lock = tt_lock_alloc_for_path(path);
Str word;
if (tt_lock_acquire(lock, TT_MAX_TICKS)) {
std::string word;
if (tt_lock_acquire(lock, tt::kernel::MAX_TICKS)) {
FILE* file = fopen(path, "r");
if (file != nullptr) {
skipNewlines(file, lineIndex);
@@ -52,25 +54,24 @@ static Str readWordAtLine(const AppHandle handle, const int lineIndex) {
return word;
}
int32_t Diceware::jobMain(void* data) {
Diceware* application = static_cast<Diceware*>(data);
Str result;
for (int i = 0; i < application->wordCount; i++) {
int32_t Diceware::jobMain() {
std::string result;
for (int i = 0; i < wordCount; i++) {
constexpr int line_count = 7776;
const auto line_index = esp_random() % line_count;
auto word = readWordAtLine(application->handle, line_index);
result.appendf("%s ", word.c_str());
auto word = readWordAtLine(handle, line_index);
result += word;
result += " ";
}
application->onFinishJob(result);
onFinishJob(result);
return 0;
}
void Diceware::cleanupJob() {
if (jobThread != nullptr) {
tt_thread_join(jobThread, TT_MAX_TICKS);
tt_thread_free(jobThread);
jobThread->join();
jobThread = nullptr;
}
}
@@ -79,12 +80,14 @@ void Diceware::startJob(uint32_t jobWordCount) {
cleanupJob();
wordCount = jobWordCount;
jobThread = tt_thread_alloc_ext("Diceware", 4096, jobMain, this);
tt_thread_start(jobThread);
jobThread = std::make_unique<tt::Thread>("Diceware", 4096, [this] {
return jobMain();
});
jobThread->start();
}
void Diceware::onFinishJob(Str result) {
tt_lvgl_lock(TT_MAX_TICKS);
void Diceware::onFinishJob(std::string result) {
tt_lvgl_lock(tt::kernel::MAX_TICKS);
lv_label_set_text(resultLabel, result.c_str());
tt_lvgl_unlock();
}
+8 -5
View File
@@ -1,18 +1,21 @@
#pragma once
#include "tt_app.h"
#include "tt_thread.h"
#include <Str.h>
#include <Tactility/Thread.h>
#include <string>
#include <lvgl.h>
#include <TactilityCpp/App.h>
#include <memory>
class Diceware final : public App {
AppHandle handle = nullptr;
lv_obj_t* spinbox = nullptr;
lv_obj_t* resultLabel = nullptr;
ThreadHandle jobThread = nullptr;
std::unique_ptr<tt::Thread> jobThread = nullptr;
uint32_t wordCount = 5;
static void onClickGenerate(lv_event_t* e);
@@ -20,10 +23,10 @@ class Diceware final : public App {
static void onSpinboxIncrement(lv_event_t* e);
static void onHelpClicked(lv_event_t* e);
static int32_t jobMain(void* data);
int32_t jobMain();
void startJob(uint32_t jobWordCount);
void onFinishJob(Str result);
void onFinishJob(std::string result);
void cleanupJob();
public: