mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-20 15:35:05 +00:00
Compare commits
No commits in common. "45a837942683fbe40311438c0f434e7ff6ed9e06" and "15de4e20b82ec0312e8fb1ad5014f169a11e1ac0" have entirely different histories.
45a8379426
...
15de4e20b8
@ -1,7 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
file(GLOB_RECURSE SOURCE_FILES "Source/*.c*")
|
||||
|
||||
if (DEFINED ENV{ESP_IDF_VERSION})
|
||||
# Read board id/project
|
||||
include("../Buildscripts/board.cmake")
|
||||
@ -9,13 +7,15 @@ if (DEFINED ENV{ESP_IDF_VERSION})
|
||||
get_property(TACTILITY_BOARD_PROJECT GLOBAL PROPERTY TACTILITY_BOARD_PROJECT)
|
||||
|
||||
idf_component_register(
|
||||
SRCS ${SOURCE_FILES}
|
||||
SRC_DIRS "Source"
|
||||
"Source/HelloWorld"
|
||||
REQUIRES ${BOARD_COMPONENTS}
|
||||
REQUIRES Tactility TactilityC ${TACTILITY_BOARD_PROJECT}
|
||||
)
|
||||
else ()
|
||||
|
||||
add_executable(AppSim ${SOURCE_FILES})
|
||||
file(GLOB_RECURSE SOURCES "Source/*.c*")
|
||||
add_executable(AppSim ${SOURCES})
|
||||
target_link_libraries(AppSim
|
||||
PRIVATE Tactility
|
||||
PRIVATE TactilityCore
|
||||
23
App/Source/HelloWorld/HelloWorld.cpp
Normal file
23
App/Source/HelloWorld/HelloWorld.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <lvgl.h>
|
||||
|
||||
using namespace tt::app;
|
||||
|
||||
class HelloWorldApp : public App {
|
||||
|
||||
void onShow(AppContext& context, lv_obj_t* parent) override {
|
||||
lv_obj_t* toolbar = tt::lvgl::toolbar_create(parent, context);
|
||||
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||
|
||||
lv_obj_t* label = lv_label_create(parent);
|
||||
lv_label_set_text(label, "Hello, world!");
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
extern const AppManifest hello_world_app = {
|
||||
.appId = "HelloWorld",
|
||||
.appName = "Hello World",
|
||||
.createApp = create<HelloWorldApp>
|
||||
};
|
||||
@ -15,7 +15,10 @@ void app_main() {
|
||||
* Auto-select a board based on the ./sdkconfig.board.* file
|
||||
* that you copied to ./sdkconfig before you opened this project.
|
||||
*/
|
||||
.hardware = TT_BOARD_HARDWARE
|
||||
.hardware = TT_BOARD_HARDWARE,
|
||||
.apps = {
|
||||
// &hello_world_app,
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
@ -24,9 +24,9 @@ function(INIT_TACTILITY_GLOBALS SDKCONFIG_FILE)
|
||||
if (board_id STREQUAL "cyd-2432s024c")
|
||||
set(TACTILITY_BOARD_PROJECT CYD-2432S024C)
|
||||
elseif (board_id STREQUAL "cyd-2432s028r")
|
||||
set(TACTILITY_BOARD_PROJECT CYD-2432S028R)
|
||||
set(TACTILITY_BOARD_PROJECT CYD-2432S028R)
|
||||
elseif (board_id STREQUAL "cyd-e32r28t")
|
||||
set(TACTILITY_BOARD_PROJECT CYD-E32R28T)
|
||||
set(TACTILITY_BOARD_PROJECT CYD-E32R28T)
|
||||
elseif (board_id STREQUAL "cyd-2432s032c")
|
||||
set(TACTILITY_BOARD_PROJECT CYD-2432S032C)
|
||||
elseif (board_id STREQUAL "cyd-4848s040c")
|
||||
|
||||
@ -29,9 +29,9 @@ if (DEFINED ENV{ESP_IDF_VERSION})
|
||||
init_tactility_globals("sdkconfig")
|
||||
get_property(TACTILITY_BOARD_PROJECT GLOBAL PROPERTY TACTILITY_BOARD_PROJECT)
|
||||
|
||||
set(COMPONENTS Firmware)
|
||||
set(COMPONENTS App)
|
||||
set(EXTRA_COMPONENT_DIRS
|
||||
"Firmware"
|
||||
"App"
|
||||
"Boards/${TACTILITY_BOARD_PROJECT}"
|
||||
"Drivers"
|
||||
"Tactility"
|
||||
@ -93,7 +93,7 @@ if (NOT DEFINED ENV{ESP_IDF_VERSION})
|
||||
add_subdirectory(Libraries/mbedtls)
|
||||
|
||||
# Sim app
|
||||
add_subdirectory(Firmware)
|
||||
add_subdirectory(App)
|
||||
|
||||
# Tests
|
||||
add_subdirectory(Tests)
|
||||
|
||||
@ -1,195 +1,7 @@
|
||||
Apache License
|
||||
==============
|
||||
Copyright (c) 2024 Ken Van Hoeylandt (aka ByteWelder)
|
||||
|
||||
_Version 2.0, January 2004_
|
||||
_<<http://www.apache.org/licenses/>>_
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
### Terms and Conditions for use, reproduction, and distribution
|
||||
|
||||
#### 1. Definitions
|
||||
|
||||
“License” shall mean the terms and conditions for use, reproduction, and
|
||||
distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
“Licensor” shall mean the copyright owner or entity authorized by the copyright
|
||||
owner that is granting the License.
|
||||
|
||||
“Legal Entity” shall mean the union of the acting entity and all other entities
|
||||
that control, are controlled by, or are under common control with that entity.
|
||||
For the purposes of this definition, “control” means **(i)** the power, direct or
|
||||
indirect, to cause the direction or management of such entity, whether by
|
||||
contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or **(iii)** beneficial ownership of such entity.
|
||||
|
||||
“You” (or “Your”) shall mean an individual or Legal Entity exercising
|
||||
permissions granted by this License.
|
||||
|
||||
“Source” form shall mean the preferred form for making modifications, including
|
||||
but not limited to software source code, documentation source, and configuration
|
||||
files.
|
||||
|
||||
“Object” form shall mean any form resulting from mechanical transformation or
|
||||
translation of a Source form, including but not limited to compiled object code,
|
||||
generated documentation, and conversions to other media types.
|
||||
|
||||
“Work” shall mean the work of authorship, whether in Source or Object form, made
|
||||
available under the License, as indicated by a copyright notice that is included
|
||||
in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
“Derivative Works” shall mean any work, whether in Source or Object form, that
|
||||
is based on (or derived from) the Work and for which the editorial revisions,
|
||||
annotations, elaborations, or other modifications represent, as a whole, an
|
||||
original work of authorship. For the purposes of this License, Derivative Works
|
||||
shall not include works that remain separable from, or merely link (or bind by
|
||||
name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
“Contribution” shall mean any work of authorship, including the original version
|
||||
of the Work and any modifications or additions to that Work or Derivative Works
|
||||
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
||||
by the copyright owner or by an individual or Legal Entity authorized to submit
|
||||
on behalf of the copyright owner. For the purposes of this definition,
|
||||
“submitted” means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems, and
|
||||
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
||||
the purpose of discussing and improving the Work, but excluding communication
|
||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||
owner as “Not a Contribution.”
|
||||
|
||||
“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
|
||||
of whom a Contribution has been received by Licensor and subsequently
|
||||
incorporated within the Work.
|
||||
|
||||
#### 2. Grant of Copyright License
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby
|
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the Work and such
|
||||
Derivative Works in Source or Object form.
|
||||
|
||||
#### 3. Grant of Patent License
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby
|
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable (except as stated in this section) patent license to make, have
|
||||
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
||||
such license applies only to those patent claims licensable by such Contributor
|
||||
that are necessarily infringed by their Contribution(s) alone or by combination
|
||||
of their Contribution(s) with the Work to which such Contribution(s) was
|
||||
submitted. If You institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
||||
Contribution incorporated within the Work constitutes direct or contributory
|
||||
patent infringement, then any patent licenses granted to You under this License
|
||||
for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
#### 4. Redistribution
|
||||
|
||||
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
||||
in any medium, with or without modifications, and in Source or Object form,
|
||||
provided that You meet the following conditions:
|
||||
|
||||
* **(a)** You must give any other recipients of the Work or Derivative Works a copy of
|
||||
this License; and
|
||||
* **(b)** You must cause any modified files to carry prominent notices stating that You
|
||||
changed the files; and
|
||||
* **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
|
||||
all copyright, patent, trademark, and attribution notices from the Source form
|
||||
of the Work, excluding those notices that do not pertain to any part of the
|
||||
Derivative Works; and
|
||||
* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
|
||||
Derivative Works that You distribute must include a readable copy of the
|
||||
attribution notices contained within such NOTICE file, excluding those notices
|
||||
that do not pertain to any part of the Derivative Works, in at least one of the
|
||||
following places: within a NOTICE text file distributed as part of the
|
||||
Derivative Works; within the Source form or documentation, if provided along
|
||||
with the Derivative Works; or, within a display generated by the Derivative
|
||||
Works, if and wherever such third-party notices normally appear. The contents of
|
||||
the NOTICE file are for informational purposes only and do not modify the
|
||||
License. You may add Your own attribution notices within Derivative Works that
|
||||
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
||||
provided that such additional attribution notices cannot be construed as
|
||||
modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide
|
||||
additional or different license terms and conditions for use, reproduction, or
|
||||
distribution of Your modifications, or for any such Derivative Works as a whole,
|
||||
provided Your use, reproduction, and distribution of the Work otherwise complies
|
||||
with the conditions stated in this License.
|
||||
|
||||
#### 5. Submission of Contributions
|
||||
|
||||
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
||||
for inclusion in the Work by You to the Licensor shall be under the terms and
|
||||
conditions of this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
||||
any separate license agreement you may have executed with Licensor regarding
|
||||
such Contributions.
|
||||
|
||||
#### 6. Trademarks
|
||||
|
||||
This License does not grant permission to use the trade names, trademarks,
|
||||
service marks, or product names of the Licensor, except as required for
|
||||
reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the NOTICE file.
|
||||
|
||||
#### 7. Disclaimer of Warranty
|
||||
|
||||
Unless required by applicable law or agreed to in writing, Licensor provides the
|
||||
Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
||||
including, without limitation, any warranties or conditions of TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
||||
solely responsible for determining the appropriateness of using or
|
||||
redistributing the Work and assume any risks associated with Your exercise of
|
||||
permissions under this License.
|
||||
|
||||
#### 8. Limitation of Liability
|
||||
|
||||
In no event and under no legal theory, whether in tort (including negligence),
|
||||
contract, or otherwise, unless required by applicable law (such as deliberate
|
||||
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special, incidental,
|
||||
or consequential damages of any character arising as a result of this License or
|
||||
out of the use or inability to use the Work (including but not limited to
|
||||
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
||||
any and all other commercial damages or losses), even if such Contributor has
|
||||
been advised of the possibility of such damages.
|
||||
|
||||
#### 9. Accepting Warranty or Additional Liability
|
||||
|
||||
While redistributing the Work or Derivative Works thereof, You may choose to
|
||||
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
||||
other liability obligations and/or rights consistent with this License. However,
|
||||
in accepting such obligations, You may act only on Your own behalf and on Your
|
||||
sole responsibility, not on behalf of any other Contributor, and only if You
|
||||
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason of your
|
||||
accepting any such warranty or additional liability.
|
||||
|
||||
_END OF TERMS AND CONDITIONS_
|
||||
|
||||
### APPENDIX: How to apply the Apache License to your work
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate
|
||||
notice, with the fields enclosed by brackets `[]` replaced with your own
|
||||
identifying information. (Don't include the brackets!) The text should be
|
||||
enclosed in the appropriate comment syntax for the file format. We also
|
||||
recommend that a file or class name and description of purpose be included on
|
||||
the same “printed page” as the copyright notice for easier identification within
|
||||
third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@ -9,7 +9,7 @@ For other usages, [contact me](https://kenvanhoeylandt.net).
|
||||
|
||||
# TactilityC & TactilitySDK
|
||||
|
||||
TactilityC (source & binaries) and the TactilitySDK distribution files are available via the [Apache License Version 2.0](Documentation/license-tactilitysdk.md).
|
||||
TactilityC (source & binaries) and the TactilitySDK distribution files are available under an [MIT License](Documentation/license-tactilitysdk.md).
|
||||
|
||||
# Other licenses & copyrights
|
||||
|
||||
|
||||
@ -15,6 +15,10 @@ namespace app::launcher { extern const AppManifest manifest; }
|
||||
struct Configuration {
|
||||
/** HAL configuration (drivers) */
|
||||
const hal::Configuration* hardware = nullptr;
|
||||
/** List of user applications */
|
||||
const std::vector<const app::AppManifest*> apps = {};
|
||||
/** List of user services */
|
||||
const std::vector<const service::ServiceManifest*> services = {};
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
#include "Tactility/app/AppManifestParsing.h"
|
||||
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/TactilityConfig.h>
|
||||
|
||||
#include <Tactility/app/AppManifestParsing.h>
|
||||
#include <Tactility/app/AppRegistration.h>
|
||||
#include <Tactility/DispatcherThread.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/file/FileLock.h>
|
||||
#include <Tactility/file/PropertiesFile.h>
|
||||
#include <Tactility/hal/HalPrivate.h>
|
||||
#include <Tactility/lvgl/LvglPrivate.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/network/NtpPrivate.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
@ -18,6 +17,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <format>
|
||||
#include <Tactility/file/FileLock.h>
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include <Tactility/InitEsp.h>
|
||||
@ -59,11 +59,13 @@ namespace app {
|
||||
namespace alertdialog { extern const AppManifest manifest; }
|
||||
namespace applist { extern const AppManifest manifest; }
|
||||
namespace boot { extern const AppManifest manifest; }
|
||||
namespace calculator { extern const AppManifest manifest; }
|
||||
namespace chat { extern const AppManifest manifest; }
|
||||
namespace development { extern const AppManifest manifest; }
|
||||
namespace display { extern const AppManifest manifest; }
|
||||
namespace files { extern const AppManifest manifest; }
|
||||
namespace fileselection { extern const AppManifest manifest; }
|
||||
namespace gpio { extern const AppManifest manifest; }
|
||||
namespace gpssettings { extern const AppManifest manifest; }
|
||||
namespace i2cscanner { extern const AppManifest manifest; }
|
||||
namespace i2csettings { extern const AppManifest manifest; }
|
||||
@ -97,12 +99,14 @@ namespace app {
|
||||
// endregion
|
||||
|
||||
// List of all apps excluding Boot app (as Boot app calls this function indirectly)
|
||||
static void registerInternalApps() {
|
||||
static void registerSystemApps() {
|
||||
addApp(app::alertdialog::manifest);
|
||||
addApp(app::applist::manifest);
|
||||
addApp(app::calculator::manifest);
|
||||
addApp(app::display::manifest);
|
||||
addApp(app::files::manifest);
|
||||
addApp(app::fileselection::manifest);
|
||||
addApp(app::gpio::manifest);
|
||||
addApp(app::imageviewer::manifest);
|
||||
addApp(app::inputdialog::manifest);
|
||||
addApp(app::launcher::manifest);
|
||||
@ -199,6 +203,14 @@ static void registerInstalledAppsFromSdCards() {
|
||||
}
|
||||
}
|
||||
|
||||
static void registerUserApps(const std::vector<const app::AppManifest*>& apps) {
|
||||
TT_LOG_I(TAG, "Registering user apps");
|
||||
for (auto* manifest : apps) {
|
||||
assert(manifest != nullptr);
|
||||
addApp(*manifest);
|
||||
}
|
||||
}
|
||||
|
||||
static void registerAndStartSecondaryServices() {
|
||||
TT_LOG_I(TAG, "Registering and starting system services");
|
||||
addService(service::loader::manifest);
|
||||
@ -220,13 +232,28 @@ static void registerAndStartPrimaryServices() {
|
||||
#endif
|
||||
}
|
||||
|
||||
static void registerAndStartUserServices(const std::vector<const service::ServiceManifest*>& manifests) {
|
||||
TT_LOG_I(TAG, "Registering and starting user services");
|
||||
for (auto* manifest : manifests) {
|
||||
assert(manifest != nullptr);
|
||||
addService(*manifest);
|
||||
}
|
||||
}
|
||||
|
||||
void initFromBootApp() {
|
||||
registerInternalApps();
|
||||
auto configuration = getConfiguration();
|
||||
// Then we register apps. They are not used/started yet.
|
||||
registerSystemApps();
|
||||
auto data_apps_path = std::format("{}/apps", file::MOUNT_POINT_DATA);
|
||||
if (file::isDirectory(data_apps_path)) {
|
||||
registerInstalledApps(data_apps_path);
|
||||
}
|
||||
registerInstalledAppsFromSdCards();
|
||||
// Then we register and start user services. They are started after system app
|
||||
// registration just in case they want to figure out which system apps are installed.
|
||||
registerAndStartUserServices(configuration->services);
|
||||
// Now we register the user apps, as they might rely on the user services.
|
||||
registerUserApps(configuration->apps);
|
||||
}
|
||||
|
||||
void run(const Configuration& config) {
|
||||
|
||||
233
Tactility/Source/app/calculator/Calculator.cpp
Normal file
233
Tactility/Source/app/calculator/Calculator.cpp
Normal file
@ -0,0 +1,233 @@
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/Assets.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <lvgl.h>
|
||||
#include <queue>
|
||||
#include <stack>
|
||||
|
||||
namespace tt::app::calculator {
|
||||
|
||||
constexpr const char* TAG = "Calculator";
|
||||
|
||||
class CalculatorApp : public App {
|
||||
|
||||
lv_obj_t* displayLabel;
|
||||
lv_obj_t* resultLabel;
|
||||
char formulaBuffer[128] = {0}; // Stores the full input expression
|
||||
bool newInput = true;
|
||||
|
||||
static void button_event_cb(lv_event_t* e) {
|
||||
CalculatorApp* self = static_cast<CalculatorApp*>(lv_event_get_user_data(e));
|
||||
lv_obj_t* btnm = lv_event_get_current_target_obj(e);
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
|
||||
uint32_t btn_id = lv_buttonmatrix_get_selected_button(btnm);
|
||||
const char* txt = lv_buttonmatrix_get_button_text(btnm, btn_id);
|
||||
|
||||
if (code == LV_EVENT_VALUE_CHANGED) {
|
||||
self->handleInput(txt);
|
||||
}
|
||||
}
|
||||
|
||||
void handleInput(const char* txt) {
|
||||
if (std::strcmp(txt, "C") == 0) {
|
||||
resetCalculator();
|
||||
return;
|
||||
}
|
||||
|
||||
if (std::strcmp(txt, "=") == 0) {
|
||||
evaluateExpression();
|
||||
return;
|
||||
}
|
||||
|
||||
if (std::strlen(formulaBuffer) + std::strlen(txt) < sizeof(formulaBuffer) - 1) {
|
||||
if (newInput) {
|
||||
std::memset(formulaBuffer, 0, sizeof(formulaBuffer));
|
||||
newInput = false;
|
||||
}
|
||||
std::strcat(formulaBuffer, txt);
|
||||
lv_label_set_text(displayLabel, formulaBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void evaluateExpression() {
|
||||
double result = computeFormula();
|
||||
|
||||
size_t formulaLen = std::strlen(formulaBuffer);
|
||||
size_t maxAvailable = sizeof(formulaBuffer) - formulaLen - 1;
|
||||
|
||||
if (maxAvailable > 10) {
|
||||
char resultBuffer[32];
|
||||
snprintf(resultBuffer, sizeof(resultBuffer), " = %.8g", result);
|
||||
strncat(formulaBuffer, resultBuffer, maxAvailable);
|
||||
} else {
|
||||
snprintf(formulaBuffer, sizeof(formulaBuffer), "%.8g", result);
|
||||
}
|
||||
|
||||
lv_label_set_text(displayLabel, "0");
|
||||
lv_label_set_text(resultLabel, formulaBuffer);
|
||||
newInput = true;
|
||||
}
|
||||
|
||||
double computeFormula() {
|
||||
return evaluateRPN(infixToRPN(std::string(formulaBuffer)));
|
||||
}
|
||||
|
||||
int precedence(char op) {
|
||||
if (op == '+' || op == '-') return 1;
|
||||
if (op == '*' || op == '/') return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::queue<std::string> infixToRPN(const std::string& infix) {
|
||||
std::stack<char> opStack;
|
||||
std::queue<std::string> output;
|
||||
std::string token;
|
||||
size_t i = 0;
|
||||
|
||||
while (i < infix.size()) {
|
||||
char ch = infix[i];
|
||||
|
||||
if (isdigit(ch)) {
|
||||
token.clear();
|
||||
while (i < infix.size() && (isdigit(infix[i]) || infix[i] == '.')) {
|
||||
token += infix[i++];
|
||||
}
|
||||
output.push(token);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '(') {
|
||||
opStack.push(ch);
|
||||
} else if (ch == ')') {
|
||||
while (!opStack.empty() && opStack.top() != '(') {
|
||||
output.push(std::string(1, opStack.top()));
|
||||
opStack.pop();
|
||||
}
|
||||
opStack.pop();
|
||||
} else if (strchr("+-*/", ch)) {
|
||||
while (!opStack.empty() && precedence(opStack.top()) >= precedence(ch)) {
|
||||
output.push(std::string(1, opStack.top()));
|
||||
opStack.pop();
|
||||
}
|
||||
opStack.push(ch);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
while (!opStack.empty()) {
|
||||
output.push(std::string(1, opStack.top()));
|
||||
opStack.pop();
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
double evaluateRPN(std::queue<std::string> rpnQueue) {
|
||||
std::stack<double> values;
|
||||
|
||||
while (!rpnQueue.empty()) {
|
||||
std::string token = rpnQueue.front();
|
||||
rpnQueue.pop();
|
||||
|
||||
if (isdigit(token[0])) {
|
||||
values.push(std::stod(token));
|
||||
} else if (strchr("+-*/", token[0])) {
|
||||
if (values.size() < 2) return 0;
|
||||
|
||||
double b = values.top();
|
||||
values.pop();
|
||||
double a = values.top();
|
||||
values.pop();
|
||||
|
||||
if (token[0] == '+') values.push(a + b);
|
||||
else if (token[0] == '-')
|
||||
values.push(a - b);
|
||||
else if (token[0] == '*')
|
||||
values.push(a * b);
|
||||
else if (token[0] == '/' && b != 0)
|
||||
values.push(a / b);
|
||||
}
|
||||
}
|
||||
|
||||
return values.empty() ? 0 : values.top();
|
||||
}
|
||||
|
||||
void resetCalculator() {
|
||||
std::memset(formulaBuffer, 0, sizeof(formulaBuffer));
|
||||
lv_label_set_text(displayLabel, "0");
|
||||
lv_label_set_text(resultLabel, "");
|
||||
newInput = true;
|
||||
}
|
||||
|
||||
void onShow(AppContext& context, lv_obj_t* parent) override {
|
||||
lv_obj_remove_flag(parent, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
|
||||
|
||||
lv_obj_t* toolbar = lvgl::toolbar_create(parent, context);
|
||||
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||
|
||||
lv_obj_t* wrapper = lv_obj_create(parent);
|
||||
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_flex_align(wrapper, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START);
|
||||
lv_obj_set_width(wrapper, LV_PCT(100));
|
||||
lv_obj_set_height(wrapper, LV_SIZE_CONTENT);
|
||||
lv_obj_set_flex_grow(wrapper, 0);
|
||||
lv_obj_set_style_pad_top(wrapper, 4, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_bottom(wrapper, 4, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_left(wrapper, 10, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_right(wrapper, 10, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_column(wrapper, 40, LV_PART_MAIN);
|
||||
lv_obj_set_style_border_width(wrapper, 0, 0);
|
||||
lv_obj_remove_flag(wrapper, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
displayLabel = lv_label_create(wrapper);
|
||||
lv_label_set_text(displayLabel, "0");
|
||||
lv_obj_set_width(displayLabel, LV_SIZE_CONTENT);
|
||||
lv_obj_set_align(displayLabel, LV_ALIGN_LEFT_MID);
|
||||
|
||||
resultLabel = lv_label_create(wrapper);
|
||||
lv_label_set_text(resultLabel, "");
|
||||
lv_obj_set_width(resultLabel, LV_SIZE_CONTENT);
|
||||
lv_obj_set_align(resultLabel, LV_ALIGN_RIGHT_MID);
|
||||
|
||||
static const char* btn_map[] = {
|
||||
"(", ")", "C", "/", "\n",
|
||||
"7", "8", "9", "*", "\n",
|
||||
"4", "5", "6", "-", "\n",
|
||||
"1", "2", "3", "+", "\n",
|
||||
"0", "=", "", "", ""
|
||||
};
|
||||
|
||||
lv_obj_t* btnm = lv_btnmatrix_create(parent);
|
||||
lv_btnmatrix_set_map(btnm, btn_map);
|
||||
|
||||
lv_obj_set_style_pad_all(btnm, 5, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_row(btnm, 10, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_column(btnm, 5, LV_PART_MAIN);
|
||||
lv_obj_set_style_border_width(btnm, 2, LV_PART_MAIN);
|
||||
lv_obj_set_style_bg_color(btnm, lv_palette_main(LV_PALETTE_BLUE), LV_PART_ITEMS);
|
||||
|
||||
if (lv_display_get_horizontal_resolution(nullptr) <= 240 || lv_display_get_vertical_resolution(nullptr) <= 240) { //small screens
|
||||
lv_obj_set_size(btnm, lv_pct(100), lv_pct(60));
|
||||
} else { //large screens
|
||||
lv_obj_set_size(btnm, lv_pct(100), lv_pct(80));
|
||||
}
|
||||
lv_obj_align(btnm, LV_ALIGN_BOTTOM_MID, 0, -5);
|
||||
|
||||
lv_obj_add_event_cb(btnm, button_event_cb, LV_EVENT_VALUE_CHANGED, this);
|
||||
}
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.appId = "Calculator",
|
||||
.appName = "Calculator",
|
||||
.appIcon = TT_ASSETS_APP_ICON_CALCULATOR,
|
||||
.createApp = create<CalculatorApp>
|
||||
};
|
||||
|
||||
} // namespace tt::app::calculator
|
||||
206
Tactility/Source/app/gpio/Gpio.cpp
Normal file
206
Tactility/Source/app/gpio/Gpio.cpp
Normal file
@ -0,0 +1,206 @@
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#include <Tactility/Assets.h>
|
||||
#include <Tactility/hal/gpio/Gpio.h>
|
||||
#include "Tactility/lvgl/Toolbar.h"
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/lvgl/Color.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
namespace tt::app::gpio {
|
||||
|
||||
extern const AppManifest manifest;
|
||||
|
||||
class GpioApp : public App {
|
||||
|
||||
std::vector<lv_obj_t*> pinWidgets;
|
||||
std::vector<bool> pinStates;
|
||||
std::unique_ptr<Timer> timer;
|
||||
Mutex mutex;
|
||||
|
||||
static lv_obj_t* createGpioRowWrapper(lv_obj_t* parent);
|
||||
void onTimer();
|
||||
|
||||
public:
|
||||
|
||||
void onShow(AppContext& app, lv_obj_t* parent) override;
|
||||
void onHide(AppContext& app) override;
|
||||
|
||||
void startTask();
|
||||
void stopTask();
|
||||
|
||||
void updatePinStates();
|
||||
void updatePinWidgets();
|
||||
};
|
||||
|
||||
void GpioApp::updatePinStates() {
|
||||
mutex.lock();
|
||||
// Update pin states
|
||||
for (int i = 0; i < pinStates.size(); ++i) {
|
||||
pinStates[i] = hal::gpio::getLevel(i);
|
||||
}
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void GpioApp::updatePinWidgets() {
|
||||
auto scoped_lvgl_lock = lvgl::getSyncLock()->asScopedLock();
|
||||
auto scoped_gpio_lock = mutex.asScopedLock();
|
||||
if (scoped_gpio_lock.lock() && scoped_lvgl_lock.lock(lvgl::defaultLockTime)) {
|
||||
assert(pinStates.size() == pinWidgets.size());
|
||||
for (int j = 0; j < pinStates.size(); ++j) {
|
||||
int level = pinStates[j];
|
||||
lv_obj_t* label = pinWidgets[j];
|
||||
void* label_user_data = lv_obj_get_user_data(label);
|
||||
// The user data stores the state, so we can avoid unnecessary updates
|
||||
if (reinterpret_cast<void*>(level) != label_user_data) {
|
||||
lv_obj_set_user_data(label, reinterpret_cast<void*>(level));
|
||||
if (level == 0) {
|
||||
lv_obj_set_style_text_color(label, lv_color_background_darkest(), LV_STATE_DEFAULT);
|
||||
} else {
|
||||
lv_obj_set_style_text_color(label, lv_color_make(0, 200, 0), LV_STATE_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_t* GpioApp::createGpioRowWrapper(lv_obj_t* parent) {
|
||||
lv_obj_t* wrapper = lv_obj_create(parent);
|
||||
lv_obj_set_style_pad_all(wrapper, 0, LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_border_width(wrapper, 0, LV_STATE_DEFAULT);
|
||||
lv_obj_set_size(wrapper, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
// region Task
|
||||
|
||||
void GpioApp::onTimer() {
|
||||
updatePinStates();
|
||||
updatePinWidgets();
|
||||
}
|
||||
|
||||
void GpioApp::startTask() {
|
||||
mutex.lock();
|
||||
assert(timer == nullptr);
|
||||
timer = std::make_unique<Timer>(Timer::Type::Periodic, [this] {
|
||||
onTimer();
|
||||
});
|
||||
timer->start(100 / portTICK_PERIOD_MS);
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void GpioApp::stopTask() {
|
||||
assert(timer);
|
||||
|
||||
timer->stop();
|
||||
timer = nullptr;
|
||||
}
|
||||
|
||||
// endregion Task
|
||||
|
||||
static int getSquareSpacing(hal::UiScale uiScale) {
|
||||
if (uiScale == hal::UiScale::Smallest) {
|
||||
return 0;
|
||||
} else {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
void GpioApp::onShow(AppContext& app, lv_obj_t* parent) {
|
||||
auto ui_scale = hal::getConfiguration()->uiScale;
|
||||
|
||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
|
||||
|
||||
auto* toolbar = lvgl::toolbar_create(parent, app);
|
||||
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||
|
||||
// Main content wrapper, enables scrolling content without scrolling the toolbar
|
||||
auto* expansion_wrapper = lv_obj_create(parent);
|
||||
lv_obj_set_width(expansion_wrapper, LV_PCT(100));
|
||||
lv_obj_set_flex_grow(expansion_wrapper, 1);
|
||||
lv_obj_set_style_border_width(expansion_wrapper, 0, LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_all(expansion_wrapper, 0, LV_STATE_DEFAULT);
|
||||
|
||||
auto* centering_wrapper = lv_obj_create(expansion_wrapper);
|
||||
lv_obj_set_size(centering_wrapper, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_obj_set_align(centering_wrapper, LV_ALIGN_CENTER);
|
||||
lv_obj_set_style_border_width(centering_wrapper, 0, LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_all(centering_wrapper, 0, LV_STATE_DEFAULT);
|
||||
|
||||
auto* display = lv_obj_get_display(parent);
|
||||
auto horizontal_px = lv_display_get_horizontal_resolution(display);
|
||||
auto vertical_px = lv_display_get_vertical_resolution(display);
|
||||
bool is_landscape_display = horizontal_px > vertical_px;
|
||||
|
||||
constexpr auto block_width = 16;
|
||||
const auto square_spacing = getSquareSpacing(ui_scale);
|
||||
int32_t x_spacing = block_width + square_spacing;
|
||||
uint8_t column = 0;
|
||||
const uint8_t column_limit = is_landscape_display ? 10 : 5;
|
||||
|
||||
auto* row_wrapper = createGpioRowWrapper(centering_wrapper);
|
||||
lv_obj_align(row_wrapper, LV_ALIGN_TOP_MID, 0, 0);
|
||||
|
||||
mutex.lock();
|
||||
|
||||
auto pin_count = hal::gpio::getPinCount();
|
||||
pinStates.resize(pin_count);
|
||||
pinWidgets.resize(pin_count);
|
||||
|
||||
for (int i = 0; i < pin_count; ++i) {
|
||||
constexpr uint8_t offset_from_left_label = 4;
|
||||
|
||||
// Add the GPIO number before the first item on a row
|
||||
if (column == 0) {
|
||||
auto* prefix = lv_label_create(row_wrapper);
|
||||
lv_label_set_text_fmt(prefix, "%02d", i);
|
||||
}
|
||||
|
||||
// Add a new GPIO status indicator
|
||||
auto* status_label = lv_label_create(row_wrapper);
|
||||
lv_obj_set_pos(status_label, (column+1) * x_spacing + offset_from_left_label, 0);
|
||||
lv_label_set_text_fmt(status_label, "%s", LV_SYMBOL_STOP);
|
||||
lv_obj_set_style_text_color(status_label, lv_color_background_darkest(), LV_STATE_DEFAULT);
|
||||
pinWidgets[i] = status_label;
|
||||
pinStates[i] = false;
|
||||
|
||||
column++;
|
||||
|
||||
if (column >= column_limit) {
|
||||
// Add the GPIO number after the last item on a row
|
||||
auto* postfix = lv_label_create(row_wrapper);
|
||||
lv_label_set_text_fmt(postfix, "%02d", i);
|
||||
lv_obj_set_pos(postfix, (column + 1) * x_spacing + offset_from_left_label, 0);
|
||||
|
||||
// Add a new row wrapper underneath the last one
|
||||
auto* new_row_wrapper = createGpioRowWrapper(centering_wrapper);
|
||||
lv_obj_align_to(new_row_wrapper, row_wrapper, LV_ALIGN_BOTTOM_LEFT, 0, square_spacing);
|
||||
row_wrapper = new_row_wrapper;
|
||||
|
||||
column = 0;
|
||||
}
|
||||
}
|
||||
mutex.unlock();
|
||||
|
||||
startTask();
|
||||
}
|
||||
|
||||
void GpioApp::onHide(AppContext& app) {
|
||||
stopTask();
|
||||
|
||||
mutex.lock();
|
||||
pinWidgets.clear();
|
||||
pinStates.clear();
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.appId = "Gpio",
|
||||
.appName = "GPIO",
|
||||
.appIcon = TT_ASSETS_APP_ICON_GPIO,
|
||||
.appCategory = Category::System,
|
||||
.createApp = create<GpioApp>
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@ -1,11 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <tt_bundle.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include "tt_app_manifest.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -13,44 +11,6 @@ extern "C" {
|
||||
|
||||
typedef void* AppHandle;
|
||||
|
||||
/** Important: These values must map to tt::app::Result values exactly */
|
||||
typedef enum {
|
||||
APP_RESULT_OK = 0,
|
||||
APP_RESULT_CANCELLED = 1,
|
||||
APP_RESULT_ERROR = 2
|
||||
} AppResult;
|
||||
|
||||
typedef unsigned int AppLaunchId;
|
||||
|
||||
/** Important: These function types must map to t::app types exactly */
|
||||
typedef void* (*AppCreateData)();
|
||||
typedef void (*AppDestroyData)(void* data);
|
||||
typedef void (*AppOnCreate)(AppHandle app, void* _Nullable data);
|
||||
typedef void (*AppOnDestroy)(AppHandle app, void* _Nullable data);
|
||||
typedef void (*AppOnShow)(AppHandle app, void* _Nullable data, lv_obj_t* parent);
|
||||
typedef void (*AppOnHide)(AppHandle app, void* _Nullable data);
|
||||
typedef void (*AppOnResult)(AppHandle app, void* _Nullable data, AppLaunchId launchId, AppResult result, BundleHandle resultData);
|
||||
|
||||
typedef struct {
|
||||
/** The application can allocate data to re-use later (e.g. struct with state) */
|
||||
AppCreateData _Nullable createData;
|
||||
/** If createData is specified, this one must be specified too */
|
||||
AppDestroyData _Nullable destroyData;
|
||||
/** Called when the app is launched (started) */
|
||||
AppOnCreate _Nullable onCreate;
|
||||
/** Called when the app is exited (stopped) */
|
||||
AppOnDestroy _Nullable onDestroy;
|
||||
/** Called when the app is about to be shown to the user (app becomes visible) */
|
||||
AppOnShow _Nullable onShow;
|
||||
/** Called when the app is about to be invisible to the user (e.g. other app was launched by this app, and this app goes to the background) */
|
||||
AppOnHide _Nullable onHide;
|
||||
/** Called when the app receives a result after launching another app */
|
||||
AppOnResult _Nullable onResult;
|
||||
} AppRegistration;
|
||||
|
||||
/** This is used to register the manifest of an external app. */
|
||||
void tt_app_register(const AppRegistration app);
|
||||
|
||||
/** @return the bundle that belongs to this application, or null if it wasn't started with parameters. */
|
||||
BundleHandle _Nullable tt_app_get_parameters(AppHandle handle);
|
||||
|
||||
|
||||
52
TactilityC/Include/tt_app_manifest.h
Normal file
52
TactilityC/Include/tt_app_manifest.h
Normal file
@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include "tt_bundle.h"
|
||||
#include <lvgl.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Important: These values must map to tt::app::Result values exactly */
|
||||
typedef enum {
|
||||
APP_RESULT_OK = 0,
|
||||
APP_RESULT_CANCELLED = 1,
|
||||
APP_RESULT_ERROR = 2
|
||||
} AppResult;
|
||||
|
||||
typedef void* AppHandle;
|
||||
|
||||
typedef unsigned int AppLaunchId;
|
||||
|
||||
/** Important: These function types must map to t::app types exactly */
|
||||
typedef void* (*AppCreateData)();
|
||||
typedef void (*AppDestroyData)(void* data);
|
||||
typedef void (*AppOnCreate)(AppHandle app, void* _Nullable data);
|
||||
typedef void (*AppOnDestroy)(AppHandle app, void* _Nullable data);
|
||||
typedef void (*AppOnShow)(AppHandle app, void* _Nullable data, lv_obj_t* parent);
|
||||
typedef void (*AppOnHide)(AppHandle app, void* _Nullable data);
|
||||
typedef void (*AppOnResult)(AppHandle app, void* _Nullable data, AppLaunchId launchId, AppResult result, BundleHandle resultData);
|
||||
|
||||
typedef struct {
|
||||
/** The application can allocate data to re-use later (e.g. struct with state) */
|
||||
AppCreateData _Nullable createData;
|
||||
/** If createData is specified, this one must be specified too */
|
||||
AppDestroyData _Nullable destroyData;
|
||||
/** Called when the app is launched (started) */
|
||||
AppOnCreate _Nullable onCreate;
|
||||
/** Called when the app is exited (stopped) */
|
||||
AppOnDestroy _Nullable onDestroy;
|
||||
/** Called when the app is about to be shown to the user (app becomes visible) */
|
||||
AppOnShow _Nullable onShow;
|
||||
/** Called when the app is about to be invisible to the user (e.g. other app was launched by this app, and this app goes to the background) */
|
||||
AppOnHide _Nullable onHide;
|
||||
/** Called when the app receives a result after launching another app */
|
||||
AppOnResult _Nullable onResult;
|
||||
} ExternalAppManifest;
|
||||
|
||||
/** This is used to register the manifest of an external app. */
|
||||
void tt_app_register(const ExternalAppManifest* manifest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@ -2,7 +2,6 @@
|
||||
#include <Tactility/app/App.h>
|
||||
#include <Tactility/app/AppPaths.h>
|
||||
#include <Tactility/app/AppContext.h>
|
||||
#include <Tactility/app/ElfApp.h>
|
||||
#include <Tactility/file/FileLock.h>
|
||||
|
||||
extern "C" {
|
||||
@ -11,25 +10,6 @@ constexpr auto* TAG = "tt_app";
|
||||
|
||||
#define HANDLE_AS_APP_CONTEXT(handle) ((tt::app::AppContext*)(handle))
|
||||
|
||||
void tt_app_register(
|
||||
const AppRegistration appRegistration
|
||||
) {
|
||||
#ifdef ESP_PLATFORM
|
||||
assert((appRegistration.createData == nullptr) == (appRegistration.destroyData == nullptr));
|
||||
tt::app::setElfAppParameters(
|
||||
appRegistration.createData,
|
||||
appRegistration.destroyData,
|
||||
appRegistration.onCreate,
|
||||
appRegistration.onDestroy,
|
||||
appRegistration.onShow,
|
||||
appRegistration.onHide,
|
||||
reinterpret_cast<tt::app::OnResult>(appRegistration.onResult)
|
||||
);
|
||||
#else
|
||||
tt_crash("TactilityC is not intended for PC/Simulator");
|
||||
#endif
|
||||
}
|
||||
|
||||
BundleHandle _Nullable tt_app_get_parameters(AppHandle handle) {
|
||||
return (BundleHandle)HANDLE_AS_APP_CONTEXT(handle)->getParameters().get();
|
||||
}
|
||||
|
||||
29
TactilityC/Source/tt_app_manifest.cpp
Normal file
29
TactilityC/Source/tt_app_manifest.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "tt_app_manifest.h"
|
||||
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/app/ElfApp.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
constexpr auto TAG = "tt_app";
|
||||
|
||||
void tt_app_register(
|
||||
const ExternalAppManifest* manifest
|
||||
) {
|
||||
#ifdef ESP_PLATFORM
|
||||
assert((manifest->createData == nullptr) == (manifest->destroyData == nullptr));
|
||||
tt::app::setElfAppParameters(
|
||||
manifest->createData,
|
||||
manifest->destroyData,
|
||||
manifest->onCreate,
|
||||
manifest->onDestroy,
|
||||
manifest->onShow,
|
||||
manifest->onHide,
|
||||
reinterpret_cast<tt::app::OnResult>(manifest->onResult)
|
||||
);
|
||||
#else
|
||||
tt_crash("TactilityC is not intended for PC/Simulator");
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
#include "tt_app.h"
|
||||
#include "tt_app_alertdialog.h"
|
||||
#include "tt_app_manifest.h"
|
||||
#include "tt_app_selectiondialog.h"
|
||||
#include "tt_bundle.h"
|
||||
#include "tt_file.h"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user