mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
64 lines
2.1 KiB
C++
64 lines
2.1 KiB
C++
#include "../../../Tactility/Private/Tactility/service/gui/GuiService.h"
|
|
|
|
#include <Tactility/app/AppManifest.h>
|
|
#include <Tactility/lvgl/Toolbar.h>
|
|
#include <lvgl.h>
|
|
#include <Tactility/hal/Device.h>
|
|
#include <Tactility/hal/display/DisplayDevice.h>
|
|
#include <Tactility/hal/display/NativeDisplay.h>
|
|
#include <Tactility/service/ServiceRegistry.h>
|
|
|
|
using namespace tt::app;
|
|
|
|
class HelloWorldApp : public App {
|
|
|
|
std::shared_ptr<tt::hal::display::DisplayDevice> displayDevice;
|
|
// 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);
|
|
// }
|
|
|
|
void onCreate(AppContext& appContext) override {
|
|
tt::service::stopService("Statusbar");
|
|
tt::service::stopService("Gui");
|
|
|
|
using namespace tt::hal;
|
|
displayDevice = findFirstDevice<display::DisplayDevice>(Device::Type::Display);
|
|
if (displayDevice == nullptr) {
|
|
TT_LOG_E("HelloWorld", "Display device not found");
|
|
stop();
|
|
} else {
|
|
if (displayDevice->supportsLvgl() && displayDevice->getLvglDisplay() != nullptr) {
|
|
if (!displayDevice->stopLvgl()) {
|
|
TT_LOG_E("HelloWorld", "Failed to detach display from LVGL");
|
|
}
|
|
}
|
|
}
|
|
|
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
|
stop(); // stop this app
|
|
}
|
|
|
|
void onDestroy(AppContext& appContext) override {
|
|
if (displayDevice != nullptr) {
|
|
if (displayDevice->supportsLvgl() && displayDevice->getLvglDisplay() == nullptr) {
|
|
TT_LOG_I("HelloWorld", "Starting LVGL");
|
|
displayDevice->startLvgl();
|
|
}
|
|
}
|
|
|
|
tt::service::startService("Gui");
|
|
tt::service::startService("Statusbar");
|
|
}
|
|
};
|
|
|
|
extern const AppManifest hello_world_app = {
|
|
.id = "HelloWorld",
|
|
.name = "Hello World",
|
|
.createApp = create<HelloWorldApp>
|
|
};
|