From 57f7052a269aecf1cb9cc3b708f149b3f3f7623a Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 4 Jan 2026 00:27:44 +0100 Subject: [PATCH 01/11] Update tactility.py and apps for new SDK --- Apps/Calculator/manifest.properties | 8 +- Apps/Calculator/tactility.py | 97 ++++++++++--------- Apps/Diceware/CMakeLists.txt | 1 - Apps/Diceware/main/Source/Diceware.cpp | 18 ++-- Apps/Diceware/main/Source/Diceware.h | 9 +- Apps/Diceware/manifest.properties | 8 +- Apps/Diceware/tactility.py | 97 ++++++++++--------- Apps/GPIO/main/Source/Gpio.cpp | 26 ++--- Apps/GPIO/main/Source/Gpio.h | 12 ++- Apps/GPIO/manifest.properties | 8 +- Apps/GPIO/tactility.py | 97 ++++++++++--------- .../main/Include/drivers/DisplayDriver.h | 3 +- Apps/GraphicsDemo/main/Source/Application.cpp | 4 +- Apps/GraphicsDemo/manifest.properties | 8 +- Apps/GraphicsDemo/tactility.py | 97 ++++++++++--------- Apps/HelloWorld/manifest.properties | 8 +- Apps/HelloWorld/tactility.py | 87 ++++++++--------- Apps/SerialConsole/main/Source/ConsoleView.h | 57 ++++------- Apps/SerialConsole/manifest.properties | 8 +- Apps/SerialConsole/tactility.py | 97 ++++++++++--------- Apps/TwoEleven/main/Source/TwoElevenUi.c | 4 +- Apps/TwoEleven/manifest.properties | 10 +- Apps/TwoEleven/tactility.py | 97 ++++++++++--------- .../TactilityCpp/Include/TactilityCpp/Lock.h | 51 ---------- .../Include/TactilityCpp/LvglLock.h | 12 +-- .../TactilityCpp/Include/TactilityCpp/Mutex.h | 27 ------ .../Include/TactilityCpp/Thread.h | 65 ------------- .../TactilityCpp/Include/TactilityCpp/Uart.h | 7 +- Libraries/TactilityCpp/Source/Lock.cpp | 6 -- 29 files changed, 438 insertions(+), 591 deletions(-) delete mode 100644 Libraries/TactilityCpp/Include/TactilityCpp/Lock.h delete mode 100644 Libraries/TactilityCpp/Include/TactilityCpp/Mutex.h delete mode 100644 Libraries/TactilityCpp/Include/TactilityCpp/Thread.h delete mode 100644 Libraries/TactilityCpp/Source/Lock.cpp diff --git a/Apps/Calculator/manifest.properties b/Apps/Calculator/manifest.properties index 993d5f5..00d51ae 100644 --- a/Apps/Calculator/manifest.properties +++ b/Apps/Calculator/manifest.properties @@ -1,10 +1,10 @@ [manifest] version=0.1 [target] -sdk=0.6.0 -platforms=esp32,esp32s3 +sdk=0.7.0-dev +platforms=esp32,esp32s3,esp32c6,esp32p4 [app] id=one.tactility.calculator -versionName=0.2.0 -versionCode=2 +versionName=0.3.0 +versionCode=3 name=Calculator diff --git a/Apps/Calculator/tactility.py b/Apps/Calculator/tactility.py index 5d5581e..d4e0959 100644 --- a/Apps/Calculator/tactility.py +++ b/Apps/Calculator/tactility.py @@ -8,11 +8,12 @@ import time import urllib.request import zipfile +from dataclasses import dataclass import requests import tarfile ttbuild_path = ".tactility" -ttbuild_version = "2.5.0" +ttbuild_version = "3.0.0" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -20,20 +21,12 @@ use_local_sdk = False local_base_path = None -if sys.platform == "win32": - shell_color_red = "\033[91m" - shell_color_orange = "\033[93m" - shell_color_green = "\033[32m" - shell_color_purple = "\033[35m" - shell_color_cyan = "\033[36m" - shell_color_reset = "\033[m" -else: - shell_color_red = "\033[91m" - shell_color_orange = "\033[93m" - shell_color_green = "\033[32m" - shell_color_purple = "\033[35m" - shell_color_cyan = "\033[36m" - shell_color_reset = "\033[m" +shell_color_red = "\033[91m" +shell_color_orange = "\033[93m" +shell_color_green = "\033[32m" +shell_color_purple = "\033[35m" +shell_color_cyan = "\033[36m" +shell_color_reset = "\033[m" def print_help(): print("Usage: python tactility.py [action] [options]") @@ -115,7 +108,7 @@ def read_properties_file(path): #region SDK helpers def read_sdk_json(): - json_file_path = os.path.join(ttbuild_path, "sdk.json") + json_file_path = os.path.join(ttbuild_path, "tool.json") json_file = open(json_file_path) return json.load(json_file) @@ -148,17 +141,17 @@ def get_sdk_root_dir(version, platform): global ttbuild_cdn return os.path.join(ttbuild_path, f"{version}-{platform}") -def get_sdk_url(version, platform): +def get_sdk_url(version, file): global ttbuild_cdn - return f"{ttbuild_cdn}/TactilitySDK-{version}-{platform}.zip" + return f"{ttbuild_cdn}/sdk/{version}/{file}" def sdk_exists(version, platform): sdk_dir = get_sdk_dir(version, platform) return os.path.isdir(sdk_dir) -def should_update_sdk_json(): +def should_update_tool_json(): global ttbuild_cdn - json_filepath = os.path.join(ttbuild_path, "sdk.json") + json_filepath = os.path.join(ttbuild_path, "tool.json") if os.path.exists(json_filepath): json_modification_time = os.path.getmtime(json_filepath) now = time.time() @@ -168,10 +161,10 @@ def should_update_sdk_json(): else: return True -def update_sdk_json(): +def update_tool_json(): global ttbuild_cdn, ttbuild_path - json_url = f"{ttbuild_cdn}/sdk.json" - json_filepath = os.path.join(ttbuild_path, "sdk.json") + json_url = f"{ttbuild_cdn}/sdk/tool.json" + json_filepath = os.path.join(ttbuild_path, "tool.json") return download_file(json_url, json_filepath) def should_fetch_sdkconfig_files(platform_targets): @@ -206,16 +199,6 @@ def validate_environment(): elif use_local_sdk == True and os.environ.get("TACTILITY_SDK_PATH") is None: exit_with_error("local build was requested, but TACTILITY_SDK_PATH environment variable is not set.") -def validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build): - version_map = sdk_json["versions"] - if not sdk_version in version_map: - exit_with_error(f"Version not found: {sdk_version}") - version_data = version_map[sdk_version] - available_platforms = version_data["platforms"] - for desired_platform in platforms_to_build: - if not desired_platform in available_platforms: - exit_with_error(f"Platform {desired_platform} is not available. Available ones: {available_platforms}") - def validate_self(sdk_json): if not "toolVersion" in sdk_json: exit_with_error("Server returned invalid SDK data format (toolVersion not found)") @@ -287,15 +270,32 @@ def get_manifest_target_platforms(manifest, requested_platform): def sdk_download(version, platform): sdk_root_dir = get_sdk_root_dir(version, platform) os.makedirs(sdk_root_dir, exist_ok=True) - sdk_url = get_sdk_url(version, platform) - filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip") + sdk_index_url = get_sdk_url(version, "index.json") print(f"Downloading SDK version {version} for {platform}") - if download_file(sdk_url, filepath): - with zipfile.ZipFile(filepath, "r") as zip_ref: - zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK")) - return True - else: + sdk_index_filepath = os.path.join(sdk_root_dir, "index.json") + if verbose: + print(f"Downloading {sdk_index_url} to {sdk_index_filepath}") + if not download_file(sdk_index_url, sdk_index_filepath): + # TODO: 404 check, print a more accurate error + print_error(f"Failed to download SDK version {version}. Check your internet connection and make sure this release exists.") + return False + sdk_index_json_file = open(sdk_index_filepath) + sdk_index_json = json.load(sdk_index_json_file) + sdk_platforms = sdk_index_json["platforms"] + if not platform in sdk_platforms: + print_error(f"Platform {platform} not found in {sdk_platforms} for version {version}") return False + sdk_platform_file = sdk_platforms[platform] + sdk_zip_source_url = get_sdk_url(version, sdk_platform_file) + sdk_zip_target_filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip") + if verbose: + print(f"Downloading {sdk_zip_source_url} to {sdk_zip_target_filepath}") + if not download_file(sdk_zip_source_url, sdk_zip_target_filepath): + print_error(f"Failed to download {sdk_zip_source_url} to {sdk_zip_target_filepath}") + return False + with zipfile.ZipFile(sdk_zip_target_filepath, "r") as zip_ref: + zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK")) + return True def sdk_download_all(version, platforms): for platform in platforms: @@ -378,7 +378,10 @@ def build_first(version, platform, skip_build): cmake_path = get_cmake_path(platform) print_status_busy(f"Building {platform} ELF") shell_needed = sys.platform == "win32" - with subprocess.Popen(["idf.py", "-B", cmake_path, "build"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: + build_command = ["idf.py", "-B", cmake_path, "build"] + if verbose: + print(f"Running command: {" ".join(build_command)}") + with subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: build_output = wait_for_process(process) # The return code is never expected to be 0 due to a bug in the elf cmake script, but we keep it just in case if process.returncode == 0: @@ -406,7 +409,10 @@ def build_consecutively(version, platform, skip_build): cmake_path = get_cmake_path(platform) print_status_busy(f"Building {platform} ELF") shell_needed = sys.platform == "win32" - with subprocess.Popen(["idf.py", "-B", cmake_path, "elf"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: + build_command = ["idf.py", "-B", cmake_path, "elf"] + if verbose: + print(f"Running command: {" ".join(build_command)}") + with subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: build_output = wait_for_process(process) if process.returncode == 0: print_status_success(f"Building {platform} ELF") @@ -494,12 +500,9 @@ def build_action(manifest, platform_arg): if not use_local_sdk: sdk_json = read_sdk_json() validate_self(sdk_json) - if not "versions" in sdk_json: - exit_with_error("Version data not found in sdk.json") # Build sdk_version = manifest["target"]["sdk"] if not use_local_sdk: - validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build) if not sdk_download_all(sdk_version, platforms_to_build): exit_with_error("Failed to download one or more SDKs") if not build_all(sdk_version, platforms_to_build, skip_build): # Environment validation @@ -633,8 +636,8 @@ def uninstall_action(manifest, ip): manifest = read_manifest() validate_manifest(manifest) all_platform_targets = manifest["target"]["platforms"].split(",") - # Update SDK cache (sdk.json) - if should_update_sdk_json() and not update_sdk_json(): + # Update SDK cache (tool.json) + if should_update_tool_json() and not update_tool_json(): exit_with_error("Failed to retrieve SDK info") # Actions if action_arg == "build": diff --git a/Apps/Diceware/CMakeLists.txt b/Apps/Diceware/CMakeLists.txt index 4785412..d575666 100644 --- a/Apps/Diceware/CMakeLists.txt +++ b/Apps/Diceware/CMakeLists.txt @@ -14,4 +14,3 @@ set(EXTRA_COMPONENT_DIRS ${TACTILITY_SDK_PATH}) project(Diceware) tactility_project(Diceware) - diff --git a/Apps/Diceware/main/Source/Diceware.cpp b/Apps/Diceware/main/Source/Diceware.cpp index 2ad1c25..2e52304 100644 --- a/Apps/Diceware/main/Source/Diceware.cpp +++ b/Apps/Diceware/main/Source/Diceware.cpp @@ -52,25 +52,23 @@ static Str readWordAtLine(const AppHandle handle, const int lineIndex) { return word; } -int32_t Diceware::jobMain(void* data) { - Diceware* application = static_cast(data); +int32_t Diceware::jobMain() { Str result; - for (int i = 0; i < application->wordCount; i++) { + 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); + auto word = readWordAtLine(handle, line_index); result.appendf("%s ", word.c_str()); } - 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,8 +77,10 @@ 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("Diceware", 4096, [this] { + return jobMain(); + }); + jobThread->start(); } void Diceware::onFinishJob(Str result) { diff --git a/Apps/Diceware/main/Source/Diceware.h b/Apps/Diceware/main/Source/Diceware.h index bb2e7bf..8972f20 100644 --- a/Apps/Diceware/main/Source/Diceware.h +++ b/Apps/Diceware/main/Source/Diceware.h @@ -1,18 +1,21 @@ #pragma once #include "tt_app.h" -#include "tt_thread.h" + +#include #include #include #include +#include + class Diceware final : public App { AppHandle handle = nullptr; lv_obj_t* spinbox = nullptr; lv_obj_t* resultLabel = nullptr; - ThreadHandle jobThread = nullptr; + std::unique_ptr jobThread = nullptr; uint32_t wordCount = 5; static void onClickGenerate(lv_event_t* e); @@ -20,7 +23,7 @@ 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); diff --git a/Apps/Diceware/manifest.properties b/Apps/Diceware/manifest.properties index 2b88678..4e2f25a 100644 --- a/Apps/Diceware/manifest.properties +++ b/Apps/Diceware/manifest.properties @@ -1,10 +1,10 @@ [manifest] version=0.1 [target] -sdk=0.6.0 -platforms=esp32,esp32s3 +sdk=0.7.0-dev +platforms=esp32,esp32s3,esp32c6,esp32p4 [app] id=one.tactility.diceware -versionName=0.2.0 -versionCode=2 +versionName=0.3.0 +versionCode=3 name=Diceware diff --git a/Apps/Diceware/tactility.py b/Apps/Diceware/tactility.py index 5d5581e..d4e0959 100644 --- a/Apps/Diceware/tactility.py +++ b/Apps/Diceware/tactility.py @@ -8,11 +8,12 @@ import time import urllib.request import zipfile +from dataclasses import dataclass import requests import tarfile ttbuild_path = ".tactility" -ttbuild_version = "2.5.0" +ttbuild_version = "3.0.0" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -20,20 +21,12 @@ use_local_sdk = False local_base_path = None -if sys.platform == "win32": - shell_color_red = "\033[91m" - shell_color_orange = "\033[93m" - shell_color_green = "\033[32m" - shell_color_purple = "\033[35m" - shell_color_cyan = "\033[36m" - shell_color_reset = "\033[m" -else: - shell_color_red = "\033[91m" - shell_color_orange = "\033[93m" - shell_color_green = "\033[32m" - shell_color_purple = "\033[35m" - shell_color_cyan = "\033[36m" - shell_color_reset = "\033[m" +shell_color_red = "\033[91m" +shell_color_orange = "\033[93m" +shell_color_green = "\033[32m" +shell_color_purple = "\033[35m" +shell_color_cyan = "\033[36m" +shell_color_reset = "\033[m" def print_help(): print("Usage: python tactility.py [action] [options]") @@ -115,7 +108,7 @@ def read_properties_file(path): #region SDK helpers def read_sdk_json(): - json_file_path = os.path.join(ttbuild_path, "sdk.json") + json_file_path = os.path.join(ttbuild_path, "tool.json") json_file = open(json_file_path) return json.load(json_file) @@ -148,17 +141,17 @@ def get_sdk_root_dir(version, platform): global ttbuild_cdn return os.path.join(ttbuild_path, f"{version}-{platform}") -def get_sdk_url(version, platform): +def get_sdk_url(version, file): global ttbuild_cdn - return f"{ttbuild_cdn}/TactilitySDK-{version}-{platform}.zip" + return f"{ttbuild_cdn}/sdk/{version}/{file}" def sdk_exists(version, platform): sdk_dir = get_sdk_dir(version, platform) return os.path.isdir(sdk_dir) -def should_update_sdk_json(): +def should_update_tool_json(): global ttbuild_cdn - json_filepath = os.path.join(ttbuild_path, "sdk.json") + json_filepath = os.path.join(ttbuild_path, "tool.json") if os.path.exists(json_filepath): json_modification_time = os.path.getmtime(json_filepath) now = time.time() @@ -168,10 +161,10 @@ def should_update_sdk_json(): else: return True -def update_sdk_json(): +def update_tool_json(): global ttbuild_cdn, ttbuild_path - json_url = f"{ttbuild_cdn}/sdk.json" - json_filepath = os.path.join(ttbuild_path, "sdk.json") + json_url = f"{ttbuild_cdn}/sdk/tool.json" + json_filepath = os.path.join(ttbuild_path, "tool.json") return download_file(json_url, json_filepath) def should_fetch_sdkconfig_files(platform_targets): @@ -206,16 +199,6 @@ def validate_environment(): elif use_local_sdk == True and os.environ.get("TACTILITY_SDK_PATH") is None: exit_with_error("local build was requested, but TACTILITY_SDK_PATH environment variable is not set.") -def validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build): - version_map = sdk_json["versions"] - if not sdk_version in version_map: - exit_with_error(f"Version not found: {sdk_version}") - version_data = version_map[sdk_version] - available_platforms = version_data["platforms"] - for desired_platform in platforms_to_build: - if not desired_platform in available_platforms: - exit_with_error(f"Platform {desired_platform} is not available. Available ones: {available_platforms}") - def validate_self(sdk_json): if not "toolVersion" in sdk_json: exit_with_error("Server returned invalid SDK data format (toolVersion not found)") @@ -287,15 +270,32 @@ def get_manifest_target_platforms(manifest, requested_platform): def sdk_download(version, platform): sdk_root_dir = get_sdk_root_dir(version, platform) os.makedirs(sdk_root_dir, exist_ok=True) - sdk_url = get_sdk_url(version, platform) - filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip") + sdk_index_url = get_sdk_url(version, "index.json") print(f"Downloading SDK version {version} for {platform}") - if download_file(sdk_url, filepath): - with zipfile.ZipFile(filepath, "r") as zip_ref: - zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK")) - return True - else: + sdk_index_filepath = os.path.join(sdk_root_dir, "index.json") + if verbose: + print(f"Downloading {sdk_index_url} to {sdk_index_filepath}") + if not download_file(sdk_index_url, sdk_index_filepath): + # TODO: 404 check, print a more accurate error + print_error(f"Failed to download SDK version {version}. Check your internet connection and make sure this release exists.") + return False + sdk_index_json_file = open(sdk_index_filepath) + sdk_index_json = json.load(sdk_index_json_file) + sdk_platforms = sdk_index_json["platforms"] + if not platform in sdk_platforms: + print_error(f"Platform {platform} not found in {sdk_platforms} for version {version}") return False + sdk_platform_file = sdk_platforms[platform] + sdk_zip_source_url = get_sdk_url(version, sdk_platform_file) + sdk_zip_target_filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip") + if verbose: + print(f"Downloading {sdk_zip_source_url} to {sdk_zip_target_filepath}") + if not download_file(sdk_zip_source_url, sdk_zip_target_filepath): + print_error(f"Failed to download {sdk_zip_source_url} to {sdk_zip_target_filepath}") + return False + with zipfile.ZipFile(sdk_zip_target_filepath, "r") as zip_ref: + zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK")) + return True def sdk_download_all(version, platforms): for platform in platforms: @@ -378,7 +378,10 @@ def build_first(version, platform, skip_build): cmake_path = get_cmake_path(platform) print_status_busy(f"Building {platform} ELF") shell_needed = sys.platform == "win32" - with subprocess.Popen(["idf.py", "-B", cmake_path, "build"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: + build_command = ["idf.py", "-B", cmake_path, "build"] + if verbose: + print(f"Running command: {" ".join(build_command)}") + with subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: build_output = wait_for_process(process) # The return code is never expected to be 0 due to a bug in the elf cmake script, but we keep it just in case if process.returncode == 0: @@ -406,7 +409,10 @@ def build_consecutively(version, platform, skip_build): cmake_path = get_cmake_path(platform) print_status_busy(f"Building {platform} ELF") shell_needed = sys.platform == "win32" - with subprocess.Popen(["idf.py", "-B", cmake_path, "elf"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: + build_command = ["idf.py", "-B", cmake_path, "elf"] + if verbose: + print(f"Running command: {" ".join(build_command)}") + with subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: build_output = wait_for_process(process) if process.returncode == 0: print_status_success(f"Building {platform} ELF") @@ -494,12 +500,9 @@ def build_action(manifest, platform_arg): if not use_local_sdk: sdk_json = read_sdk_json() validate_self(sdk_json) - if not "versions" in sdk_json: - exit_with_error("Version data not found in sdk.json") # Build sdk_version = manifest["target"]["sdk"] if not use_local_sdk: - validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build) if not sdk_download_all(sdk_version, platforms_to_build): exit_with_error("Failed to download one or more SDKs") if not build_all(sdk_version, platforms_to_build, skip_build): # Environment validation @@ -633,8 +636,8 @@ def uninstall_action(manifest, ip): manifest = read_manifest() validate_manifest(manifest) all_platform_targets = manifest["target"]["platforms"].split(",") - # Update SDK cache (sdk.json) - if should_update_sdk_json() and not update_sdk_json(): + # Update SDK cache (tool.json) + if should_update_tool_json() and not update_tool_json(): exit_with_error("Failed to retrieve SDK info") # Actions if action_arg == "build": diff --git a/Apps/GPIO/main/Source/Gpio.cpp b/Apps/GPIO/main/Source/Gpio.cpp index 47af668..525fed3 100644 --- a/Apps/GPIO/main/Source/Gpio.cpp +++ b/Apps/GPIO/main/Source/Gpio.cpp @@ -1,6 +1,7 @@ #include "Gpio.h" -#include +#include + #include #include #include @@ -18,7 +19,7 @@ void Gpio::updatePinStates() { } void Gpio::updatePinWidgets() { - tt_lvgl_lock(TT_MAX_TICKS); + tt_lvgl_lock(tt::kernel::MAX_TICKS); for (int j = 0; j < pinStates.size(); ++j) { int level = pinStates[j]; lv_obj_t* label = pinWidgets[j]; @@ -46,28 +47,21 @@ lv_obj_t* Gpio::createGpioRowWrapper(lv_obj_t* parent) { // region Task -void Gpio::onTimer(void* context) { - Gpio* app = static_cast(context); - - app->mutex.lock(); - app->updatePinStates(); - app->updatePinWidgets(); - app->mutex.unlock(); +void Gpio::onTimer() { + mutex.lock(); + updatePinStates(); + updatePinWidgets(); + mutex.unlock(); } void Gpio::startTask() { mutex.lock(); - assert(timer == nullptr); - timer = tt_timer_alloc(TimerTypePeriodic, onTimer, this); - tt_timer_start(timer, 100 / portTICK_PERIOD_MS); + timer.start(); mutex.unlock(); } void Gpio::stopTask() { - assert(timer); - tt_timer_stop(timer); - tt_timer_free(timer); - timer = nullptr; + timer.stop(); } // endregion Task diff --git a/Apps/GPIO/main/Source/Gpio.h b/Apps/GPIO/main/Source/Gpio.h index c9c86a3..e0858d6 100644 --- a/Apps/GPIO/main/Source/Gpio.h +++ b/Apps/GPIO/main/Source/Gpio.h @@ -3,9 +3,9 @@ #include #include -#include -#include +#include +#include #include #include @@ -14,11 +14,13 @@ class Gpio final : public App { std::vector pinWidgets; std::vector pinStates; - TimerHandle timer; - Mutex mutex = Mutex(MutexTypeRecursive); + tt::Timer timer = tt::Timer(tt::Timer::Type::Periodic, pdMS_TO_TICKS(100), [this]{ + onTimer(); + }); + tt::RecursiveMutex mutex; static lv_obj_t* createGpioRowWrapper(lv_obj_t* parent); - static void onTimer(void* parameter); + void onTimer(); public: diff --git a/Apps/GPIO/manifest.properties b/Apps/GPIO/manifest.properties index a45a478..afd2e34 100644 --- a/Apps/GPIO/manifest.properties +++ b/Apps/GPIO/manifest.properties @@ -1,10 +1,10 @@ [manifest] version=0.1 [target] -sdk=0.6.0 -platforms=esp32,esp32s3 +sdk=0.7.0-dev +platforms=esp32,esp32s3,esp32c6,esp32p4 [app] id=one.tactility.gpio -versionName=0.2.0 -versionCode=2 +versionName=0.3.0 +versionCode=3 name=GPIO diff --git a/Apps/GPIO/tactility.py b/Apps/GPIO/tactility.py index 5d5581e..d4e0959 100644 --- a/Apps/GPIO/tactility.py +++ b/Apps/GPIO/tactility.py @@ -8,11 +8,12 @@ import time import urllib.request import zipfile +from dataclasses import dataclass import requests import tarfile ttbuild_path = ".tactility" -ttbuild_version = "2.5.0" +ttbuild_version = "3.0.0" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -20,20 +21,12 @@ use_local_sdk = False local_base_path = None -if sys.platform == "win32": - shell_color_red = "\033[91m" - shell_color_orange = "\033[93m" - shell_color_green = "\033[32m" - shell_color_purple = "\033[35m" - shell_color_cyan = "\033[36m" - shell_color_reset = "\033[m" -else: - shell_color_red = "\033[91m" - shell_color_orange = "\033[93m" - shell_color_green = "\033[32m" - shell_color_purple = "\033[35m" - shell_color_cyan = "\033[36m" - shell_color_reset = "\033[m" +shell_color_red = "\033[91m" +shell_color_orange = "\033[93m" +shell_color_green = "\033[32m" +shell_color_purple = "\033[35m" +shell_color_cyan = "\033[36m" +shell_color_reset = "\033[m" def print_help(): print("Usage: python tactility.py [action] [options]") @@ -115,7 +108,7 @@ def read_properties_file(path): #region SDK helpers def read_sdk_json(): - json_file_path = os.path.join(ttbuild_path, "sdk.json") + json_file_path = os.path.join(ttbuild_path, "tool.json") json_file = open(json_file_path) return json.load(json_file) @@ -148,17 +141,17 @@ def get_sdk_root_dir(version, platform): global ttbuild_cdn return os.path.join(ttbuild_path, f"{version}-{platform}") -def get_sdk_url(version, platform): +def get_sdk_url(version, file): global ttbuild_cdn - return f"{ttbuild_cdn}/TactilitySDK-{version}-{platform}.zip" + return f"{ttbuild_cdn}/sdk/{version}/{file}" def sdk_exists(version, platform): sdk_dir = get_sdk_dir(version, platform) return os.path.isdir(sdk_dir) -def should_update_sdk_json(): +def should_update_tool_json(): global ttbuild_cdn - json_filepath = os.path.join(ttbuild_path, "sdk.json") + json_filepath = os.path.join(ttbuild_path, "tool.json") if os.path.exists(json_filepath): json_modification_time = os.path.getmtime(json_filepath) now = time.time() @@ -168,10 +161,10 @@ def should_update_sdk_json(): else: return True -def update_sdk_json(): +def update_tool_json(): global ttbuild_cdn, ttbuild_path - json_url = f"{ttbuild_cdn}/sdk.json" - json_filepath = os.path.join(ttbuild_path, "sdk.json") + json_url = f"{ttbuild_cdn}/sdk/tool.json" + json_filepath = os.path.join(ttbuild_path, "tool.json") return download_file(json_url, json_filepath) def should_fetch_sdkconfig_files(platform_targets): @@ -206,16 +199,6 @@ def validate_environment(): elif use_local_sdk == True and os.environ.get("TACTILITY_SDK_PATH") is None: exit_with_error("local build was requested, but TACTILITY_SDK_PATH environment variable is not set.") -def validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build): - version_map = sdk_json["versions"] - if not sdk_version in version_map: - exit_with_error(f"Version not found: {sdk_version}") - version_data = version_map[sdk_version] - available_platforms = version_data["platforms"] - for desired_platform in platforms_to_build: - if not desired_platform in available_platforms: - exit_with_error(f"Platform {desired_platform} is not available. Available ones: {available_platforms}") - def validate_self(sdk_json): if not "toolVersion" in sdk_json: exit_with_error("Server returned invalid SDK data format (toolVersion not found)") @@ -287,15 +270,32 @@ def get_manifest_target_platforms(manifest, requested_platform): def sdk_download(version, platform): sdk_root_dir = get_sdk_root_dir(version, platform) os.makedirs(sdk_root_dir, exist_ok=True) - sdk_url = get_sdk_url(version, platform) - filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip") + sdk_index_url = get_sdk_url(version, "index.json") print(f"Downloading SDK version {version} for {platform}") - if download_file(sdk_url, filepath): - with zipfile.ZipFile(filepath, "r") as zip_ref: - zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK")) - return True - else: + sdk_index_filepath = os.path.join(sdk_root_dir, "index.json") + if verbose: + print(f"Downloading {sdk_index_url} to {sdk_index_filepath}") + if not download_file(sdk_index_url, sdk_index_filepath): + # TODO: 404 check, print a more accurate error + print_error(f"Failed to download SDK version {version}. Check your internet connection and make sure this release exists.") + return False + sdk_index_json_file = open(sdk_index_filepath) + sdk_index_json = json.load(sdk_index_json_file) + sdk_platforms = sdk_index_json["platforms"] + if not platform in sdk_platforms: + print_error(f"Platform {platform} not found in {sdk_platforms} for version {version}") return False + sdk_platform_file = sdk_platforms[platform] + sdk_zip_source_url = get_sdk_url(version, sdk_platform_file) + sdk_zip_target_filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip") + if verbose: + print(f"Downloading {sdk_zip_source_url} to {sdk_zip_target_filepath}") + if not download_file(sdk_zip_source_url, sdk_zip_target_filepath): + print_error(f"Failed to download {sdk_zip_source_url} to {sdk_zip_target_filepath}") + return False + with zipfile.ZipFile(sdk_zip_target_filepath, "r") as zip_ref: + zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK")) + return True def sdk_download_all(version, platforms): for platform in platforms: @@ -378,7 +378,10 @@ def build_first(version, platform, skip_build): cmake_path = get_cmake_path(platform) print_status_busy(f"Building {platform} ELF") shell_needed = sys.platform == "win32" - with subprocess.Popen(["idf.py", "-B", cmake_path, "build"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: + build_command = ["idf.py", "-B", cmake_path, "build"] + if verbose: + print(f"Running command: {" ".join(build_command)}") + with subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: build_output = wait_for_process(process) # The return code is never expected to be 0 due to a bug in the elf cmake script, but we keep it just in case if process.returncode == 0: @@ -406,7 +409,10 @@ def build_consecutively(version, platform, skip_build): cmake_path = get_cmake_path(platform) print_status_busy(f"Building {platform} ELF") shell_needed = sys.platform == "win32" - with subprocess.Popen(["idf.py", "-B", cmake_path, "elf"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: + build_command = ["idf.py", "-B", cmake_path, "elf"] + if verbose: + print(f"Running command: {" ".join(build_command)}") + with subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: build_output = wait_for_process(process) if process.returncode == 0: print_status_success(f"Building {platform} ELF") @@ -494,12 +500,9 @@ def build_action(manifest, platform_arg): if not use_local_sdk: sdk_json = read_sdk_json() validate_self(sdk_json) - if not "versions" in sdk_json: - exit_with_error("Version data not found in sdk.json") # Build sdk_version = manifest["target"]["sdk"] if not use_local_sdk: - validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build) if not sdk_download_all(sdk_version, platforms_to_build): exit_with_error("Failed to download one or more SDKs") if not build_all(sdk_version, platforms_to_build, skip_build): # Environment validation @@ -633,8 +636,8 @@ def uninstall_action(manifest, ip): manifest = read_manifest() validate_manifest(manifest) all_platform_targets = manifest["target"]["platforms"].split(",") - # Update SDK cache (sdk.json) - if should_update_sdk_json() and not update_sdk_json(): + # Update SDK cache (tool.json) + if should_update_tool_json() and not update_tool_json(): exit_with_error("Failed to retrieve SDK info") # Actions if action_arg == "build": diff --git a/Apps/GraphicsDemo/main/Include/drivers/DisplayDriver.h b/Apps/GraphicsDemo/main/Include/drivers/DisplayDriver.h index 1b4310c..702fc59 100644 --- a/Apps/GraphicsDemo/main/Include/drivers/DisplayDriver.h +++ b/Apps/GraphicsDemo/main/Include/drivers/DisplayDriver.h @@ -2,6 +2,7 @@ #include #include +#include /** * Wrapper for tt_hal_display_driver_* @@ -22,7 +23,7 @@ class DisplayDriver { tt_hal_display_driver_free(handle); } - bool lock(TickType timeout = TT_MAX_TICKS) const { + bool lock(TickType_t timeout = tt::kernel::MAX_TICKS) const { return tt_hal_display_driver_lock(handle, timeout); } diff --git a/Apps/GraphicsDemo/main/Source/Application.cpp b/Apps/GraphicsDemo/main/Source/Application.cpp index 6594cf0..417cb1a 100644 --- a/Apps/GraphicsDemo/main/Source/Application.cpp +++ b/Apps/GraphicsDemo/main/Source/Application.cpp @@ -2,7 +2,7 @@ #include "PixelBuffer.h" #include "esp_log.h" -#include +#include constexpr auto TAG = "Application"; @@ -66,7 +66,7 @@ void runApplication(DisplayDriver* display, TouchDriver* touch) { // Give other tasks space to breathe // SPI displays would otherwise time out SPI SD card access - tt_kernel_delay_ticks(1); + tt::kernel::delayTicks(1); } while (!isTouched(touch)); } diff --git a/Apps/GraphicsDemo/manifest.properties b/Apps/GraphicsDemo/manifest.properties index af5ef93..574be53 100644 --- a/Apps/GraphicsDemo/manifest.properties +++ b/Apps/GraphicsDemo/manifest.properties @@ -1,10 +1,10 @@ [manifest] version=0.1 [target] -sdk=0.6.0 -platforms=esp32,esp32s3 +sdk=0.7.0-dev +platforms=esp32,esp32s3,esp32c6,esp32p4 [app] id=one.tactility.graphicsdemo -versionName=0.2.0 -versionCode=2 +versionName=0.3.0 +versionCode=3 name=Graphics Demo diff --git a/Apps/GraphicsDemo/tactility.py b/Apps/GraphicsDemo/tactility.py index 5d5581e..d4e0959 100644 --- a/Apps/GraphicsDemo/tactility.py +++ b/Apps/GraphicsDemo/tactility.py @@ -8,11 +8,12 @@ import time import urllib.request import zipfile +from dataclasses import dataclass import requests import tarfile ttbuild_path = ".tactility" -ttbuild_version = "2.5.0" +ttbuild_version = "3.0.0" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -20,20 +21,12 @@ use_local_sdk = False local_base_path = None -if sys.platform == "win32": - shell_color_red = "\033[91m" - shell_color_orange = "\033[93m" - shell_color_green = "\033[32m" - shell_color_purple = "\033[35m" - shell_color_cyan = "\033[36m" - shell_color_reset = "\033[m" -else: - shell_color_red = "\033[91m" - shell_color_orange = "\033[93m" - shell_color_green = "\033[32m" - shell_color_purple = "\033[35m" - shell_color_cyan = "\033[36m" - shell_color_reset = "\033[m" +shell_color_red = "\033[91m" +shell_color_orange = "\033[93m" +shell_color_green = "\033[32m" +shell_color_purple = "\033[35m" +shell_color_cyan = "\033[36m" +shell_color_reset = "\033[m" def print_help(): print("Usage: python tactility.py [action] [options]") @@ -115,7 +108,7 @@ def read_properties_file(path): #region SDK helpers def read_sdk_json(): - json_file_path = os.path.join(ttbuild_path, "sdk.json") + json_file_path = os.path.join(ttbuild_path, "tool.json") json_file = open(json_file_path) return json.load(json_file) @@ -148,17 +141,17 @@ def get_sdk_root_dir(version, platform): global ttbuild_cdn return os.path.join(ttbuild_path, f"{version}-{platform}") -def get_sdk_url(version, platform): +def get_sdk_url(version, file): global ttbuild_cdn - return f"{ttbuild_cdn}/TactilitySDK-{version}-{platform}.zip" + return f"{ttbuild_cdn}/sdk/{version}/{file}" def sdk_exists(version, platform): sdk_dir = get_sdk_dir(version, platform) return os.path.isdir(sdk_dir) -def should_update_sdk_json(): +def should_update_tool_json(): global ttbuild_cdn - json_filepath = os.path.join(ttbuild_path, "sdk.json") + json_filepath = os.path.join(ttbuild_path, "tool.json") if os.path.exists(json_filepath): json_modification_time = os.path.getmtime(json_filepath) now = time.time() @@ -168,10 +161,10 @@ def should_update_sdk_json(): else: return True -def update_sdk_json(): +def update_tool_json(): global ttbuild_cdn, ttbuild_path - json_url = f"{ttbuild_cdn}/sdk.json" - json_filepath = os.path.join(ttbuild_path, "sdk.json") + json_url = f"{ttbuild_cdn}/sdk/tool.json" + json_filepath = os.path.join(ttbuild_path, "tool.json") return download_file(json_url, json_filepath) def should_fetch_sdkconfig_files(platform_targets): @@ -206,16 +199,6 @@ def validate_environment(): elif use_local_sdk == True and os.environ.get("TACTILITY_SDK_PATH") is None: exit_with_error("local build was requested, but TACTILITY_SDK_PATH environment variable is not set.") -def validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build): - version_map = sdk_json["versions"] - if not sdk_version in version_map: - exit_with_error(f"Version not found: {sdk_version}") - version_data = version_map[sdk_version] - available_platforms = version_data["platforms"] - for desired_platform in platforms_to_build: - if not desired_platform in available_platforms: - exit_with_error(f"Platform {desired_platform} is not available. Available ones: {available_platforms}") - def validate_self(sdk_json): if not "toolVersion" in sdk_json: exit_with_error("Server returned invalid SDK data format (toolVersion not found)") @@ -287,15 +270,32 @@ def get_manifest_target_platforms(manifest, requested_platform): def sdk_download(version, platform): sdk_root_dir = get_sdk_root_dir(version, platform) os.makedirs(sdk_root_dir, exist_ok=True) - sdk_url = get_sdk_url(version, platform) - filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip") + sdk_index_url = get_sdk_url(version, "index.json") print(f"Downloading SDK version {version} for {platform}") - if download_file(sdk_url, filepath): - with zipfile.ZipFile(filepath, "r") as zip_ref: - zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK")) - return True - else: + sdk_index_filepath = os.path.join(sdk_root_dir, "index.json") + if verbose: + print(f"Downloading {sdk_index_url} to {sdk_index_filepath}") + if not download_file(sdk_index_url, sdk_index_filepath): + # TODO: 404 check, print a more accurate error + print_error(f"Failed to download SDK version {version}. Check your internet connection and make sure this release exists.") + return False + sdk_index_json_file = open(sdk_index_filepath) + sdk_index_json = json.load(sdk_index_json_file) + sdk_platforms = sdk_index_json["platforms"] + if not platform in sdk_platforms: + print_error(f"Platform {platform} not found in {sdk_platforms} for version {version}") return False + sdk_platform_file = sdk_platforms[platform] + sdk_zip_source_url = get_sdk_url(version, sdk_platform_file) + sdk_zip_target_filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip") + if verbose: + print(f"Downloading {sdk_zip_source_url} to {sdk_zip_target_filepath}") + if not download_file(sdk_zip_source_url, sdk_zip_target_filepath): + print_error(f"Failed to download {sdk_zip_source_url} to {sdk_zip_target_filepath}") + return False + with zipfile.ZipFile(sdk_zip_target_filepath, "r") as zip_ref: + zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK")) + return True def sdk_download_all(version, platforms): for platform in platforms: @@ -378,7 +378,10 @@ def build_first(version, platform, skip_build): cmake_path = get_cmake_path(platform) print_status_busy(f"Building {platform} ELF") shell_needed = sys.platform == "win32" - with subprocess.Popen(["idf.py", "-B", cmake_path, "build"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: + build_command = ["idf.py", "-B", cmake_path, "build"] + if verbose: + print(f"Running command: {" ".join(build_command)}") + with subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: build_output = wait_for_process(process) # The return code is never expected to be 0 due to a bug in the elf cmake script, but we keep it just in case if process.returncode == 0: @@ -406,7 +409,10 @@ def build_consecutively(version, platform, skip_build): cmake_path = get_cmake_path(platform) print_status_busy(f"Building {platform} ELF") shell_needed = sys.platform == "win32" - with subprocess.Popen(["idf.py", "-B", cmake_path, "elf"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: + build_command = ["idf.py", "-B", cmake_path, "elf"] + if verbose: + print(f"Running command: {" ".join(build_command)}") + with subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: build_output = wait_for_process(process) if process.returncode == 0: print_status_success(f"Building {platform} ELF") @@ -494,12 +500,9 @@ def build_action(manifest, platform_arg): if not use_local_sdk: sdk_json = read_sdk_json() validate_self(sdk_json) - if not "versions" in sdk_json: - exit_with_error("Version data not found in sdk.json") # Build sdk_version = manifest["target"]["sdk"] if not use_local_sdk: - validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build) if not sdk_download_all(sdk_version, platforms_to_build): exit_with_error("Failed to download one or more SDKs") if not build_all(sdk_version, platforms_to_build, skip_build): # Environment validation @@ -633,8 +636,8 @@ def uninstall_action(manifest, ip): manifest = read_manifest() validate_manifest(manifest) all_platform_targets = manifest["target"]["platforms"].split(",") - # Update SDK cache (sdk.json) - if should_update_sdk_json() and not update_sdk_json(): + # Update SDK cache (tool.json) + if should_update_tool_json() and not update_tool_json(): exit_with_error("Failed to retrieve SDK info") # Actions if action_arg == "build": diff --git a/Apps/HelloWorld/manifest.properties b/Apps/HelloWorld/manifest.properties index b2cb9f2..2432119 100644 --- a/Apps/HelloWorld/manifest.properties +++ b/Apps/HelloWorld/manifest.properties @@ -1,10 +1,10 @@ [manifest] version=0.1 [target] -sdk=0.6.0 -platforms=esp32,esp32s3 +sdk=0.7.0-dev +platforms=esp32,esp32s3,esp32c6,esp32p4 [app] id=one.tactility.helloworld -versionName=0.2.0 -versionCode=2 +versionName=0.3.0 +versionCode=3 name=Hello World diff --git a/Apps/HelloWorld/tactility.py b/Apps/HelloWorld/tactility.py index 5d5581e..75b132c 100644 --- a/Apps/HelloWorld/tactility.py +++ b/Apps/HelloWorld/tactility.py @@ -8,11 +8,12 @@ import time import urllib.request import zipfile +from dataclasses import dataclass import requests import tarfile ttbuild_path = ".tactility" -ttbuild_version = "2.5.0" +ttbuild_version = "3.0.0" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -20,20 +21,12 @@ use_local_sdk = False local_base_path = None -if sys.platform == "win32": - shell_color_red = "\033[91m" - shell_color_orange = "\033[93m" - shell_color_green = "\033[32m" - shell_color_purple = "\033[35m" - shell_color_cyan = "\033[36m" - shell_color_reset = "\033[m" -else: - shell_color_red = "\033[91m" - shell_color_orange = "\033[93m" - shell_color_green = "\033[32m" - shell_color_purple = "\033[35m" - shell_color_cyan = "\033[36m" - shell_color_reset = "\033[m" +shell_color_red = "\033[91m" +shell_color_orange = "\033[93m" +shell_color_green = "\033[32m" +shell_color_purple = "\033[35m" +shell_color_cyan = "\033[36m" +shell_color_reset = "\033[m" def print_help(): print("Usage: python tactility.py [action] [options]") @@ -115,7 +108,7 @@ def read_properties_file(path): #region SDK helpers def read_sdk_json(): - json_file_path = os.path.join(ttbuild_path, "sdk.json") + json_file_path = os.path.join(ttbuild_path, "tool.json") json_file = open(json_file_path) return json.load(json_file) @@ -148,17 +141,17 @@ def get_sdk_root_dir(version, platform): global ttbuild_cdn return os.path.join(ttbuild_path, f"{version}-{platform}") -def get_sdk_url(version, platform): +def get_sdk_url(version, file): global ttbuild_cdn - return f"{ttbuild_cdn}/TactilitySDK-{version}-{platform}.zip" + return f"{ttbuild_cdn}/sdk/{version}/{file}" def sdk_exists(version, platform): sdk_dir = get_sdk_dir(version, platform) return os.path.isdir(sdk_dir) -def should_update_sdk_json(): +def should_update_tool_json(): global ttbuild_cdn - json_filepath = os.path.join(ttbuild_path, "sdk.json") + json_filepath = os.path.join(ttbuild_path, "tool.json") if os.path.exists(json_filepath): json_modification_time = os.path.getmtime(json_filepath) now = time.time() @@ -168,10 +161,10 @@ def should_update_sdk_json(): else: return True -def update_sdk_json(): +def update_tool_json(): global ttbuild_cdn, ttbuild_path - json_url = f"{ttbuild_cdn}/sdk.json" - json_filepath = os.path.join(ttbuild_path, "sdk.json") + json_url = f"{ttbuild_cdn}/sdk/tool.json" + json_filepath = os.path.join(ttbuild_path, "tool.json") return download_file(json_url, json_filepath) def should_fetch_sdkconfig_files(platform_targets): @@ -206,16 +199,6 @@ def validate_environment(): elif use_local_sdk == True and os.environ.get("TACTILITY_SDK_PATH") is None: exit_with_error("local build was requested, but TACTILITY_SDK_PATH environment variable is not set.") -def validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build): - version_map = sdk_json["versions"] - if not sdk_version in version_map: - exit_with_error(f"Version not found: {sdk_version}") - version_data = version_map[sdk_version] - available_platforms = version_data["platforms"] - for desired_platform in platforms_to_build: - if not desired_platform in available_platforms: - exit_with_error(f"Platform {desired_platform} is not available. Available ones: {available_platforms}") - def validate_self(sdk_json): if not "toolVersion" in sdk_json: exit_with_error("Server returned invalid SDK data format (toolVersion not found)") @@ -287,15 +270,32 @@ def get_manifest_target_platforms(manifest, requested_platform): def sdk_download(version, platform): sdk_root_dir = get_sdk_root_dir(version, platform) os.makedirs(sdk_root_dir, exist_ok=True) - sdk_url = get_sdk_url(version, platform) - filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip") + sdk_index_url = get_sdk_url(version, "index.json") print(f"Downloading SDK version {version} for {platform}") - if download_file(sdk_url, filepath): - with zipfile.ZipFile(filepath, "r") as zip_ref: - zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK")) - return True - else: + sdk_index_filepath = os.path.join(sdk_root_dir, "index.json") + if verbose: + print(f"Downloading {sdk_index_url} to {sdk_index_filepath}") + if not download_file(sdk_index_url, sdk_index_filepath): + # TODO: 404 check, print a more accurate error + print_error(f"Failed to download SDK version {version}. Check your internet connection and make sure this release exists.") return False + sdk_index_json_file = open(sdk_index_filepath) + sdk_index_json = json.load(sdk_index_json_file) + sdk_platforms = sdk_index_json["platforms"] + if not platform in sdk_platforms: + print_error(f"Platform {platform} not found in {sdk_platforms} for version {version}") + return False + sdk_platform_file = sdk_platforms[platform] + sdk_zip_source_url = get_sdk_url(version, sdk_platform_file) + sdk_zip_target_filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip") + if verbose: + print(f"Downloading {sdk_zip_source_url} to {sdk_zip_target_filepath}") + if not download_file(sdk_zip_source_url, sdk_zip_target_filepath): + print_error(f"Failed to download {sdk_zip_source_url} to {sdk_zip_target_filepath}") + return False + with zipfile.ZipFile(sdk_zip_target_filepath, "r") as zip_ref: + zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK")) + return True def sdk_download_all(version, platforms): for platform in platforms: @@ -494,12 +494,9 @@ def build_action(manifest, platform_arg): if not use_local_sdk: sdk_json = read_sdk_json() validate_self(sdk_json) - if not "versions" in sdk_json: - exit_with_error("Version data not found in sdk.json") # Build sdk_version = manifest["target"]["sdk"] if not use_local_sdk: - validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build) if not sdk_download_all(sdk_version, platforms_to_build): exit_with_error("Failed to download one or more SDKs") if not build_all(sdk_version, platforms_to_build, skip_build): # Environment validation @@ -633,8 +630,8 @@ def uninstall_action(manifest, ip): manifest = read_manifest() validate_manifest(manifest) all_platform_targets = manifest["target"]["platforms"].split(",") - # Update SDK cache (sdk.json) - if should_update_sdk_json() and not update_sdk_json(): + # Update SDK cache (tool.json) + if should_update_tool_json() and not update_tool_json(): exit_with_error("Failed to retrieve SDK info") # Actions if action_arg == "build": diff --git a/Apps/SerialConsole/main/Source/ConsoleView.h b/Apps/SerialConsole/main/Source/ConsoleView.h index a4a8ec4..a0c4050 100644 --- a/Apps/SerialConsole/main/Source/ConsoleView.h +++ b/Apps/SerialConsole/main/Source/ConsoleView.h @@ -9,10 +9,9 @@ #include #include -#include -#include -#include +#include +#include #include constexpr size_t receiveBufferSize = 512; @@ -26,11 +25,11 @@ class ConsoleView final : public View { lv_obj_t* _Nullable logTextarea = nullptr; lv_obj_t* _Nullable inputTextarea = nullptr; std::shared_ptr _Nullable uart = nullptr; - std::shared_ptr uartThread _Nullable = nullptr; + std::shared_ptr uartThread _Nullable = nullptr; bool uartThreadInterrupted = false; - std::shared_ptr viewThread _Nullable = nullptr; + std::shared_ptr viewThread _Nullable = nullptr; bool viewThreadInterrupted = false; - Mutex mutex = Mutex(MutexTypeRecursive); + tt::RecursiveMutex mutex; uint8_t receiveBuffer[receiveBufferSize]; uint8_t renderBuffer[renderBufferSize]; size_t receiveBufferPosition = 0; @@ -51,11 +50,6 @@ class ConsoleView final : public View { } void updateViews() { - auto scoped_lvgl_lock = lvglLock.asScopedLock(); - if (!scoped_lvgl_lock.lock()) { - return; - } - if (parent == nullptr) { return; } @@ -73,32 +67,28 @@ class ConsoleView final : public View { mutex.unlock(); } - tt_lvgl_lock(TT_MAX_TICKS); - lv_textarea_set_text(logTextarea, (const char*)renderBuffer); - tt_lvgl_unlock(); + if (lvglLock.lock()) { + lv_textarea_set_text(logTextarea, (const char*)renderBuffer); + lvglLock.unlock(); + } } int32_t viewThreadMain() { while (!isViewThreadInterrupted()) { - auto start_time = tt_kernel_get_ticks(); + auto start_time = tt::kernel::getTicks(); updateViews(); - auto end_time = tt_kernel_get_ticks(); + auto end_time = tt::kernel::getTicks(); auto time_diff = end_time - start_time; if (time_diff < 500U) { - tt_kernel_delay_ticks((500U - time_diff) / portTICK_PERIOD_MS); + tt::kernel::delayTicks((500U - time_diff) / portTICK_PERIOD_MS); } } return 0; } - static int32_t viewThreadMainStatic(void* context) { - auto* self = static_cast(context); - return self->viewThreadMain(); - } - int32_t uartThreadMain() { char byte; @@ -125,11 +115,6 @@ class ConsoleView final : public View { return 0; } - static int32_t uartThreadMainStatic(void* view) { - auto* self = static_cast(view); - return self->uartThreadMain(); - } - static void onSendClickedCallback(lv_event_t* event) { auto* view = (ConsoleView*)lv_event_get_user_data(event); view->onSendClicked(); @@ -181,13 +166,12 @@ class ConsoleView final : public View { uart = std::move(newUart); uartThreadInterrupted = false; - uartThread = std::make_unique( + uartThread = std::make_unique( "SerConsUart", 4096, - uartThreadMainStatic, - this + [this] { return uartThreadMain(); } ); - uartThread->setPriority(ThreadPriorityHigh); + uartThread->setPriority(tt::Thread::Priority::High); uartThread->start(); } @@ -228,13 +212,12 @@ class ConsoleView final : public View { lv_obj_add_event_cb(button, onSendClickedCallback, LV_EVENT_SHORT_CLICKED, this); viewThreadInterrupted = false; - viewThread = std::make_unique( + viewThread = std::make_unique( "SerConsView", 4096, - viewThreadMainStatic, - this + [this] { return viewThreadMain(); } ); - viewThread->setPriority(ThreadPriorityHigher); + viewThread->setPriority(tt::Thread::Priority::Higher); viewThread->start(); } @@ -249,7 +232,7 @@ class ConsoleView final : public View { // Unlock so thread can lock lock.unlock(); - if (old_uart_thread->getState() != ThreadStateStopped) { + if (old_uart_thread->getState() != tt::Thread::State::Stopped) { // Wait for thread to finish old_uart_thread->join(); } @@ -267,7 +250,7 @@ class ConsoleView final : public View { // Unlock so thread can lock lock.unlock(); - if (old_view_thread->getState() != ThreadStateStopped) { + if (old_view_thread->getState() != tt::Thread::State::Stopped) { // Wait for thread to finish old_view_thread->join(); } diff --git a/Apps/SerialConsole/manifest.properties b/Apps/SerialConsole/manifest.properties index cc5dffc..13e2e2d 100644 --- a/Apps/SerialConsole/manifest.properties +++ b/Apps/SerialConsole/manifest.properties @@ -1,10 +1,10 @@ [manifest] version=0.1 [target] -sdk=0.6.0 -platforms=esp32,esp32s3 +sdk=0.7.0-dev +platforms=esp32,esp32s3,esp32c6,esp32p4 [app] id=one.tactility.serialconsole -versionName=0.2.0 -versionCode=2 +versionName=0.3.0 +versionCode=3 name=Serial Console diff --git a/Apps/SerialConsole/tactility.py b/Apps/SerialConsole/tactility.py index 5d5581e..d4e0959 100644 --- a/Apps/SerialConsole/tactility.py +++ b/Apps/SerialConsole/tactility.py @@ -8,11 +8,12 @@ import time import urllib.request import zipfile +from dataclasses import dataclass import requests import tarfile ttbuild_path = ".tactility" -ttbuild_version = "2.5.0" +ttbuild_version = "3.0.0" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -20,20 +21,12 @@ use_local_sdk = False local_base_path = None -if sys.platform == "win32": - shell_color_red = "\033[91m" - shell_color_orange = "\033[93m" - shell_color_green = "\033[32m" - shell_color_purple = "\033[35m" - shell_color_cyan = "\033[36m" - shell_color_reset = "\033[m" -else: - shell_color_red = "\033[91m" - shell_color_orange = "\033[93m" - shell_color_green = "\033[32m" - shell_color_purple = "\033[35m" - shell_color_cyan = "\033[36m" - shell_color_reset = "\033[m" +shell_color_red = "\033[91m" +shell_color_orange = "\033[93m" +shell_color_green = "\033[32m" +shell_color_purple = "\033[35m" +shell_color_cyan = "\033[36m" +shell_color_reset = "\033[m" def print_help(): print("Usage: python tactility.py [action] [options]") @@ -115,7 +108,7 @@ def read_properties_file(path): #region SDK helpers def read_sdk_json(): - json_file_path = os.path.join(ttbuild_path, "sdk.json") + json_file_path = os.path.join(ttbuild_path, "tool.json") json_file = open(json_file_path) return json.load(json_file) @@ -148,17 +141,17 @@ def get_sdk_root_dir(version, platform): global ttbuild_cdn return os.path.join(ttbuild_path, f"{version}-{platform}") -def get_sdk_url(version, platform): +def get_sdk_url(version, file): global ttbuild_cdn - return f"{ttbuild_cdn}/TactilitySDK-{version}-{platform}.zip" + return f"{ttbuild_cdn}/sdk/{version}/{file}" def sdk_exists(version, platform): sdk_dir = get_sdk_dir(version, platform) return os.path.isdir(sdk_dir) -def should_update_sdk_json(): +def should_update_tool_json(): global ttbuild_cdn - json_filepath = os.path.join(ttbuild_path, "sdk.json") + json_filepath = os.path.join(ttbuild_path, "tool.json") if os.path.exists(json_filepath): json_modification_time = os.path.getmtime(json_filepath) now = time.time() @@ -168,10 +161,10 @@ def should_update_sdk_json(): else: return True -def update_sdk_json(): +def update_tool_json(): global ttbuild_cdn, ttbuild_path - json_url = f"{ttbuild_cdn}/sdk.json" - json_filepath = os.path.join(ttbuild_path, "sdk.json") + json_url = f"{ttbuild_cdn}/sdk/tool.json" + json_filepath = os.path.join(ttbuild_path, "tool.json") return download_file(json_url, json_filepath) def should_fetch_sdkconfig_files(platform_targets): @@ -206,16 +199,6 @@ def validate_environment(): elif use_local_sdk == True and os.environ.get("TACTILITY_SDK_PATH") is None: exit_with_error("local build was requested, but TACTILITY_SDK_PATH environment variable is not set.") -def validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build): - version_map = sdk_json["versions"] - if not sdk_version in version_map: - exit_with_error(f"Version not found: {sdk_version}") - version_data = version_map[sdk_version] - available_platforms = version_data["platforms"] - for desired_platform in platforms_to_build: - if not desired_platform in available_platforms: - exit_with_error(f"Platform {desired_platform} is not available. Available ones: {available_platforms}") - def validate_self(sdk_json): if not "toolVersion" in sdk_json: exit_with_error("Server returned invalid SDK data format (toolVersion not found)") @@ -287,15 +270,32 @@ def get_manifest_target_platforms(manifest, requested_platform): def sdk_download(version, platform): sdk_root_dir = get_sdk_root_dir(version, platform) os.makedirs(sdk_root_dir, exist_ok=True) - sdk_url = get_sdk_url(version, platform) - filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip") + sdk_index_url = get_sdk_url(version, "index.json") print(f"Downloading SDK version {version} for {platform}") - if download_file(sdk_url, filepath): - with zipfile.ZipFile(filepath, "r") as zip_ref: - zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK")) - return True - else: + sdk_index_filepath = os.path.join(sdk_root_dir, "index.json") + if verbose: + print(f"Downloading {sdk_index_url} to {sdk_index_filepath}") + if not download_file(sdk_index_url, sdk_index_filepath): + # TODO: 404 check, print a more accurate error + print_error(f"Failed to download SDK version {version}. Check your internet connection and make sure this release exists.") + return False + sdk_index_json_file = open(sdk_index_filepath) + sdk_index_json = json.load(sdk_index_json_file) + sdk_platforms = sdk_index_json["platforms"] + if not platform in sdk_platforms: + print_error(f"Platform {platform} not found in {sdk_platforms} for version {version}") return False + sdk_platform_file = sdk_platforms[platform] + sdk_zip_source_url = get_sdk_url(version, sdk_platform_file) + sdk_zip_target_filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip") + if verbose: + print(f"Downloading {sdk_zip_source_url} to {sdk_zip_target_filepath}") + if not download_file(sdk_zip_source_url, sdk_zip_target_filepath): + print_error(f"Failed to download {sdk_zip_source_url} to {sdk_zip_target_filepath}") + return False + with zipfile.ZipFile(sdk_zip_target_filepath, "r") as zip_ref: + zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK")) + return True def sdk_download_all(version, platforms): for platform in platforms: @@ -378,7 +378,10 @@ def build_first(version, platform, skip_build): cmake_path = get_cmake_path(platform) print_status_busy(f"Building {platform} ELF") shell_needed = sys.platform == "win32" - with subprocess.Popen(["idf.py", "-B", cmake_path, "build"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: + build_command = ["idf.py", "-B", cmake_path, "build"] + if verbose: + print(f"Running command: {" ".join(build_command)}") + with subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: build_output = wait_for_process(process) # The return code is never expected to be 0 due to a bug in the elf cmake script, but we keep it just in case if process.returncode == 0: @@ -406,7 +409,10 @@ def build_consecutively(version, platform, skip_build): cmake_path = get_cmake_path(platform) print_status_busy(f"Building {platform} ELF") shell_needed = sys.platform == "win32" - with subprocess.Popen(["idf.py", "-B", cmake_path, "elf"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: + build_command = ["idf.py", "-B", cmake_path, "elf"] + if verbose: + print(f"Running command: {" ".join(build_command)}") + with subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: build_output = wait_for_process(process) if process.returncode == 0: print_status_success(f"Building {platform} ELF") @@ -494,12 +500,9 @@ def build_action(manifest, platform_arg): if not use_local_sdk: sdk_json = read_sdk_json() validate_self(sdk_json) - if not "versions" in sdk_json: - exit_with_error("Version data not found in sdk.json") # Build sdk_version = manifest["target"]["sdk"] if not use_local_sdk: - validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build) if not sdk_download_all(sdk_version, platforms_to_build): exit_with_error("Failed to download one or more SDKs") if not build_all(sdk_version, platforms_to_build, skip_build): # Environment validation @@ -633,8 +636,8 @@ def uninstall_action(manifest, ip): manifest = read_manifest() validate_manifest(manifest) all_platform_targets = manifest["target"]["platforms"].split(",") - # Update SDK cache (sdk.json) - if should_update_sdk_json() and not update_sdk_json(): + # Update SDK cache (tool.json) + if should_update_tool_json() and not update_tool_json(): exit_with_error("Failed to retrieve SDK info") # Actions if action_arg == "build": diff --git a/Apps/TwoEleven/main/Source/TwoElevenUi.c b/Apps/TwoEleven/main/Source/TwoElevenUi.c index cd15459..9d7d319 100644 --- a/Apps/TwoEleven/main/Source/TwoElevenUi.c +++ b/Apps/TwoEleven/main/Source/TwoElevenUi.c @@ -154,10 +154,10 @@ static void game_play_event(lv_event_t * e) lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_active()); switch (dir) { case LV_DIR_TOP: - success = move_left(&(game_2048->score), game_2048->matrix_size, game_2048->matrix); + success = move_right(&(game_2048->score), game_2048->matrix_size, game_2048->matrix); break; case LV_DIR_BOTTOM: - success = move_right(&(game_2048->score), game_2048->matrix_size, game_2048->matrix); + success = move_left(&(game_2048->score), game_2048->matrix_size, game_2048->matrix); break; case LV_DIR_LEFT: success = move_up(&(game_2048->score), game_2048->matrix_size, game_2048->matrix); diff --git a/Apps/TwoEleven/manifest.properties b/Apps/TwoEleven/manifest.properties index 1ce7e24..f1ab83e 100644 --- a/Apps/TwoEleven/manifest.properties +++ b/Apps/TwoEleven/manifest.properties @@ -1,11 +1,11 @@ [manifest] version=0.1 [target] -sdk=0.7.0-SNAPSHOT2 -platforms=esp32,esp32s3 +sdk=0.7.0-dev +platforms=esp32,esp32s3,esp32c6,esp32p4 [app] id=one.tactility.twoeleven -versionName=0.2.0 -versionCode=2 +versionName=0.3.0 +versionCode=3 name=2048 -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). \ No newline at end of file +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). diff --git a/Apps/TwoEleven/tactility.py b/Apps/TwoEleven/tactility.py index 5d5581e..d4e0959 100644 --- a/Apps/TwoEleven/tactility.py +++ b/Apps/TwoEleven/tactility.py @@ -8,11 +8,12 @@ import time import urllib.request import zipfile +from dataclasses import dataclass import requests import tarfile ttbuild_path = ".tactility" -ttbuild_version = "2.5.0" +ttbuild_version = "3.0.0" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -20,20 +21,12 @@ use_local_sdk = False local_base_path = None -if sys.platform == "win32": - shell_color_red = "\033[91m" - shell_color_orange = "\033[93m" - shell_color_green = "\033[32m" - shell_color_purple = "\033[35m" - shell_color_cyan = "\033[36m" - shell_color_reset = "\033[m" -else: - shell_color_red = "\033[91m" - shell_color_orange = "\033[93m" - shell_color_green = "\033[32m" - shell_color_purple = "\033[35m" - shell_color_cyan = "\033[36m" - shell_color_reset = "\033[m" +shell_color_red = "\033[91m" +shell_color_orange = "\033[93m" +shell_color_green = "\033[32m" +shell_color_purple = "\033[35m" +shell_color_cyan = "\033[36m" +shell_color_reset = "\033[m" def print_help(): print("Usage: python tactility.py [action] [options]") @@ -115,7 +108,7 @@ def read_properties_file(path): #region SDK helpers def read_sdk_json(): - json_file_path = os.path.join(ttbuild_path, "sdk.json") + json_file_path = os.path.join(ttbuild_path, "tool.json") json_file = open(json_file_path) return json.load(json_file) @@ -148,17 +141,17 @@ def get_sdk_root_dir(version, platform): global ttbuild_cdn return os.path.join(ttbuild_path, f"{version}-{platform}") -def get_sdk_url(version, platform): +def get_sdk_url(version, file): global ttbuild_cdn - return f"{ttbuild_cdn}/TactilitySDK-{version}-{platform}.zip" + return f"{ttbuild_cdn}/sdk/{version}/{file}" def sdk_exists(version, platform): sdk_dir = get_sdk_dir(version, platform) return os.path.isdir(sdk_dir) -def should_update_sdk_json(): +def should_update_tool_json(): global ttbuild_cdn - json_filepath = os.path.join(ttbuild_path, "sdk.json") + json_filepath = os.path.join(ttbuild_path, "tool.json") if os.path.exists(json_filepath): json_modification_time = os.path.getmtime(json_filepath) now = time.time() @@ -168,10 +161,10 @@ def should_update_sdk_json(): else: return True -def update_sdk_json(): +def update_tool_json(): global ttbuild_cdn, ttbuild_path - json_url = f"{ttbuild_cdn}/sdk.json" - json_filepath = os.path.join(ttbuild_path, "sdk.json") + json_url = f"{ttbuild_cdn}/sdk/tool.json" + json_filepath = os.path.join(ttbuild_path, "tool.json") return download_file(json_url, json_filepath) def should_fetch_sdkconfig_files(platform_targets): @@ -206,16 +199,6 @@ def validate_environment(): elif use_local_sdk == True and os.environ.get("TACTILITY_SDK_PATH") is None: exit_with_error("local build was requested, but TACTILITY_SDK_PATH environment variable is not set.") -def validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build): - version_map = sdk_json["versions"] - if not sdk_version in version_map: - exit_with_error(f"Version not found: {sdk_version}") - version_data = version_map[sdk_version] - available_platforms = version_data["platforms"] - for desired_platform in platforms_to_build: - if not desired_platform in available_platforms: - exit_with_error(f"Platform {desired_platform} is not available. Available ones: {available_platforms}") - def validate_self(sdk_json): if not "toolVersion" in sdk_json: exit_with_error("Server returned invalid SDK data format (toolVersion not found)") @@ -287,15 +270,32 @@ def get_manifest_target_platforms(manifest, requested_platform): def sdk_download(version, platform): sdk_root_dir = get_sdk_root_dir(version, platform) os.makedirs(sdk_root_dir, exist_ok=True) - sdk_url = get_sdk_url(version, platform) - filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip") + sdk_index_url = get_sdk_url(version, "index.json") print(f"Downloading SDK version {version} for {platform}") - if download_file(sdk_url, filepath): - with zipfile.ZipFile(filepath, "r") as zip_ref: - zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK")) - return True - else: + sdk_index_filepath = os.path.join(sdk_root_dir, "index.json") + if verbose: + print(f"Downloading {sdk_index_url} to {sdk_index_filepath}") + if not download_file(sdk_index_url, sdk_index_filepath): + # TODO: 404 check, print a more accurate error + print_error(f"Failed to download SDK version {version}. Check your internet connection and make sure this release exists.") + return False + sdk_index_json_file = open(sdk_index_filepath) + sdk_index_json = json.load(sdk_index_json_file) + sdk_platforms = sdk_index_json["platforms"] + if not platform in sdk_platforms: + print_error(f"Platform {platform} not found in {sdk_platforms} for version {version}") return False + sdk_platform_file = sdk_platforms[platform] + sdk_zip_source_url = get_sdk_url(version, sdk_platform_file) + sdk_zip_target_filepath = os.path.join(sdk_root_dir, f"{version}-{platform}.zip") + if verbose: + print(f"Downloading {sdk_zip_source_url} to {sdk_zip_target_filepath}") + if not download_file(sdk_zip_source_url, sdk_zip_target_filepath): + print_error(f"Failed to download {sdk_zip_source_url} to {sdk_zip_target_filepath}") + return False + with zipfile.ZipFile(sdk_zip_target_filepath, "r") as zip_ref: + zip_ref.extractall(os.path.join(sdk_root_dir, "TactilitySDK")) + return True def sdk_download_all(version, platforms): for platform in platforms: @@ -378,7 +378,10 @@ def build_first(version, platform, skip_build): cmake_path = get_cmake_path(platform) print_status_busy(f"Building {platform} ELF") shell_needed = sys.platform == "win32" - with subprocess.Popen(["idf.py", "-B", cmake_path, "build"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: + build_command = ["idf.py", "-B", cmake_path, "build"] + if verbose: + print(f"Running command: {" ".join(build_command)}") + with subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: build_output = wait_for_process(process) # The return code is never expected to be 0 due to a bug in the elf cmake script, but we keep it just in case if process.returncode == 0: @@ -406,7 +409,10 @@ def build_consecutively(version, platform, skip_build): cmake_path = get_cmake_path(platform) print_status_busy(f"Building {platform} ELF") shell_needed = sys.platform == "win32" - with subprocess.Popen(["idf.py", "-B", cmake_path, "elf"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: + build_command = ["idf.py", "-B", cmake_path, "elf"] + if verbose: + print(f"Running command: {" ".join(build_command)}") + with subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: build_output = wait_for_process(process) if process.returncode == 0: print_status_success(f"Building {platform} ELF") @@ -494,12 +500,9 @@ def build_action(manifest, platform_arg): if not use_local_sdk: sdk_json = read_sdk_json() validate_self(sdk_json) - if not "versions" in sdk_json: - exit_with_error("Version data not found in sdk.json") # Build sdk_version = manifest["target"]["sdk"] if not use_local_sdk: - validate_version_and_platforms(sdk_json, sdk_version, platforms_to_build) if not sdk_download_all(sdk_version, platforms_to_build): exit_with_error("Failed to download one or more SDKs") if not build_all(sdk_version, platforms_to_build, skip_build): # Environment validation @@ -633,8 +636,8 @@ def uninstall_action(manifest, ip): manifest = read_manifest() validate_manifest(manifest) all_platform_targets = manifest["target"]["platforms"].split(",") - # Update SDK cache (sdk.json) - if should_update_sdk_json() and not update_sdk_json(): + # Update SDK cache (tool.json) + if should_update_tool_json() and not update_tool_json(): exit_with_error("Failed to retrieve SDK info") # Actions if action_arg == "build": diff --git a/Libraries/TactilityCpp/Include/TactilityCpp/Lock.h b/Libraries/TactilityCpp/Include/TactilityCpp/Lock.h deleted file mode 100644 index 0246752..0000000 --- a/Libraries/TactilityCpp/Include/TactilityCpp/Lock.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include - -class ScopedLock; - -/** Represents a lock/mutex */ -class Lock { - -public: - - virtual ~Lock() = default; - - virtual bool lock(TickType timeout) const = 0; - - bool lock() const { return lock(TT_MAX_TICKS); } - - virtual bool unlock() const = 0; - - ScopedLock asScopedLock() const; -}; - -/** - * Represents a lockable instance that is scoped to a specific lifecycle. - * Once the ScopedLock is destroyed, unlock() is called automatically. - * - * In other words: - * You have to lock() this object manually, but unlock() happens automatically on destruction. - */ -class ScopedLock final : public Lock { - - const Lock& lockable; - -public: - - using Lock::lock; - - explicit ScopedLock(const Lock& lockable) : lockable(lockable) {} - - ~ScopedLock() override { - lockable.unlock(); // We don't care whether it succeeded or not - } - - bool lock(TickType timeout) const override { - return lockable.lock(timeout); - } - - bool unlock() const override { - return lockable.unlock(); - } -}; diff --git a/Libraries/TactilityCpp/Include/TactilityCpp/LvglLock.h b/Libraries/TactilityCpp/Include/TactilityCpp/LvglLock.h index ac1854f..2e71ce6 100644 --- a/Libraries/TactilityCpp/Include/TactilityCpp/LvglLock.h +++ b/Libraries/TactilityCpp/Include/TactilityCpp/LvglLock.h @@ -1,21 +1,19 @@ #pragma once -#include +#include #include -class LvglLock final : public Lock { +class LvglLock final : public tt::Lock { public: - bool lock(TickType timeout = TT_MAX_TICKS) const override { - tt_lvgl_lock(timeout); - return true; + bool lock(TickType_t timeout = tt::kernel::MAX_TICKS) const override { + return tt_lvgl_lock(timeout); } - bool unlock() const override { + void unlock() const override { tt_lvgl_unlock(); - return true; } }; diff --git a/Libraries/TactilityCpp/Include/TactilityCpp/Mutex.h b/Libraries/TactilityCpp/Include/TactilityCpp/Mutex.h deleted file mode 100644 index 5b9846e..0000000 --- a/Libraries/TactilityCpp/Include/TactilityCpp/Mutex.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include -#include - -class Mutex final : public Lock { - - LockHandle handle; - -public: - - explicit Mutex(TtMutexType type) : handle(tt_lock_alloc_mutex(type)) {}; - - ~Mutex() override { - tt_lock_free(handle); - } - - bool lock(TickType timeout = TT_MAX_TICKS) const override { - return tt_lock_acquire(handle, timeout); - } - - bool unlock() const override { - return tt_lock_release(handle); - } -}; - - diff --git a/Libraries/TactilityCpp/Include/TactilityCpp/Thread.h b/Libraries/TactilityCpp/Include/TactilityCpp/Thread.h deleted file mode 100644 index d12e937..0000000 --- a/Libraries/TactilityCpp/Include/TactilityCpp/Thread.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once - -#include - -class Thread { - ThreadHandle handle; -public: - - Thread() : handle(tt_thread_alloc()) {} - - Thread( - const char* name, - uint32_t stackSize, - ThreadCallback callback, - void* _Nullable callbackContext - ) : handle(tt_thread_alloc_ext(name, stackSize, callback, callbackContext)) {} - - ~Thread() { - tt_thread_free(handle); - } - - void start() const { - tt_thread_start(handle); - } - - bool join(TickType timeout = TT_MAX_TICKS) const { - return tt_thread_join(handle, timeout); - } - - void setName(const char* name) const { - tt_thread_set_name(handle, name); - } - - void setStackSize(size_t stackSize) const { - tt_thread_set_stack_size(handle, stackSize); - } - - void setAffinity(int affinity) const { - tt_thread_set_affinity(handle, affinity); - } - - void setCallback(ThreadCallback callback, void* _Nullable callbackContext) const { - tt_thread_set_callback(handle, callback, callbackContext); - } - - void setPriority(ThreadPriority priority) const { - tt_thread_set_priority(handle, priority); - } - - void setStateCallback(ThreadStateCallback callback, void* _Nullable callbackContext) const { - tt_thread_set_state_callback(handle, callback, callbackContext); - } - - ThreadState getState() const { - return tt_thread_get_state(handle); - } - - ThreadId getId() const { - return tt_thread_get_id(handle); - } - - int32_t getReturnCode() const { - return tt_thread_get_return_code(handle); - } -}; diff --git a/Libraries/TactilityCpp/Include/TactilityCpp/Uart.h b/Libraries/TactilityCpp/Include/TactilityCpp/Uart.h index 5edc2ba..02f1dfa 100644 --- a/Libraries/TactilityCpp/Include/TactilityCpp/Uart.h +++ b/Libraries/TactilityCpp/Include/TactilityCpp/Uart.h @@ -3,6 +3,7 @@ #include #include #include +#include class Uart { UartHandle handle; @@ -44,15 +45,15 @@ class Uart { return tt_hal_uart_stop(handle); } - size_t readBytes(char* buffer, size_t bufferSize, TickType timeout) const { + size_t readBytes(char* buffer, size_t bufferSize, TickType_t timeout) const { return tt_hal_uart_read_bytes(handle, buffer, bufferSize, timeout); } - bool readByte(char* output, TickType timeout) const { + bool readByte(char* output, TickType_t timeout) const { return tt_hal_uart_read_bytes(handle, output, 1, timeout); } - size_t writeBytes(const char* buffer, size_t bufferSize, TickType timeout) const { + size_t writeBytes(const char* buffer, size_t bufferSize, TickType_t timeout) const { return tt_hal_uart_write_bytes(handle, buffer, bufferSize, timeout); } diff --git a/Libraries/TactilityCpp/Source/Lock.cpp b/Libraries/TactilityCpp/Source/Lock.cpp deleted file mode 100644 index 642fd7e..0000000 --- a/Libraries/TactilityCpp/Source/Lock.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include - -ScopedLock Lock::asScopedLock() const { - return ScopedLock(*this); -} - From f9e2a0d66d722c9a0edff0808191ee1e5325ae41 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 4 Jan 2026 00:30:20 +0100 Subject: [PATCH 02/11] Fix direction --- Apps/TwoEleven/main/Source/TwoElevenUi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Apps/TwoEleven/main/Source/TwoElevenUi.c b/Apps/TwoEleven/main/Source/TwoElevenUi.c index 9d7d319..6c447b4 100644 --- a/Apps/TwoEleven/main/Source/TwoElevenUi.c +++ b/Apps/TwoEleven/main/Source/TwoElevenUi.c @@ -177,10 +177,10 @@ static void game_play_event(lv_event_t * e) if (!game_2048->game_over) { switch (*((const uint8_t *) lv_event_get_param(e))) { case LV_KEY_UP: - success = move_left(&(game_2048->score), game_2048->matrix_size, game_2048->matrix); + success = move_right(&(game_2048->score), game_2048->matrix_size, game_2048->matrix); break; case LV_KEY_DOWN: - success = move_right(&(game_2048->score), game_2048->matrix_size, game_2048->matrix); + success = move_left(&(game_2048->score), game_2048->matrix_size, game_2048->matrix); break; case LV_KEY_LEFT: success = move_up(&(game_2048->score), game_2048->matrix_size, game_2048->matrix); From 6700a8230c00f6d5b958a4d8e42b74b8f1337a22 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 4 Jan 2026 00:45:43 +0100 Subject: [PATCH 03/11] Various fixes and removed Str library --- Apps/Calculator/main/CMakeLists.txt | 4 - Apps/Calculator/main/Source/Calculator.cpp | 21 +- Apps/Calculator/main/Source/Calculator.h | 6 +- Apps/Calculator/tactility.py | 12 +- Apps/Diceware/main/CMakeLists.txt | 4 - Apps/Diceware/tactility.py | 12 +- Apps/GPIO/main/CMakeLists.txt | 5 - Apps/GPIO/tactility.py | 12 +- Apps/GraphicsDemo/main/CMakeLists.txt | 4 +- Apps/GraphicsDemo/tactility.py | 12 +- Apps/HelloWorld/tactility.py | 22 +- Apps/SerialConsole/main/CMakeLists.txt | 5 - Apps/SerialConsole/tactility.py | 12 +- Apps/TwoEleven/main/CMakeLists.txt | 6 +- Apps/TwoEleven/tactility.py | 12 +- Libraries/Str/CMakeLists.txt | 15 - Libraries/Str/Include/Str.h | 618 --------------------- Libraries/Str/README.md | 11 - Libraries/Str/Source/Str.cpp | 2 - 19 files changed, 68 insertions(+), 727 deletions(-) delete mode 100644 Libraries/Str/CMakeLists.txt delete mode 100644 Libraries/Str/Include/Str.h delete mode 100644 Libraries/Str/README.md delete mode 100644 Libraries/Str/Source/Str.cpp diff --git a/Apps/Calculator/main/CMakeLists.txt b/Apps/Calculator/main/CMakeLists.txt index e9acb7b..0309010 100644 --- a/Apps/Calculator/main/CMakeLists.txt +++ b/Apps/Calculator/main/CMakeLists.txt @@ -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 ) diff --git a/Apps/Calculator/main/Source/Calculator.cpp b/Apps/Calculator/main/Source/Calculator.cpp index 88d56b7..956407a 100644 --- a/Apps/Calculator/main/Source/Calculator.cpp +++ b/Apps/Calculator/main/Source/Calculator.cpp @@ -4,6 +4,7 @@ #include #include #include +#include constexpr auto* TAG = "Calculator"; @@ -45,10 +46,10 @@ void Calculator::handleInput(const char* txt) { } } -std::deque Calculator::infixToRPN(const Str& infix) { +std::deque Calculator::infixToRPN(const std::string& infix) { std::stack opStack; - std::deque output; - Str token; + std::deque output; + std::string token; size_t i = 0; while (i < infix.length()) { @@ -56,20 +57,20 @@ std::deque Calculator::infixToRPN(const Str& infix) { if (isdigit(ch)) { token.clear(); - while (i < infix.length() && (isdigit(infix[i]) || infix[i] == '.')) { token.append(infix[i++]); } + while (i < infix.length() && (isdigit(infix[i]) || infix[i] == '.')) { token += infix[i++]; } output.push_back(token); continue; } if (ch == '(') { opStack.push(ch); } else if (ch == ')') { while (!opStack.empty() && opStack.top() != '(') { - output.push_back(Str(1, opStack.top())); + output.push_back(std::string(1, opStack.top())); opStack.pop(); } opStack.pop(); } else if (strchr("+-*/", ch)) { while (!opStack.empty() && precedence(opStack.top()) >= precedence(ch)) { - output.push_back(Str(1, opStack.top())); + output.push_back(std::string(1, opStack.top())); opStack.pop(); } opStack.push(ch); @@ -79,18 +80,18 @@ std::deque Calculator::infixToRPN(const Str& infix) { } while (!opStack.empty()) { - output.push_back(Str(1, opStack.top())); + output.push_back(std::string(1, opStack.top())); opStack.pop(); } return output; } -double Calculator::evaluateRPN(std::deque rpnQueue) { +double Calculator::evaluateRPN(std::deque rpnQueue) { std::stack values; while (!rpnQueue.empty()) { - Str token = rpnQueue.front(); + std::string token = rpnQueue.front(); rpnQueue.pop_front(); if (isdigit(token[0])) { @@ -132,7 +133,7 @@ void Calculator::evaluateExpression() { } double Calculator::computeFormula() { - return evaluateRPN(infixToRPN(Str(formulaBuffer))); + return evaluateRPN(infixToRPN(std::string(formulaBuffer))); } void Calculator::resetCalculator() { diff --git a/Apps/Calculator/main/Source/Calculator.h b/Apps/Calculator/main/Source/Calculator.h index 0881400..9aea097 100644 --- a/Apps/Calculator/main/Source/Calculator.h +++ b/Apps/Calculator/main/Source/Calculator.h @@ -4,7 +4,7 @@ #include #include -#include +#include #include class Calculator final : public App { @@ -18,8 +18,8 @@ class Calculator final : public App { void handleInput(const char* txt); void evaluateExpression(); double computeFormula(); - static std::deque infixToRPN(const Str& infix); - static double evaluateRPN(std::deque rpnQueue); + static std::deque infixToRPN(const std::string& infix); + static double evaluateRPN(std::deque rpnQueue); void resetCalculator(); public: diff --git a/Apps/Calculator/tactility.py b/Apps/Calculator/tactility.py index d4e0959..ab95f58 100644 --- a/Apps/Calculator/tactility.py +++ b/Apps/Calculator/tactility.py @@ -13,7 +13,7 @@ import tarfile ttbuild_path = ".tactility" -ttbuild_version = "3.0.0" +ttbuild_version = "3.1.0" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -109,8 +109,8 @@ def read_properties_file(path): def read_sdk_json(): json_file_path = os.path.join(ttbuild_path, "tool.json") - json_file = open(json_file_path) - return json.load(json_file) + with open(json_file_path) as json_file: + return json.load(json_file) def get_sdk_dir(version, platform): global use_local_sdk, local_base_path @@ -279,10 +279,10 @@ def sdk_download(version, platform): # TODO: 404 check, print a more accurate error print_error(f"Failed to download SDK version {version}. Check your internet connection and make sure this release exists.") return False - sdk_index_json_file = open(sdk_index_filepath) - sdk_index_json = json.load(sdk_index_json_file) + with open(sdk_index_filepath) as sdk_index_json_file: + sdk_index_json = json.load(sdk_index_json_file) sdk_platforms = sdk_index_json["platforms"] - if not platform in sdk_platforms: + if platform not in sdk_platforms: print_error(f"Platform {platform} not found in {sdk_platforms} for version {version}") return False sdk_platform_file = sdk_platforms[platform] diff --git a/Apps/Diceware/main/CMakeLists.txt b/Apps/Diceware/main/CMakeLists.txt index c413328..0f54d39 100644 --- a/Apps/Diceware/main/CMakeLists.txt +++ b/Apps/Diceware/main/CMakeLists.txt @@ -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 ) diff --git a/Apps/Diceware/tactility.py b/Apps/Diceware/tactility.py index d4e0959..ab95f58 100644 --- a/Apps/Diceware/tactility.py +++ b/Apps/Diceware/tactility.py @@ -13,7 +13,7 @@ import tarfile ttbuild_path = ".tactility" -ttbuild_version = "3.0.0" +ttbuild_version = "3.1.0" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -109,8 +109,8 @@ def read_properties_file(path): def read_sdk_json(): json_file_path = os.path.join(ttbuild_path, "tool.json") - json_file = open(json_file_path) - return json.load(json_file) + with open(json_file_path) as json_file: + return json.load(json_file) def get_sdk_dir(version, platform): global use_local_sdk, local_base_path @@ -279,10 +279,10 @@ def sdk_download(version, platform): # TODO: 404 check, print a more accurate error print_error(f"Failed to download SDK version {version}. Check your internet connection and make sure this release exists.") return False - sdk_index_json_file = open(sdk_index_filepath) - sdk_index_json = json.load(sdk_index_json_file) + with open(sdk_index_filepath) as sdk_index_json_file: + sdk_index_json = json.load(sdk_index_json_file) sdk_platforms = sdk_index_json["platforms"] - if not platform in sdk_platforms: + if platform not in sdk_platforms: print_error(f"Platform {platform} not found in {sdk_platforms} for version {version}") return False sdk_platform_file = sdk_platforms[platform] diff --git a/Apps/GPIO/main/CMakeLists.txt b/Apps/GPIO/main/CMakeLists.txt index c22595b..0f54d39 100644 --- a/Apps/GPIO/main/CMakeLists.txt +++ b/Apps/GPIO/main/CMakeLists.txt @@ -1,16 +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** - ../../../Libraries/TactilityCpp/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 ) diff --git a/Apps/GPIO/tactility.py b/Apps/GPIO/tactility.py index d4e0959..ab95f58 100644 --- a/Apps/GPIO/tactility.py +++ b/Apps/GPIO/tactility.py @@ -13,7 +13,7 @@ import tarfile ttbuild_path = ".tactility" -ttbuild_version = "3.0.0" +ttbuild_version = "3.1.0" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -109,8 +109,8 @@ def read_properties_file(path): def read_sdk_json(): json_file_path = os.path.join(ttbuild_path, "tool.json") - json_file = open(json_file_path) - return json.load(json_file) + with open(json_file_path) as json_file: + return json.load(json_file) def get_sdk_dir(version, platform): global use_local_sdk, local_base_path @@ -279,10 +279,10 @@ def sdk_download(version, platform): # TODO: 404 check, print a more accurate error print_error(f"Failed to download SDK version {version}. Check your internet connection and make sure this release exists.") return False - sdk_index_json_file = open(sdk_index_filepath) - sdk_index_json = json.load(sdk_index_json_file) + with open(sdk_index_filepath) as sdk_index_json_file: + sdk_index_json = json.load(sdk_index_json_file) sdk_platforms = sdk_index_json["platforms"] - if not platform in sdk_platforms: + if platform not in sdk_platforms: print_error(f"Platform {platform} not found in {sdk_platforms} for version {version}") return False sdk_platform_file = sdk_platforms[platform] diff --git a/Apps/GraphicsDemo/main/CMakeLists.txt b/Apps/GraphicsDemo/main/CMakeLists.txt index 759aed7..e8bdcd6 100644 --- a/Apps/GraphicsDemo/main/CMakeLists.txt +++ b/Apps/GraphicsDemo/main/CMakeLists.txt @@ -2,6 +2,8 @@ file(GLOB_RECURSE SOURCE_FILES Source/*.c*) idf_component_register( SRC_DIRS "Source" - INCLUDE_DIRS "Include" + # Library headers must be included directly, + # because all regular dependencies get stripped by elf_loader's cmake script + INCLUDE_DIRS "Include" "../../../Libraries/TactilityCpp/Include" REQUIRES TactilitySDK ) diff --git a/Apps/GraphicsDemo/tactility.py b/Apps/GraphicsDemo/tactility.py index d4e0959..ab95f58 100644 --- a/Apps/GraphicsDemo/tactility.py +++ b/Apps/GraphicsDemo/tactility.py @@ -13,7 +13,7 @@ import tarfile ttbuild_path = ".tactility" -ttbuild_version = "3.0.0" +ttbuild_version = "3.1.0" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -109,8 +109,8 @@ def read_properties_file(path): def read_sdk_json(): json_file_path = os.path.join(ttbuild_path, "tool.json") - json_file = open(json_file_path) - return json.load(json_file) + with open(json_file_path) as json_file: + return json.load(json_file) def get_sdk_dir(version, platform): global use_local_sdk, local_base_path @@ -279,10 +279,10 @@ def sdk_download(version, platform): # TODO: 404 check, print a more accurate error print_error(f"Failed to download SDK version {version}. Check your internet connection and make sure this release exists.") return False - sdk_index_json_file = open(sdk_index_filepath) - sdk_index_json = json.load(sdk_index_json_file) + with open(sdk_index_filepath) as sdk_index_json_file: + sdk_index_json = json.load(sdk_index_json_file) sdk_platforms = sdk_index_json["platforms"] - if not platform in sdk_platforms: + if platform not in sdk_platforms: print_error(f"Platform {platform} not found in {sdk_platforms} for version {version}") return False sdk_platform_file = sdk_platforms[platform] diff --git a/Apps/HelloWorld/tactility.py b/Apps/HelloWorld/tactility.py index 75b132c..ab95f58 100644 --- a/Apps/HelloWorld/tactility.py +++ b/Apps/HelloWorld/tactility.py @@ -13,7 +13,7 @@ import tarfile ttbuild_path = ".tactility" -ttbuild_version = "3.0.0" +ttbuild_version = "3.1.0" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -109,8 +109,8 @@ def read_properties_file(path): def read_sdk_json(): json_file_path = os.path.join(ttbuild_path, "tool.json") - json_file = open(json_file_path) - return json.load(json_file) + with open(json_file_path) as json_file: + return json.load(json_file) def get_sdk_dir(version, platform): global use_local_sdk, local_base_path @@ -279,10 +279,10 @@ def sdk_download(version, platform): # TODO: 404 check, print a more accurate error print_error(f"Failed to download SDK version {version}. Check your internet connection and make sure this release exists.") return False - sdk_index_json_file = open(sdk_index_filepath) - sdk_index_json = json.load(sdk_index_json_file) + with open(sdk_index_filepath) as sdk_index_json_file: + sdk_index_json = json.load(sdk_index_json_file) sdk_platforms = sdk_index_json["platforms"] - if not platform in sdk_platforms: + if platform not in sdk_platforms: print_error(f"Platform {platform} not found in {sdk_platforms} for version {version}") return False sdk_platform_file = sdk_platforms[platform] @@ -378,7 +378,10 @@ def build_first(version, platform, skip_build): cmake_path = get_cmake_path(platform) print_status_busy(f"Building {platform} ELF") shell_needed = sys.platform == "win32" - with subprocess.Popen(["idf.py", "-B", cmake_path, "build"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: + build_command = ["idf.py", "-B", cmake_path, "build"] + if verbose: + print(f"Running command: {" ".join(build_command)}") + with subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: build_output = wait_for_process(process) # The return code is never expected to be 0 due to a bug in the elf cmake script, but we keep it just in case if process.returncode == 0: @@ -406,7 +409,10 @@ def build_consecutively(version, platform, skip_build): cmake_path = get_cmake_path(platform) print_status_busy(f"Building {platform} ELF") shell_needed = sys.platform == "win32" - with subprocess.Popen(["idf.py", "-B", cmake_path, "elf"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: + build_command = ["idf.py", "-B", cmake_path, "elf"] + if verbose: + print(f"Running command: {" ".join(build_command)}") + with subprocess.Popen(build_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell_needed) as process: build_output = wait_for_process(process) if process.returncode == 0: print_status_success(f"Building {platform} ELF") diff --git a/Apps/SerialConsole/main/CMakeLists.txt b/Apps/SerialConsole/main/CMakeLists.txt index c22595b..0f54d39 100644 --- a/Apps/SerialConsole/main/CMakeLists.txt +++ b/Apps/SerialConsole/main/CMakeLists.txt @@ -1,16 +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** - ../../../Libraries/TactilityCpp/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 ) diff --git a/Apps/SerialConsole/tactility.py b/Apps/SerialConsole/tactility.py index d4e0959..ab95f58 100644 --- a/Apps/SerialConsole/tactility.py +++ b/Apps/SerialConsole/tactility.py @@ -13,7 +13,7 @@ import tarfile ttbuild_path = ".tactility" -ttbuild_version = "3.0.0" +ttbuild_version = "3.1.0" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -109,8 +109,8 @@ def read_properties_file(path): def read_sdk_json(): json_file_path = os.path.join(ttbuild_path, "tool.json") - json_file = open(json_file_path) - return json.load(json_file) + with open(json_file_path) as json_file: + return json.load(json_file) def get_sdk_dir(version, platform): global use_local_sdk, local_base_path @@ -279,10 +279,10 @@ def sdk_download(version, platform): # TODO: 404 check, print a more accurate error print_error(f"Failed to download SDK version {version}. Check your internet connection and make sure this release exists.") return False - sdk_index_json_file = open(sdk_index_filepath) - sdk_index_json = json.load(sdk_index_json_file) + with open(sdk_index_filepath) as sdk_index_json_file: + sdk_index_json = json.load(sdk_index_json_file) sdk_platforms = sdk_index_json["platforms"] - if not platform in sdk_platforms: + if platform not in sdk_platforms: print_error(f"Platform {platform} not found in {sdk_platforms} for version {version}") return False sdk_platform_file = sdk_platforms[platform] diff --git a/Apps/TwoEleven/main/CMakeLists.txt b/Apps/TwoEleven/main/CMakeLists.txt index 08cb55b..0309010 100644 --- a/Apps/TwoEleven/main/CMakeLists.txt +++ b/Apps/TwoEleven/main/CMakeLists.txt @@ -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 -) \ No newline at end of file +) diff --git a/Apps/TwoEleven/tactility.py b/Apps/TwoEleven/tactility.py index d4e0959..ab95f58 100644 --- a/Apps/TwoEleven/tactility.py +++ b/Apps/TwoEleven/tactility.py @@ -13,7 +13,7 @@ import tarfile ttbuild_path = ".tactility" -ttbuild_version = "3.0.0" +ttbuild_version = "3.1.0" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -109,8 +109,8 @@ def read_properties_file(path): def read_sdk_json(): json_file_path = os.path.join(ttbuild_path, "tool.json") - json_file = open(json_file_path) - return json.load(json_file) + with open(json_file_path) as json_file: + return json.load(json_file) def get_sdk_dir(version, platform): global use_local_sdk, local_base_path @@ -279,10 +279,10 @@ def sdk_download(version, platform): # TODO: 404 check, print a more accurate error print_error(f"Failed to download SDK version {version}. Check your internet connection and make sure this release exists.") return False - sdk_index_json_file = open(sdk_index_filepath) - sdk_index_json = json.load(sdk_index_json_file) + with open(sdk_index_filepath) as sdk_index_json_file: + sdk_index_json = json.load(sdk_index_json_file) sdk_platforms = sdk_index_json["platforms"] - if not platform in sdk_platforms: + if platform not in sdk_platforms: print_error(f"Platform {platform} not found in {sdk_platforms} for version {version}") return False sdk_platform_file = sdk_platforms[platform] diff --git a/Libraries/Str/CMakeLists.txt b/Libraries/Str/CMakeLists.txt deleted file mode 100644 index ac84507..0000000 --- a/Libraries/Str/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 3.20) - -set(CMAKE_CXX_STANDARD 23) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - -file(GLOB SOURCES "Source/*.c*") -file(GLOB HEADERS "Include/*.h*") - -add_library(Str STATIC) - -target_sources(Str PRIVATE ${SOURCES}) -include_directories(Str "Include/") -target_include_directories(Str PUBLIC "Include/") - diff --git a/Libraries/Str/Include/Str.h b/Libraries/Str/Include/Str.h deleted file mode 100644 index c5c022a..0000000 --- a/Libraries/Str/Include/Str.h +++ /dev/null @@ -1,618 +0,0 @@ -// Str v0.33 -// Simple C++ string type with an optional local buffer, by Omar Cornut -// https://github.com/ocornut/str - -// LICENSE -// This software is in the public domain. Where that dedication is not -// recognized, you are granted a perpetual, irrevocable license to copy, -// distribute, and modify this file as you see fit. - -// USAGE -// Include this file in whatever places need to refer to it. -// In ONE .cpp file, write '#define STR_IMPLEMENTATION' before the #include of this file. -// This expands out the actual implementation into that C/C++ file. - - -/* -- This isn't a fully featured string class. -- It is a simple, bearable replacement to std::string that isn't heap abusive nor bloated (can actually be debugged by humans). -- String are mutable. We don't maintain size so length() is not-constant time. -- Maximum string size currently limited to 2 MB (we allocate 21 bits to hold capacity). -- Local buffer size is currently limited to 1023 bytes (we allocate 10 bits to hold local buffer size). -- In "non-owned" mode for literals/reference we don't do any tracking/counting of references. -- Overhead is 8-bytes in 32-bits, 16-bytes in 64-bits (12 + alignment). -- This code hasn't been tested very much. it is probably incomplete or broken. Made it for my own use. - -The idea is that you can provide an arbitrary sized local buffer if you expect string to fit -most of the time, and then you avoid using costly heap. - -No local buffer, always use heap, sizeof()==8~16 (depends if your pointers are 32-bits or 64-bits) - - Str s = "hey"; - -With a local buffer of 16 bytes, sizeof() == 8~16 + 16 bytes. - - Str16 s = "filename.h"; // copy into local buffer - Str16 s = "long_filename_not_very_long_but_longer_than_expected.h"; // use heap - -With a local buffer of 256 bytes, sizeof() == 8~16 + 256 bytes. - - Str256 s = "long_filename_not_very_long_but_longer_than_expected.h"; // copy into local buffer - -Common sizes are defined at the bottom of Str.h, you may define your own. - -Functions: - - Str256 s; - s.set("hello sailor"); // set (copy) - s.setf("%s/%s.tmp", folder, filename); // set (w/format) - s.append("hello"); // append. cost a length() calculation! - s.appendf("hello %d", 42); // append (w/format). cost a length() calculation! - s.set_ref("Hey!"); // set (literal/reference, just copy pointer, no tracking) - -Constructor helper for format string: add a trailing 'f' to the type. Underlying type is the same. - - Str256f filename("%s/%s.tmp", folder, filename); // construct (w/format) - fopen(Str256f("%s/%s.tmp, folder, filename).c_str(), "rb"); // construct (w/format), use as function param, destruct - -Constructor helper for reference/literal: - - StrRef ref("literal"); // copy pointer, no allocation, no string copy - StrRef ref2(GetDebugName()); // copy pointer. no tracking of anything whatsoever, know what you are doing! - -All StrXXX types derives from Str and instance hold the local buffer capacity. So you can pass e.g. Str256* to a function taking base type Str* and it will be functional. - - void MyFunc(Str& s) { s = "Hello"; } // will use local buffer if available in Str instance - -(Using a template e.g. Str we could remove the LocalBufSize storage but it would make passing typed Str<> to functions tricky. - Instead we don't use template so you can pass them around as the base type Str*. Also, templates are ugly.) -*/ - -/* - CHANGELOG - 0.33 - fixed capacity() return value to match standard. e.g. a Str256's capacity() now returns 255, not 256. - 0.32 - added owned() accessor. - 0.31 - fixed various warnings. - 0.30 - turned into a single header file, removed Str.cpp. - 0.29 - fixed bug when calling reserve on non-owned strings (ie. when using StrRef or set_ref), and fixed include. - 0.28 - breaking change: replaced Str32 by Str30 to avoid collision with Str32 from MacTypes.h . - 0.27 - added STR_API and basic .natvis file. - 0.26 - fixed set(cont char* src, const char* src_end) writing null terminator to the wrong position. - 0.25 - allow set(const char* NULL) or operator= NULL to clear the string. note that set() from range or other types are not allowed. - 0.24 - allow set_ref(const char* NULL) to clear the string. include fixes for linux. - 0.23 - added append(char). added append_from(int idx, XXX) functions. fixed some compilers warnings. - 0.22 - documentation improvements, comments. fixes for some compilers. - 0.21 - added StrXXXf() constructor to construct directly from a format string. -*/ - -/* -TODO -- Since we lose 4-bytes of padding on 64-bits architecture, perhaps just spread the header to 8-bytes and lift size limits? -- More functions/helpers. -*/ - -#ifndef STR_INCLUDED -#define STR_INCLUDED - -//------------------------------------------------------------------------- -// CONFIGURATION -//------------------------------------------------------------------------- - -#ifndef STR_MEMALLOC -#define STR_MEMALLOC malloc -#include -#endif -#ifndef STR_MEMFREE -#define STR_MEMFREE free -#include -#endif -#ifndef STR_ASSERT -#define STR_ASSERT assert -#include -#endif -#ifndef STR_API -#define STR_API -#endif -#include // for va_list -#include // for strlen, strcmp, memcpy, etc. - -// Configuration: #define STR_DEFINE_STR32 1 to keep defining Str32/Str32f, but be warned: on macOS/iOS, MacTypes.h also defines a type named Str32. -#ifndef STR_DEFINE_STR32 -#define STR_DEFINE_STR32 0 -#endif - -//------------------------------------------------------------------------- -// HEADERS -//------------------------------------------------------------------------- - -// This is the base class that you can pass around -// Footprint is 8-bytes (32-bits arch) or 16-bytes (64-bits arch) -class STR_API Str -{ - char* Data; // Point to LocalBuf() or heap allocated - int Capacity : 21; // Max 2 MB. Exclude zero terminator. - int LocalBufSize : 10; // Max 1023 bytes - unsigned int Owned : 1; // Set when we have ownership of the pointed data (most common, unless using set_ref() method or StrRef constructor) - -public: - inline char* c_str() { return Data; } - inline const char* c_str() const { return Data; } - inline bool empty() const { return Data[0] == 0; } - inline int length() const { return (int)strlen(Data); } // by design, allow user to write into the buffer at any time - inline int capacity() const { return Capacity; } - inline bool owned() const { return Owned ? true : false; } - - inline void set_ref(const char* src); - int setf(const char* fmt, ...); - int setfv(const char* fmt, va_list args); - int setf_nogrow(const char* fmt, ...); - int setfv_nogrow(const char* fmt, va_list args); - int append(char c); - int append(const char* s, const char* s_end = NULL); - int appendf(const char* fmt, ...); - int appendfv(const char* fmt, va_list args); - int append_from(int idx, char c); - int append_from(int idx, const char* s, const char* s_end = NULL); // If you know the string length or want to append from a certain point - int appendf_from(int idx, const char* fmt, ...); - int appendfv_from(int idx, const char* fmt, va_list args); - - void clear(); - void reserve(int cap); - void reserve_discard(int cap); - void shrink_to_fit(); - - inline char& operator[](size_t i) { return Data[i]; } - inline char operator[](size_t i) const { return Data[i]; } - //explicit operator const char*() const{ return Data; } - - inline Str(); - inline Str(const char* rhs); - inline void set(const char* src); - inline void set(const char* src, const char* src_end); - inline Str& operator=(const char* rhs) { set(rhs); return *this; } - inline bool operator==(const char* rhs) const { return strcmp(c_str(), rhs) == 0; } - - inline Str(const Str& rhs); - inline void set(const Str& src); - inline void set(int count, char character); - inline Str& operator=(const Str& rhs) { set(rhs); return *this; } - inline bool operator==(const Str& rhs) const { return strcmp(c_str(), rhs.c_str()) == 0; } - - inline Str(int amount, char character); - - // Destructor for all variants - inline ~Str() - { - if (Owned && !is_using_local_buf()) - STR_MEMFREE(Data); - } - - static char* EmptyBuffer; - -protected: - inline char* local_buf() { return (char*)this + sizeof(Str); } - inline const char* local_buf() const { return (char*)this + sizeof(Str); } - inline bool is_using_local_buf() const { return Data == local_buf() && LocalBufSize != 0; } - - // Constructor for StrXXX variants with local buffer - Str(unsigned short local_buf_size) - { - STR_ASSERT(local_buf_size < 1024); - Data = local_buf(); - Data[0] = '\0'; - Capacity = local_buf_size ? local_buf_size - 1 : 0; - LocalBufSize = local_buf_size; - Owned = 1; - } -}; - -void Str::set(const char* src) -{ - // We allow set(NULL) or via = operator to clear the string. - if (src == NULL) - { - clear(); - return; - } - int buf_len = (int)strlen(src); - if (Capacity < buf_len) - reserve_discard(buf_len); - memcpy(Data, src, (size_t)(buf_len + 1)); - Owned = 1; -} - -void Str::set(const char* src, const char* src_end) -{ - STR_ASSERT(src != NULL && src_end >= src); - int buf_len = (int)(src_end - src); - if ((int)Capacity < buf_len) - reserve_discard(buf_len); - memcpy(Data, src, (size_t)buf_len); - Data[buf_len] = 0; - Owned = 1; -} - -void Str::set(const Str& src) -{ - int buf_len = (int)strlen(src.c_str()); - if ((int)Capacity < buf_len) - reserve_discard(buf_len); - memcpy(Data, src.c_str(), (size_t)(buf_len + 1)); - Owned = 1; -} - -void Str::set(int count, char character) { - int buf_len = count + 1; - if ((int)Capacity < buf_len) - reserve_discard(buf_len); - memset(Data, character, count); - Data[count] = 0; - Owned = 1; -} - -inline void Str::set_ref(const char* src) -{ - if (Owned && !is_using_local_buf()) - STR_MEMFREE(Data); - Data = src ? (char*)src : EmptyBuffer; - Capacity = 0; - Owned = 0; -} - -Str::Str() -{ - Data = EmptyBuffer; // Shared READ-ONLY initial buffer for 0 capacity - Capacity = 0; - LocalBufSize = 0; - Owned = 0; -} - -Str::Str(const Str& rhs) : Str() -{ - set(rhs); -} - -Str::Str(const char* rhs) : Str() -{ - set(rhs); -} - -Str::Str(int amount, char character) : Str() { - set(amount, character); -} - -// Literal/reference string -class StrRef : public Str -{ -public: - StrRef(const char* s) : Str() { set_ref(s); } -}; - -#define STR_DEFINETYPE(TYPENAME, LOCALBUFSIZE) \ -class TYPENAME : public Str \ -{ \ - char local_buf[LOCALBUFSIZE]; \ -public: \ - TYPENAME() : Str(LOCALBUFSIZE) {} \ - TYPENAME(const Str& rhs) : Str(LOCALBUFSIZE) { set(rhs); } \ - TYPENAME(const char* rhs) : Str(LOCALBUFSIZE) { set(rhs); } \ - TYPENAME(const TYPENAME& rhs) : Str(LOCALBUFSIZE) { set(rhs); } \ - TYPENAME& operator=(const char* rhs) { set(rhs); return *this; } \ - TYPENAME& operator=(const Str& rhs) { set(rhs); return *this; } \ - TYPENAME& operator=(const TYPENAME& rhs) { set(rhs); return *this; } \ -}; - -// Disable PVS-Studio warning V730: Not all members of a class are initialized inside the constructor (local_buf is not initialized and that is fine) -// -V:STR_DEFINETYPE:730 - -// Helper to define StrXXXf constructors -#define STR_DEFINETYPE_F(TYPENAME, TYPENAME_F) \ -class TYPENAME_F : public TYPENAME \ -{ \ -public: \ - TYPENAME_F(const char* fmt, ...) : TYPENAME() { va_list args; va_start(args, fmt); setfv(fmt, args); va_end(args); } \ -}; - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-private-field" // warning : private field 'local_buf' is not used -#endif - -// Declaring types for common sizes here -STR_DEFINETYPE(Str16, 16) -STR_DEFINETYPE(Str30, 30) -STR_DEFINETYPE(Str64, 64) -STR_DEFINETYPE(Str128, 128) -STR_DEFINETYPE(Str256, 256) -STR_DEFINETYPE(Str512, 512) - -// Declaring helper constructors to pass in format strings in one statement -STR_DEFINETYPE_F(Str16, Str16f) -STR_DEFINETYPE_F(Str30, Str30f) -STR_DEFINETYPE_F(Str64, Str64f) -STR_DEFINETYPE_F(Str128, Str128f) -STR_DEFINETYPE_F(Str256, Str256f) -STR_DEFINETYPE_F(Str512, Str512f) - -#if STR_DEFINE_STR32 -STR_DEFINETYPE(Str32, 32) -STR_DEFINETYPE_F(Str32, Str32f) -#endif - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#endif // #ifndef STR_INCLUDED - -//------------------------------------------------------------------------- -// IMPLEMENTATION -//------------------------------------------------------------------------- - -#ifdef STR_IMPLEMENTATION - -#include // for vsnprintf - -// On some platform vsnprintf() takes va_list by reference and modifies it. -// va_copy is the 'correct' way to copy a va_list but Visual Studio prior to 2013 doesn't have it. -#ifndef va_copy -#define va_copy(dest, src) (dest = src) -#endif - -// Static empty buffer we can point to for empty strings -// Pointing to a literal increases the like-hood of getting a crash if someone attempts to write in the empty string buffer. -char* Str::EmptyBuffer = (char*)"\0NULL"; - -// Clear -void Str::clear() -{ - if (Owned && !is_using_local_buf()) - STR_MEMFREE(Data); - if (LocalBufSize) - { - Data = local_buf(); - Data[0] = '\0'; - Capacity = LocalBufSize - 1; - Owned = 1; - } - else - { - Data = EmptyBuffer; - Capacity = 0; - Owned = 0; - } -} - -// Reserve memory, preserving the current of the buffer -// Capacity doesn't include the zero terminator, so reserve(5) is enough to store "hello". -void Str::reserve(int new_capacity) -{ - if (new_capacity <= Capacity) - return; - - char* new_data; - if (new_capacity <= LocalBufSize - 1) - { - // Disowned -> LocalBuf - new_data = local_buf(); - new_capacity = LocalBufSize - 1; - } - else - { - // Disowned or LocalBuf -> Heap - new_data = (char*)STR_MEMALLOC((size_t)(new_capacity + 1) * sizeof(char)); - } - - // string in Data might be longer than new_capacity if it wasn't owned, don't copy too much -#ifdef _MSC_VER - strncpy_s(new_data, (size_t)new_capacity + 1, Data, (size_t)new_capacity); -#else - strncpy(new_data, Data, (size_t)new_capacity); -#endif - new_data[new_capacity] = 0; - - if (Owned && !is_using_local_buf()) - STR_MEMFREE(Data); - - Data = new_data; - Capacity = new_capacity; - Owned = 1; -} - -// Reserve memory, discarding the current of the buffer (if we expect to be fully rewritten) -void Str::reserve_discard(int new_capacity) -{ - if (new_capacity <= Capacity) - return; - - if (Owned && !is_using_local_buf()) - STR_MEMFREE(Data); - - if (new_capacity <= LocalBufSize - 1) - { - // Disowned -> LocalBuf - Data = local_buf(); - Capacity = LocalBufSize - 1; - } - else - { - // Disowned or LocalBuf -> Heap - Data = (char*)STR_MEMALLOC((size_t)(new_capacity + 1) * sizeof(char)); - Capacity = new_capacity; - } - Owned = 1; -} - -void Str::shrink_to_fit() -{ - if (!Owned || is_using_local_buf()) - return; - int new_capacity = length(); - if (Capacity <= new_capacity) - return; - - char* new_data = (char*)STR_MEMALLOC((size_t)(new_capacity + 1) * sizeof(char)); - memcpy(new_data, Data, (size_t)(new_capacity + 1)); - STR_MEMFREE(Data); - Data = new_data; - Capacity = new_capacity; -} - -// FIXME: merge setfv() and appendfv()? -int Str::setfv(const char* fmt, va_list args) -{ - // Needed for portability on platforms where va_list are passed by reference and modified by functions - va_list args2; - va_copy(args2, args); - - // MSVC returns -1 on overflow when writing, which forces us to do two passes - // FIXME-OPT: Find a way around that. -#ifdef _MSC_VER - int len = vsnprintf(NULL, 0, fmt, args); - STR_ASSERT(len >= 0); - - if (Capacity < len) - reserve_discard(len); - len = vsnprintf(Data, (size_t)len + 1, fmt, args2); -#else - // First try - int len = vsnprintf(Owned ? Data : NULL, Owned ? (size_t)(Capacity + 1): 0, fmt, args); - STR_ASSERT(len >= 0); - - if (Capacity < len) - { - reserve_discard(len); - len = vsnprintf(Data, (size_t)len + 1, fmt, args2); - } -#endif - - STR_ASSERT(Owned); - return len; -} - -int Str::setf(const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - int len = setfv(fmt, args); - va_end(args); - return len; -} - -int Str::setfv_nogrow(const char* fmt, va_list args) -{ - STR_ASSERT(Owned); - - if (Capacity == 0) - return 0; - - int w = vsnprintf(Data, (size_t)(Capacity + 1), fmt, args); - Data[Capacity] = 0; - Owned = 1; - return (w == -1) ? Capacity : w; -} - -int Str::setf_nogrow(const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - int len = setfv_nogrow(fmt, args); - va_end(args); - return len; -} - -int Str::append_from(int idx, char c) -{ - int add_len = 1; - if (Capacity < idx + add_len) - reserve(idx + add_len); - Data[idx] = c; - Data[idx + add_len] = 0; - STR_ASSERT(Owned); - return add_len; -} - -int Str::append_from(int idx, const char* s, const char* s_end) -{ - if (!s_end) - s_end = s + strlen(s); - int add_len = (int)(s_end - s); - if (Capacity < idx + add_len) - reserve(idx + add_len); - memcpy(Data + idx, (const void*)s, (size_t)add_len); - Data[idx + add_len] = 0; // Our source data isn't necessarily zero terminated - STR_ASSERT(Owned); - return add_len; -} - -// FIXME: merge setfv() and appendfv()? -int Str::appendfv_from(int idx, const char* fmt, va_list args) -{ - // Needed for portability on platforms where va_list are passed by reference and modified by functions - va_list args2; - va_copy(args2, args); - - // MSVC returns -1 on overflow when writing, which forces us to do two passes - // FIXME-OPT: Find a way around that. -#ifdef _MSC_VER - int add_len = vsnprintf(NULL, 0, fmt, args); - STR_ASSERT(add_len >= 0); - - if (Capacity < idx + add_len) - reserve(idx + add_len); - add_len = vsnprintf(Data + idx, add_len + 1, fmt, args2); -#else - // First try - int add_len = vsnprintf(Owned ? Data + idx : NULL, Owned ? (size_t)(Capacity + 1 - idx) : 0, fmt, args); - STR_ASSERT(add_len >= 0); - - if (Capacity < idx + add_len) - { - reserve(idx + add_len); - add_len = vsnprintf(Data + idx, (size_t)add_len + 1, fmt, args2); - } -#endif - - STR_ASSERT(Owned); - return add_len; -} - -int Str::appendf_from(int idx, const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - int len = appendfv_from(idx, fmt, args); - va_end(args); - return len; -} - -int Str::append(char c) -{ - int cur_len = length(); - return append_from(cur_len, c); -} - -int Str::append(const char* s, const char* s_end) -{ - int cur_len = length(); - return append_from(cur_len, s, s_end); -} - -int Str::appendfv(const char* fmt, va_list args) -{ - int cur_len = length(); - return appendfv_from(cur_len, fmt, args); -} - -int Str::appendf(const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - int len = appendfv(fmt, args); - va_end(args); - return len; -} - -#endif // #define STR_IMPLEMENTATION - -//------------------------------------------------------------------------- diff --git a/Libraries/Str/README.md b/Libraries/Str/README.md deleted file mode 100644 index eeaaf1c..0000000 --- a/Libraries/Str/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Str - -Simple C++ string type with an optional local buffer, by Omar Cornut -https://github.com/ocornut/str - -**LICENSE** - -This software is in the public domain. Where that dedication is not -recognized, you are granted a perpetual, irrevocable license to copy, -distribute, and modify this file as you see fit. - diff --git a/Libraries/Str/Source/Str.cpp b/Libraries/Str/Source/Str.cpp deleted file mode 100644 index 78bcabe..0000000 --- a/Libraries/Str/Source/Str.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#define STR_IMPLEMENTATION -#include "Str.h" From 83221e7c7057ff5f5f50d0eeb52fc676cc246672 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 4 Jan 2026 00:54:17 +0100 Subject: [PATCH 04/11] Remove unused import --- Apps/Calculator/tactility.py | 1 - Apps/Diceware/tactility.py | 1 - Apps/GPIO/tactility.py | 1 - Apps/GraphicsDemo/tactility.py | 1 - Apps/HelloWorld/tactility.py | 1 - Apps/SerialConsole/tactility.py | 1 - Apps/TwoEleven/tactility.py | 1 - 7 files changed, 7 deletions(-) diff --git a/Apps/Calculator/tactility.py b/Apps/Calculator/tactility.py index ab95f58..77d27b1 100644 --- a/Apps/Calculator/tactility.py +++ b/Apps/Calculator/tactility.py @@ -8,7 +8,6 @@ import time import urllib.request import zipfile -from dataclasses import dataclass import requests import tarfile diff --git a/Apps/Diceware/tactility.py b/Apps/Diceware/tactility.py index ab95f58..77d27b1 100644 --- a/Apps/Diceware/tactility.py +++ b/Apps/Diceware/tactility.py @@ -8,7 +8,6 @@ import time import urllib.request import zipfile -from dataclasses import dataclass import requests import tarfile diff --git a/Apps/GPIO/tactility.py b/Apps/GPIO/tactility.py index ab95f58..77d27b1 100644 --- a/Apps/GPIO/tactility.py +++ b/Apps/GPIO/tactility.py @@ -8,7 +8,6 @@ import time import urllib.request import zipfile -from dataclasses import dataclass import requests import tarfile diff --git a/Apps/GraphicsDemo/tactility.py b/Apps/GraphicsDemo/tactility.py index ab95f58..77d27b1 100644 --- a/Apps/GraphicsDemo/tactility.py +++ b/Apps/GraphicsDemo/tactility.py @@ -8,7 +8,6 @@ import time import urllib.request import zipfile -from dataclasses import dataclass import requests import tarfile diff --git a/Apps/HelloWorld/tactility.py b/Apps/HelloWorld/tactility.py index ab95f58..77d27b1 100644 --- a/Apps/HelloWorld/tactility.py +++ b/Apps/HelloWorld/tactility.py @@ -8,7 +8,6 @@ import time import urllib.request import zipfile -from dataclasses import dataclass import requests import tarfile diff --git a/Apps/SerialConsole/tactility.py b/Apps/SerialConsole/tactility.py index ab95f58..77d27b1 100644 --- a/Apps/SerialConsole/tactility.py +++ b/Apps/SerialConsole/tactility.py @@ -8,7 +8,6 @@ import time import urllib.request import zipfile -from dataclasses import dataclass import requests import tarfile diff --git a/Apps/TwoEleven/tactility.py b/Apps/TwoEleven/tactility.py index ab95f58..77d27b1 100644 --- a/Apps/TwoEleven/tactility.py +++ b/Apps/TwoEleven/tactility.py @@ -8,7 +8,6 @@ import time import urllib.request import zipfile -from dataclasses import dataclass import requests import tarfile From 027f4d82bcb888ee1f0d1b971cfe51f6797397e1 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 4 Jan 2026 01:02:46 +0100 Subject: [PATCH 05/11] Fixes --- Apps/Calculator/tactility.py | 5 +++-- Apps/Diceware/tactility.py | 5 +++-- Apps/GPIO/tactility.py | 5 +++-- Apps/GraphicsDemo/tactility.py | 5 +++-- Apps/HelloWorld/tactility.py | 5 +++-- Apps/SerialConsole/tactility.py | 5 +++-- Apps/TwoEleven/tactility.py | 5 +++-- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Apps/Calculator/tactility.py b/Apps/Calculator/tactility.py index 77d27b1..81f271c 100644 --- a/Apps/Calculator/tactility.py +++ b/Apps/Calculator/tactility.py @@ -615,7 +615,7 @@ def uninstall_action(manifest, ip): # Argument validation if len(sys.argv) == 1: print_help() - sys.exit() + sys.exit(1) if "--verbose" in sys.argv: verbose = True sys.argv.remove("--verbose") @@ -646,7 +646,8 @@ def uninstall_action(manifest, ip): platform = None if len(sys.argv) > 2: platform = sys.argv[2] - build_action(manifest, platform) + if not build_action(manifest, platform): + sys.exit(1) elif action_arg == "clean": clean_action() elif action_arg == "clearcache": diff --git a/Apps/Diceware/tactility.py b/Apps/Diceware/tactility.py index 77d27b1..81f271c 100644 --- a/Apps/Diceware/tactility.py +++ b/Apps/Diceware/tactility.py @@ -615,7 +615,7 @@ def uninstall_action(manifest, ip): # Argument validation if len(sys.argv) == 1: print_help() - sys.exit() + sys.exit(1) if "--verbose" in sys.argv: verbose = True sys.argv.remove("--verbose") @@ -646,7 +646,8 @@ def uninstall_action(manifest, ip): platform = None if len(sys.argv) > 2: platform = sys.argv[2] - build_action(manifest, platform) + if not build_action(manifest, platform): + sys.exit(1) elif action_arg == "clean": clean_action() elif action_arg == "clearcache": diff --git a/Apps/GPIO/tactility.py b/Apps/GPIO/tactility.py index 77d27b1..81f271c 100644 --- a/Apps/GPIO/tactility.py +++ b/Apps/GPIO/tactility.py @@ -615,7 +615,7 @@ def uninstall_action(manifest, ip): # Argument validation if len(sys.argv) == 1: print_help() - sys.exit() + sys.exit(1) if "--verbose" in sys.argv: verbose = True sys.argv.remove("--verbose") @@ -646,7 +646,8 @@ def uninstall_action(manifest, ip): platform = None if len(sys.argv) > 2: platform = sys.argv[2] - build_action(manifest, platform) + if not build_action(manifest, platform): + sys.exit(1) elif action_arg == "clean": clean_action() elif action_arg == "clearcache": diff --git a/Apps/GraphicsDemo/tactility.py b/Apps/GraphicsDemo/tactility.py index 77d27b1..81f271c 100644 --- a/Apps/GraphicsDemo/tactility.py +++ b/Apps/GraphicsDemo/tactility.py @@ -615,7 +615,7 @@ def uninstall_action(manifest, ip): # Argument validation if len(sys.argv) == 1: print_help() - sys.exit() + sys.exit(1) if "--verbose" in sys.argv: verbose = True sys.argv.remove("--verbose") @@ -646,7 +646,8 @@ def uninstall_action(manifest, ip): platform = None if len(sys.argv) > 2: platform = sys.argv[2] - build_action(manifest, platform) + if not build_action(manifest, platform): + sys.exit(1) elif action_arg == "clean": clean_action() elif action_arg == "clearcache": diff --git a/Apps/HelloWorld/tactility.py b/Apps/HelloWorld/tactility.py index 77d27b1..81f271c 100644 --- a/Apps/HelloWorld/tactility.py +++ b/Apps/HelloWorld/tactility.py @@ -615,7 +615,7 @@ def uninstall_action(manifest, ip): # Argument validation if len(sys.argv) == 1: print_help() - sys.exit() + sys.exit(1) if "--verbose" in sys.argv: verbose = True sys.argv.remove("--verbose") @@ -646,7 +646,8 @@ def uninstall_action(manifest, ip): platform = None if len(sys.argv) > 2: platform = sys.argv[2] - build_action(manifest, platform) + if not build_action(manifest, platform): + sys.exit(1) elif action_arg == "clean": clean_action() elif action_arg == "clearcache": diff --git a/Apps/SerialConsole/tactility.py b/Apps/SerialConsole/tactility.py index 77d27b1..81f271c 100644 --- a/Apps/SerialConsole/tactility.py +++ b/Apps/SerialConsole/tactility.py @@ -615,7 +615,7 @@ def uninstall_action(manifest, ip): # Argument validation if len(sys.argv) == 1: print_help() - sys.exit() + sys.exit(1) if "--verbose" in sys.argv: verbose = True sys.argv.remove("--verbose") @@ -646,7 +646,8 @@ def uninstall_action(manifest, ip): platform = None if len(sys.argv) > 2: platform = sys.argv[2] - build_action(manifest, platform) + if not build_action(manifest, platform): + sys.exit(1) elif action_arg == "clean": clean_action() elif action_arg == "clearcache": diff --git a/Apps/TwoEleven/tactility.py b/Apps/TwoEleven/tactility.py index 77d27b1..81f271c 100644 --- a/Apps/TwoEleven/tactility.py +++ b/Apps/TwoEleven/tactility.py @@ -615,7 +615,7 @@ def uninstall_action(manifest, ip): # Argument validation if len(sys.argv) == 1: print_help() - sys.exit() + sys.exit(1) if "--verbose" in sys.argv: verbose = True sys.argv.remove("--verbose") @@ -646,7 +646,8 @@ def uninstall_action(manifest, ip): platform = None if len(sys.argv) > 2: platform = sys.argv[2] - build_action(manifest, platform) + if not build_action(manifest, platform): + sys.exit(1) elif action_arg == "clean": clean_action() elif action_arg == "clearcache": From 85c15b0533f99d1e9cff57dcbff3d352c0b7ee57 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 4 Jan 2026 01:26:02 +0100 Subject: [PATCH 06/11] Updates for using std::string --- Apps/SerialConsole/main/Source/ConnectView.h | 7 +++---- Apps/SerialConsole/main/Source/ConsoleView.h | 10 +++++----- Libraries/TactilityCpp/Include/TactilityCpp/Uart.h | 8 ++++---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Apps/SerialConsole/main/Source/ConnectView.h b/Apps/SerialConsole/main/Source/ConnectView.h index e27aa25..6966bf4 100644 --- a/Apps/SerialConsole/main/Source/ConnectView.h +++ b/Apps/SerialConsole/main/Source/ConnectView.h @@ -5,7 +5,6 @@ #include #include #include -#include #include #include @@ -21,7 +20,7 @@ class ConnectView final : public View { public: typedef std::function)> OnConnectedFunction; - std::vector uartNames; + std::vector uartNames; Preferences preferences = Preferences("SerialConsole"); LvglLock lvglLock; @@ -31,8 +30,8 @@ class ConnectView final : public View { lv_obj_t* busDropdown = nullptr; lv_obj_t* speedTextarea = nullptr; - Str join(const std::vector& list) { - Str output; + std::string join(const std::vector& list) { + std::string output; for (int i = list.size() - 1; i >= 0; i--) { output.append(list[i].c_str()); if (i < list.size() - 1) { diff --git a/Apps/SerialConsole/main/Source/ConsoleView.h b/Apps/SerialConsole/main/Source/ConsoleView.h index a0c4050..df6c45e 100644 --- a/Apps/SerialConsole/main/Source/ConsoleView.h +++ b/Apps/SerialConsole/main/Source/ConsoleView.h @@ -3,7 +3,7 @@ #include "View.h" #include "esp_log.h" -#include +#include #include #include #include @@ -33,7 +33,7 @@ class ConsoleView final : public View { uint8_t receiveBuffer[receiveBufferSize]; uint8_t renderBuffer[renderBufferSize]; size_t receiveBufferPosition = 0; - Str terminatorString = "\n"; + std::string terminatorString = "\n"; LvglLock lvglLock; @@ -141,9 +141,9 @@ class ConsoleView final : public View { void onSendClicked() { mutex.lock(); - Str input_text = lv_textarea_get_text(inputTextarea); - Str to_send; - to_send.appendf("%s%s", input_text.c_str(), terminatorString.c_str()); + std::string input_text = lv_textarea_get_text(inputTextarea); + std::string to_send; + to_send.append(input_text + terminatorString); mutex.unlock(); if (uart != nullptr) { diff --git a/Libraries/TactilityCpp/Include/TactilityCpp/Uart.h b/Libraries/TactilityCpp/Include/TactilityCpp/Uart.h index 02f1dfa..1e665f5 100644 --- a/Libraries/TactilityCpp/Include/TactilityCpp/Uart.h +++ b/Libraries/TactilityCpp/Include/TactilityCpp/Uart.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include @@ -21,13 +21,13 @@ class Uart { return std::make_unique(handle); } - static std::vector getNames() { - std::vector names; + static std::vector getNames() { + std::vector names; size_t count = tt_hal_uart_get_count(); for (size_t i = 0; i < count; i++) { char buffer[64]; if (tt_hal_uart_get_name(i, buffer, sizeof(buffer))) { - names.push_back(Str(buffer)); + names.push_back(std::string(buffer)); } } return names; From cfc9358dbbff7c20f5237ee0b72320060cbfeb55 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 4 Jan 2026 01:32:32 +0100 Subject: [PATCH 07/11] Replace Str with std::string --- Apps/Diceware/main/Source/Diceware.cpp | 12 ++++++------ Apps/Diceware/main/Source/Diceware.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Apps/Diceware/main/Source/Diceware.cpp b/Apps/Diceware/main/Source/Diceware.cpp index 2e52304..a1d16ca 100644 --- a/Apps/Diceware/main/Source/Diceware.cpp +++ b/Apps/Diceware/main/Source/Diceware.cpp @@ -20,15 +20,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); } 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,7 +38,7 @@ static Str readWordAtLine(const AppHandle handle, const int lineIndex) { } auto lock = tt_lock_alloc_for_path(path); - Str word; + std::string word; if (tt_lock_acquire(lock, TT_MAX_TICKS)) { FILE* file = fopen(path, "r"); if (file != nullptr) { @@ -53,7 +53,7 @@ static Str readWordAtLine(const AppHandle handle, const int lineIndex) { } int32_t Diceware::jobMain() { - Str result; + std::string result; for (int i = 0; i < wordCount; i++) { constexpr int line_count = 7776; const auto line_index = esp_random() % line_count; @@ -83,7 +83,7 @@ void Diceware::startJob(uint32_t jobWordCount) { jobThread->start(); } -void Diceware::onFinishJob(Str result) { +void Diceware::onFinishJob(std::string result) { tt_lvgl_lock(TT_MAX_TICKS); lv_label_set_text(resultLabel, result.c_str()); tt_lvgl_unlock(); diff --git a/Apps/Diceware/main/Source/Diceware.h b/Apps/Diceware/main/Source/Diceware.h index 8972f20..4a1fe6a 100644 --- a/Apps/Diceware/main/Source/Diceware.h +++ b/Apps/Diceware/main/Source/Diceware.h @@ -4,7 +4,7 @@ #include -#include +#include #include #include @@ -26,7 +26,7 @@ class Diceware final : public App { int32_t jobMain(); void startJob(uint32_t jobWordCount); - void onFinishJob(Str result); + void onFinishJob(std::string result); void cleanupJob(); public: From a25a98b22fb5c187ea67d4f10aa42d75a356ab47 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 4 Jan 2026 01:39:31 +0100 Subject: [PATCH 08/11] Fixes --- Apps/Diceware/main/Source/Diceware.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Apps/Diceware/main/Source/Diceware.cpp b/Apps/Diceware/main/Source/Diceware.cpp index a1d16ca..80fd884 100644 --- a/Apps/Diceware/main/Source/Diceware.cpp +++ b/Apps/Diceware/main/Source/Diceware.cpp @@ -24,7 +24,7 @@ static std::string readWord(FILE* file) { char c; 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; } @@ -58,7 +58,8 @@ int32_t Diceware::jobMain() { constexpr int line_count = 7776; const auto line_index = esp_random() % line_count; auto word = readWordAtLine(handle, line_index); - result.appendf("%s ", word.c_str()); + result += word; + result += " "; } onFinishJob(result); From 15aebc7999f2a859f6512f06f0b64002ad71481f Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 4 Jan 2026 01:49:57 +0100 Subject: [PATCH 09/11] Fix --- Apps/Diceware/main/Source/Diceware.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Apps/Diceware/main/Source/Diceware.cpp b/Apps/Diceware/main/Source/Diceware.cpp index 80fd884..a82f650 100644 --- a/Apps/Diceware/main/Source/Diceware.cpp +++ b/Apps/Diceware/main/Source/Diceware.cpp @@ -8,6 +8,8 @@ #include #include +#include + constexpr char* TAG = "Diceware"; static void skipNewlines(FILE* file, const int count) { @@ -39,7 +41,7 @@ static std::string readWordAtLine(const AppHandle handle, const int lineIndex) { auto lock = tt_lock_alloc_for_path(path); std::string word; - if (tt_lock_acquire(lock, TT_MAX_TICKS)) { + if (tt_lock_acquire(lock, tt::kernel::MAX_TICKS)) { FILE* file = fopen(path, "r"); if (file != nullptr) { skipNewlines(file, lineIndex); @@ -85,7 +87,7 @@ void Diceware::startJob(uint32_t jobWordCount) { } void Diceware::onFinishJob(std::string result) { - tt_lvgl_lock(TT_MAX_TICKS); + tt_lvgl_lock(tt::kernel::MAX_TICKS); lv_label_set_text(resultLabel, result.c_str()); tt_lvgl_unlock(); } From 98df5c01046098b2daccfd0e29bf37f2cdaccbee Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 4 Jan 2026 02:01:45 +0100 Subject: [PATCH 10/11] Fixes --- Apps/SerialConsole/main/Source/ConsoleView.h | 4 ++-- Libraries/TactilityCpp/Include/TactilityCpp/Uart.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Apps/SerialConsole/main/Source/ConsoleView.h b/Apps/SerialConsole/main/Source/ConsoleView.h index df6c45e..933e31b 100644 --- a/Apps/SerialConsole/main/Source/ConsoleView.h +++ b/Apps/SerialConsole/main/Source/ConsoleView.h @@ -25,9 +25,9 @@ class ConsoleView final : public View { lv_obj_t* _Nullable logTextarea = nullptr; lv_obj_t* _Nullable inputTextarea = nullptr; std::shared_ptr _Nullable uart = nullptr; - std::shared_ptr uartThread _Nullable = nullptr; + std::unique_ptr uartThread _Nullable = nullptr; bool uartThreadInterrupted = false; - std::shared_ptr viewThread _Nullable = nullptr; + std::unique_ptr viewThread _Nullable = nullptr; bool viewThreadInterrupted = false; tt::RecursiveMutex mutex; uint8_t receiveBuffer[receiveBufferSize]; diff --git a/Libraries/TactilityCpp/Include/TactilityCpp/Uart.h b/Libraries/TactilityCpp/Include/TactilityCpp/Uart.h index 1e665f5..c2a39b7 100644 --- a/Libraries/TactilityCpp/Include/TactilityCpp/Uart.h +++ b/Libraries/TactilityCpp/Include/TactilityCpp/Uart.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include From 47ea86ecf73140c1c3e6f79deaaa65325b56d9b5 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 4 Jan 2026 02:10:21 +0100 Subject: [PATCH 11/11] Fixes --- Apps/SerialConsole/main/Source/ConsoleView.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Apps/SerialConsole/main/Source/ConsoleView.h b/Apps/SerialConsole/main/Source/ConsoleView.h index 933e31b..94c86db 100644 --- a/Apps/SerialConsole/main/Source/ConsoleView.h +++ b/Apps/SerialConsole/main/Source/ConsoleView.h @@ -81,8 +81,9 @@ class ConsoleView final : public View { auto end_time = tt::kernel::getTicks(); auto time_diff = end_time - start_time; - if (time_diff < 500U) { - tt::kernel::delayTicks((500U - time_diff) / portTICK_PERIOD_MS); + auto target_delay = tt::kernel::millisToTicks(500U); + if (time_diff < target_delay) { + tt::kernel::delayTicks(target_delay - time_diff); } } @@ -94,7 +95,7 @@ class ConsoleView final : public View { while (!isUartThreadInterrupted()) { assert(uart != nullptr); - bool success = uart->readByte(&byte, 50 / portTICK_PERIOD_MS); + bool success = uart->readByte(&byte, tt::kernel::millisToTicks(50)); // Thread might've been interrupted in the meanwhile if (isUartThreadInterrupted()) {