diff --git a/Tactility/Source/app/crashdiagnostics/QrHelpers.h b/Tactility/Private/app/crashdiagnostics/QrHelpers.h similarity index 100% rename from Tactility/Source/app/crashdiagnostics/QrHelpers.h rename to Tactility/Private/app/crashdiagnostics/QrHelpers.h diff --git a/Tactility/Source/app/crashdiagnostics/QrUrl.h b/Tactility/Private/app/crashdiagnostics/QrUrl.h similarity index 100% rename from Tactility/Source/app/crashdiagnostics/QrUrl.h rename to Tactility/Private/app/crashdiagnostics/QrUrl.h diff --git a/Tactility/Source/app/files/FileUtils.h b/Tactility/Private/app/files/FileUtils.h similarity index 100% rename from Tactility/Source/app/files/FileUtils.h rename to Tactility/Private/app/files/FileUtils.h diff --git a/Tactility/Private/app/files/FilesPrivate.h b/Tactility/Private/app/files/FilesPrivate.h new file mode 100644 index 00000000..25d4c0b4 --- /dev/null +++ b/Tactility/Private/app/files/FilesPrivate.h @@ -0,0 +1,34 @@ +#pragma once + +#include "./View.h" +#include "./State.h" + +#include "app/AppManifest.h" + +#include +#include +#include + +namespace tt::app::files { + +class Files { + std::unique_ptr view; + std::shared_ptr state; + +public: + Files() { + state = std::make_shared(); + view = std::make_unique(state); + } + + void onShow(lv_obj_t* parent) { + view->init(parent); + } + + void onResult(Result result, const Bundle& bundle) { + view->onResult(result, bundle); + } +}; + + +} // namespace diff --git a/Tactility/Source/app/files/State.h b/Tactility/Private/app/files/State.h similarity index 100% rename from Tactility/Source/app/files/State.h rename to Tactility/Private/app/files/State.h diff --git a/Tactility/Source/app/files/View.h b/Tactility/Private/app/files/View.h similarity index 97% rename from Tactility/Source/app/files/View.h rename to Tactility/Private/app/files/View.h index 862b7c7f..65839e43 100644 --- a/Tactility/Source/app/files/View.h +++ b/Tactility/Private/app/files/View.h @@ -1,6 +1,7 @@ #pragma once -#include "State.h" +#include "./State.h" + #include "app/AppManifest.h" #include #include diff --git a/Tactility/Source/app/i2cscanner/I2cHelpers.h b/Tactility/Private/app/i2cscanner/I2cHelpers.h similarity index 100% rename from Tactility/Source/app/i2cscanner/I2cHelpers.h rename to Tactility/Private/app/i2cscanner/I2cHelpers.h diff --git a/Tactility/Private/app/i2cscanner/I2cScannerPrivate.h b/Tactility/Private/app/i2cscanner/I2cScannerPrivate.h new file mode 100644 index 00000000..54028725 --- /dev/null +++ b/Tactility/Private/app/i2cscanner/I2cScannerPrivate.h @@ -0,0 +1,37 @@ +#pragma once + +#include +#include +#include +#include "lvgl.h" +#include "hal/i2c/I2c.h" +#include "Timer.h" +#include + +namespace tt::app::i2cscanner { + +#define TAG "i2cscanner" + +enum ScanState { + ScanStateInitial, + ScanStateScanning, + ScanStateStopped +}; + +struct Data { + // Core + Mutex mutex = Mutex(Mutex::TypeRecursive); + std::unique_ptr scanTimer = nullptr; + // State + ScanState scanState; + i2c_port_t port = I2C_NUM_0; + std::vector scannedAddresses; + // Widgets + lv_obj_t* scanButtonLabelWidget = nullptr; + lv_obj_t* portDropdownWidget = nullptr; + lv_obj_t* scanListWidget = nullptr; +}; + +void onScanTimerFinished(std::shared_ptr data); + +} diff --git a/Tactility/Source/app/i2cscanner/I2cScannerThread.h b/Tactility/Private/app/i2cscanner/I2cScannerThread.h similarity index 86% rename from Tactility/Source/app/i2cscanner/I2cScannerThread.h rename to Tactility/Private/app/i2cscanner/I2cScannerThread.h index c137e705..2593602a 100644 --- a/Tactility/Source/app/i2cscanner/I2cScannerThread.h +++ b/Tactility/Private/app/i2cscanner/I2cScannerThread.h @@ -1,6 +1,6 @@ #pragma once -#include "I2cScanner.h" +#include "./I2cScannerPrivate.h" #include namespace tt::app::i2cscanner { diff --git a/Tactility/Source/app/screenshot/ScreenshotUi.h b/Tactility/Private/app/screenshot/ScreenshotUi.h similarity index 100% rename from Tactility/Source/app/screenshot/ScreenshotUi.h rename to Tactility/Private/app/screenshot/ScreenshotUi.h diff --git a/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.cpp b/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.cpp index 397a4fae..88d46736 100644 --- a/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.cpp +++ b/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.cpp @@ -1,11 +1,11 @@ #ifdef ESP_TARGET +#include "app/crashdiagnostics/QrHelpers.h" +#include "app/crashdiagnostics/QrUrl.h" +#include "app/launcher/Launcher.h" #include "lvgl.h" #include "lvgl/Statusbar.h" -#include "app/launcher/Launcher.h" #include "qrcode.h" -#include "QrHelpers.h" -#include "QrUrl.h" #include "service/loader/Loader.h" #define TAG "crash_diagnostics" diff --git a/Tactility/Source/app/crashdiagnostics/QrHelpers.cpp b/Tactility/Source/app/crashdiagnostics/QrHelpers.cpp index e36935f9..3d36248d 100644 --- a/Tactility/Source/app/crashdiagnostics/QrHelpers.cpp +++ b/Tactility/Source/app/crashdiagnostics/QrHelpers.cpp @@ -1,6 +1,5 @@ +#include "app/crashdiagnostics/QrHelpers.h" #include -#include -#include "QrHelpers.h" /** * Maps QR version (starting at a fictitious 0) to the usable byte size for L(ow) CRC checking QR. diff --git a/Tactility/Source/app/crashdiagnostics/QrUrl.cpp b/Tactility/Source/app/crashdiagnostics/QrUrl.cpp index baa3eca2..f74204f3 100644 --- a/Tactility/Source/app/crashdiagnostics/QrUrl.cpp +++ b/Tactility/Source/app/crashdiagnostics/QrUrl.cpp @@ -1,6 +1,6 @@ #ifdef ESP_TARGET -#include "QrUrl.h" +#include "app/crashdiagnostics/QrUrl.h" #include "kernel/PanicHandler.h" #include "Log.h" diff --git a/Tactility/Source/app/files/FileUtils.cpp b/Tactility/Source/app/files/FileUtils.cpp index 28f1645e..2267cdf3 100644 --- a/Tactility/Source/app/files/FileUtils.cpp +++ b/Tactility/Source/app/files/FileUtils.cpp @@ -1,4 +1,5 @@ -#include "FileUtils.h" +#include "app/files/FileUtils.h" + #include "TactilityCore.h" #include #include diff --git a/Tactility/Source/app/files/Files.cpp b/Tactility/Source/app/files/Files.cpp index 3149a282..41ba5831 100644 --- a/Tactility/Source/app/files/Files.cpp +++ b/Tactility/Source/app/files/Files.cpp @@ -1,6 +1,8 @@ -#include "Files.h" +#include "app/files/FilesPrivate.h" + #include "app/AppContext.h" #include "Assets.h" +#include "service/loader/Loader.h" #include @@ -37,4 +39,8 @@ extern const AppManifest manifest = { .onResult = onResult }; +void start() { + service::loader::startApp(manifest.id); +} + } // namespace diff --git a/Tactility/Source/app/files/Files.h b/Tactility/Source/app/files/Files.h index eda259f8..51f8f16f 100644 --- a/Tactility/Source/app/files/Files.h +++ b/Tactility/Source/app/files/Files.h @@ -10,24 +10,6 @@ namespace tt::app::files { -class Files { - std::unique_ptr view; - std::shared_ptr state; - -public: - Files() { - state = std::make_shared(); - view = std::make_unique(state); - } - - void onShow(lv_obj_t* parent) { - view->init(parent); - } - - void onResult(Result result, const Bundle& bundle) { - view->onResult(result, bundle); - } -}; - +void start(); } // namespace diff --git a/Tactility/Source/app/files/State.cpp b/Tactility/Source/app/files/State.cpp index ed0f0601..46881aeb 100644 --- a/Tactility/Source/app/files/State.cpp +++ b/Tactility/Source/app/files/State.cpp @@ -1,7 +1,8 @@ -#include "State.h" +#include "app/files/State.h" +#include "app/files/FileUtils.h" + #include "kernel/Kernel.h" #include "Log.h" -#include "FileUtils.h" #include "Partitions.h" #include "hal/SdCard.h" diff --git a/Tactility/Source/app/files/View.cpp b/Tactility/Source/app/files/View.cpp index 519ce3b7..283552cd 100644 --- a/Tactility/Source/app/files/View.cpp +++ b/Tactility/Source/app/files/View.cpp @@ -1,3 +1,6 @@ +#include "app/files/FileUtils.h" +#include "app/files/View.h" + #include "app/alertdialog/AlertDialog.h" #include "app/imageviewer/ImageViewer.h" #include "app/inputdialog/InputDialog.h" @@ -6,9 +9,7 @@ #include "lvgl/Toolbar.h" #include "lvgl/LvglSync.h" #include "service/loader/Loader.h" -#include "FileUtils.h" #include "Tactility.h" -#include "View.h" #include "StringUtils.h" #include #include @@ -83,18 +84,14 @@ void View::viewFile(const std::string& path, const std::string& filename) { app::startElfApp(processed_filepath); #endif } else if (isSupportedImageFile(filename)) { - auto bundle = std::make_shared(); - bundle->putString(IMAGE_VIEWER_FILE_ARGUMENT, processed_filepath); - service::loader::startApp("ImageViewer", bundle); + app::imageviewer::start(processed_filepath); } else if (isSupportedTextFile(filename)) { - auto bundle = std::make_shared(); if (kernel::getPlatform() == kernel::PlatformEsp) { - bundle->putString(TEXT_VIEWER_FILE_ARGUMENT, processed_filepath); + app::textviewer::start(processed_filepath); } else { // Remove forward slash, because we need a relative path - bundle->putString(TEXT_VIEWER_FILE_ARGUMENT, processed_filepath.substr(1)); + app::textviewer::start(processed_filepath.substr(1)); } - service::loader::startApp("TextViewer", bundle); } else { TT_LOG_W(TAG, "opening files of this type is not supported"); } diff --git a/Tactility/Source/app/i2cscanner/I2cHelpers.cpp b/Tactility/Source/app/i2cscanner/I2cHelpers.cpp index bd57f706..95b2dbcd 100644 --- a/Tactility/Source/app/i2cscanner/I2cHelpers.cpp +++ b/Tactility/Source/app/i2cscanner/I2cHelpers.cpp @@ -1,4 +1,4 @@ -#include "I2cHelpers.h" +#include "app/i2cscanner/I2cHelpers.h" #include "Tactility.h" #include "StringUtils.h" #include diff --git a/Tactility/Source/app/i2cscanner/I2cScanner.cpp b/Tactility/Source/app/i2cscanner/I2cScanner.cpp index 002defeb..e4dad0c0 100644 --- a/Tactility/Source/app/i2cscanner/I2cScanner.cpp +++ b/Tactility/Source/app/i2cscanner/I2cScanner.cpp @@ -1,6 +1,6 @@ -#include "I2cScanner.h" -#include "I2cScannerThread.h" -#include "I2cHelpers.h" +#include "app/i2cscanner/I2cScannerPrivate.h" +#include "app/i2cscanner/I2cScannerThread.h" +#include "app/i2cscanner/I2cHelpers.h" #include "Assets.h" #include "Tactility.h" @@ -50,7 +50,7 @@ static void onSelectBus(lv_event_t* event) { TT_LOG_I(TAG, "Selected %ld", selected); } -static void onPressScan(lv_event_t* event) { +static void onPressScan(TT_UNUSED lv_event_t* event) { auto data = optData(); if (data != nullptr) { if (data->scanState == ScanStateScanning) { @@ -191,4 +191,8 @@ extern const AppManifest manifest = { .onHide = onHide }; +void start() { + service::loader::startApp(manifest.id); +} + } // namespace diff --git a/Tactility/Source/app/i2cscanner/I2cScanner.h b/Tactility/Source/app/i2cscanner/I2cScanner.h index 54028725..9ba5537f 100644 --- a/Tactility/Source/app/i2cscanner/I2cScanner.h +++ b/Tactility/Source/app/i2cscanner/I2cScanner.h @@ -10,28 +10,6 @@ namespace tt::app::i2cscanner { -#define TAG "i2cscanner" - -enum ScanState { - ScanStateInitial, - ScanStateScanning, - ScanStateStopped -}; - -struct Data { - // Core - Mutex mutex = Mutex(Mutex::TypeRecursive); - std::unique_ptr scanTimer = nullptr; - // State - ScanState scanState; - i2c_port_t port = I2C_NUM_0; - std::vector scannedAddresses; - // Widgets - lv_obj_t* scanButtonLabelWidget = nullptr; - lv_obj_t* portDropdownWidget = nullptr; - lv_obj_t* scanListWidget = nullptr; -}; - -void onScanTimerFinished(std::shared_ptr data); +void start(); } diff --git a/Tactility/Source/app/i2cscanner/I2cScannerThread.cpp b/Tactility/Source/app/i2cscanner/I2cScannerThread.cpp index 008dc411..be7a8aaa 100644 --- a/Tactility/Source/app/i2cscanner/I2cScannerThread.cpp +++ b/Tactility/Source/app/i2cscanner/I2cScannerThread.cpp @@ -1,4 +1,4 @@ -#include "I2cScannerThread.h" +#include "app/i2cscanner/I2cScannerThread.h" #include "lvgl.h" #include "service/loader/Loader.h" diff --git a/Tactility/Source/app/imageviewer/ImageViewer.cpp b/Tactility/Source/app/imageviewer/ImageViewer.cpp index c62780ac..4dd38f67 100644 --- a/Tactility/Source/app/imageviewer/ImageViewer.cpp +++ b/Tactility/Source/app/imageviewer/ImageViewer.cpp @@ -1,15 +1,16 @@ #include -#include "ImageViewer.h" #include "lvgl.h" #include "lvgl/Style.h" #include "lvgl/Toolbar.h" #include "StringUtils.h" +#include "service/loader/Loader.h" namespace tt::app::imageviewer { extern const AppManifest manifest; #define TAG "image_viewer" +#define IMAGE_VIEWER_FILE_ARGUMENT "file" static void onShow(AppContext& app, lv_obj_t* parent) { auto wrapper = lv_obj_create(parent); @@ -57,4 +58,10 @@ extern const AppManifest manifest = { .onShow = onShow }; +void start(const std::string& file) { + auto parameters = std::make_shared(); + parameters->putString(IMAGE_VIEWER_FILE_ARGUMENT, file); + service::loader::startApp(manifest.id, parameters); +} + } // namespace diff --git a/Tactility/Source/app/imageviewer/ImageViewer.h b/Tactility/Source/app/imageviewer/ImageViewer.h index 18dd8ecc..a6a4c4da 100644 --- a/Tactility/Source/app/imageviewer/ImageViewer.h +++ b/Tactility/Source/app/imageviewer/ImageViewer.h @@ -1,3 +1,7 @@ #pragma once -#define IMAGE_VIEWER_FILE_ARGUMENT "file" \ No newline at end of file +namespace tt::app::imageviewer { + +void start(const std::string& file); + +}; \ No newline at end of file diff --git a/Tactility/Source/app/screenshot/Screenshot.cpp b/Tactility/Source/app/screenshot/Screenshot.cpp index e3f9c1d9..18689664 100644 --- a/Tactility/Source/app/screenshot/Screenshot.cpp +++ b/Tactility/Source/app/screenshot/Screenshot.cpp @@ -2,7 +2,7 @@ #if TT_FEATURE_SCREENSHOT_ENABLED -#include "ScreenshotUi.h" +#include "app/screenshot/ScreenshotUi.h" #include namespace tt::app::screenshot { diff --git a/Tactility/Source/app/screenshot/ScreenshotUi.cpp b/Tactility/Source/app/screenshot/ScreenshotUi.cpp index 4ff85935..bb4e5b5c 100644 --- a/Tactility/Source/app/screenshot/ScreenshotUi.cpp +++ b/Tactility/Source/app/screenshot/ScreenshotUi.cpp @@ -2,7 +2,7 @@ #if TT_FEATURE_SCREENSHOT_ENABLED -#include "ScreenshotUi.h" +#include "app/screenshot/ScreenshotUi.h" #include "TactilityCore.h" #include "hal/SdCard.h" diff --git a/Tactility/Source/app/textviewer/TextViewer.cpp b/Tactility/Source/app/textviewer/TextViewer.cpp index c0b2e006..f4d50d40 100644 --- a/Tactility/Source/app/textviewer/TextViewer.cpp +++ b/Tactility/Source/app/textviewer/TextViewer.cpp @@ -4,8 +4,10 @@ #include "lvgl/LabelUtils.h" #include "lvgl/Style.h" #include "lvgl/Toolbar.h" +#include "service/loader/Loader.h" #define TAG "text_viewer" +#define TEXT_VIEWER_FILE_ARGUMENT "file" namespace tt::app::textviewer { @@ -45,4 +47,11 @@ extern const AppManifest manifest = { .onShow = onShow }; +void start(const std::string& file) { + auto parameters = std::make_shared(); + parameters->putString(TEXT_VIEWER_FILE_ARGUMENT, file); + service::loader::startApp(manifest.id, parameters); +} + + } // namespace diff --git a/Tactility/Source/app/textviewer/TextViewer.h b/Tactility/Source/app/textviewer/TextViewer.h index de52710b..3f9fdd43 100644 --- a/Tactility/Source/app/textviewer/TextViewer.h +++ b/Tactility/Source/app/textviewer/TextViewer.h @@ -1,3 +1,7 @@ #pragma once -#define TEXT_VIEWER_FILE_ARGUMENT "file" \ No newline at end of file +namespace tt::app::textviewer { + +void start(const std::string&file); + +}