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:
committed by
GitHub
parent
e1579d3cbd
commit
b39bd6b6f5
@@ -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;
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user