Simplify app registration with TactilityCpp (#7)

- Simplified app registration with a C++ wrapper for the TactilityC.
- Rename the various app classes from `Application` to more specific names like `Calculator` etc.
This commit is contained in:
Ken Van Hoeylandt
2025-10-05 22:38:26 +02:00
committed by GitHub
parent e1579d3cbd
commit b39bd6b6f5
12 changed files with 117 additions and 114 deletions
+3 -2
View File
@@ -5,8 +5,9 @@
#include <lvgl.h>
#include <deque>
#include <Str.h>
#include <TactilityCpp/App.h>
class Calculator {
class Calculator final : public App {
lv_obj_t* displayLabel;
lv_obj_t* resultLabel;
@@ -23,5 +24,5 @@ class Calculator {
public:
void onShow(AppHandle context, lv_obj_t* parent);
void onShow(AppHandle context, lv_obj_t* parent) override;
};
+2 -18
View File
@@ -1,26 +1,10 @@
#include <tt_app.h>
#include "Calculator.h"
static void onShowApp(AppHandle appHandle, void* data, lv_obj_t* parent) {
static_cast<Calculator*>(data)->onShow(appHandle, parent);
}
static void* createAppData() {
return new Calculator();
}
static void destroyAppData(void* app) {
delete static_cast<Calculator*>(app);
}
#include <TactilityCpp/App.h>
extern "C" {
int main(int argc, char* argv[]) {
tt_app_register((AppRegistration) {
.createData = createAppData,
.destroyData = destroyAppData,
.onShow = onShowApp,
});
registerApp<Calculator>();
return 0;
}