C++ refactoring (#91)
This commit is contained in:
committed by
GitHub
parent
d06137ba76
commit
ca5d4b8226
@@ -1,33 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "App.h"
|
||||
|
||||
#include "AppManifest.h"
|
||||
#include "Mutex.h"
|
||||
|
||||
namespace tt {
|
||||
|
||||
class AppData {
|
||||
public:
|
||||
Mutex* mutex;
|
||||
const AppManifest* manifest;
|
||||
AppState state = AppStateInitial;
|
||||
/** @brief Memory marker at start of app, to detect memory leaks */
|
||||
size_t memory = 0;
|
||||
AppFlags flags = {
|
||||
.flags = 0
|
||||
};
|
||||
/** @brief Optional parameters to start the app with
|
||||
* When these are stored in the app struct, the struct takes ownership.
|
||||
* Do not mutate after app creation.
|
||||
*/
|
||||
Bundle parameters;
|
||||
/** @brief @brief Contextual data related to the running app's instance
|
||||
* The app can attach its data to this.
|
||||
* The lifecycle is determined by the on_start and on_stop methods in the AppManifest.
|
||||
* These manifest methods can optionally allocate/free data that is attached here.
|
||||
*/
|
||||
void* _Nullable data = nullptr;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Hal/Configuration.h"
|
||||
|
||||
namespace tt {
|
||||
|
||||
void lvgl_init(const hal::Configuration* config);
|
||||
|
||||
} // namespace
|
||||
@@ -3,9 +3,9 @@
|
||||
#include "MessageQueue.h"
|
||||
#include "Mutex.h"
|
||||
#include "Pubsub.h"
|
||||
#include "Services/Gui/Gui.h"
|
||||
#include "Services/Gui/ViewPort.h"
|
||||
#include "Services/Gui/ViewPort_i.h"
|
||||
#include "service/gui/Gui.h"
|
||||
#include "service/gui/ViewPort.h"
|
||||
#include "service/gui/ViewPort_i.h"
|
||||
#include <cstdio>
|
||||
|
||||
namespace tt::service::gui {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Services/Gui/ViewPort.h"
|
||||
#include "service/gui/ViewPort.h"
|
||||
|
||||
namespace tt::service::gui {
|
||||
|
||||
+7
-9
@@ -1,12 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "ApiLock.h"
|
||||
#include "AppManifest.h"
|
||||
#include "app/Manifest.h"
|
||||
#include "MessageQueue.h"
|
||||
#include "Pubsub.h"
|
||||
#include "Thread.h"
|
||||
#include "Services/Gui/ViewPort.h"
|
||||
#include "Services/Loader/Loader.h"
|
||||
#include "service/gui/ViewPort.h"
|
||||
#include "service/loader/Loader.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "freertos/FreeRTOS.h"
|
||||
@@ -53,8 +52,7 @@ public:
|
||||
// This lock blocks anyone from starting an app as long
|
||||
// as an app is already running via loader_start()
|
||||
// This lock's lifecycle is not owned by this class.
|
||||
// TODO: Convert to smart pointer
|
||||
ApiLock api_lock;
|
||||
EventFlag* _Nullable api_lock;
|
||||
LoaderMessageType type;
|
||||
|
||||
struct {
|
||||
@@ -93,8 +91,8 @@ public:
|
||||
result = { .raw_value = nullptr };
|
||||
}
|
||||
|
||||
void setLock(ApiLock lock) {
|
||||
api_lock = lock;
|
||||
void setApiLock(EventFlag* eventFlag) {
|
||||
api_lock = eventFlag;
|
||||
}
|
||||
|
||||
void cleanup() {
|
||||
@@ -111,7 +109,7 @@ struct Loader {
|
||||
MessageQueue queue = MessageQueue(1, sizeof(LoaderMessage));
|
||||
Mutex* mutex;
|
||||
int8_t app_stack_index;
|
||||
App app_stack[APP_STACK_SIZE];
|
||||
app::App app_stack[APP_STACK_SIZE];
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "hal/Configuration.h"
|
||||
|
||||
namespace tt::ui {
|
||||
|
||||
void initLvgl(const hal::Configuration* config);
|
||||
|
||||
} // namespace
|
||||
@@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "AppManifest.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace tt {
|
||||
|
||||
void app_manifest_registry_init();
|
||||
void app_manifest_registry_add(const AppManifest* manifest);
|
||||
void app_manifest_registry_remove(const AppManifest* manifest);
|
||||
const AppManifest _Nullable* app_manifest_registry_find_by_id(const std::string& id);
|
||||
std::vector<const AppManifest*> app_manifest_registry_get();
|
||||
|
||||
} // namespace
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "Tactility.h"
|
||||
|
||||
#include "AppManifestRegistry.h"
|
||||
#include "LvglInit_i.h"
|
||||
#include "ServiceRegistry.h"
|
||||
#include "app/ManifestRegistry.h"
|
||||
#include "service/ServiceRegistry.h"
|
||||
#include "service/loader/Loader.h"
|
||||
#include "TactilityHeadless.h"
|
||||
#include "Services/Loader/Loader.h"
|
||||
#include "ui/LvglInit_i.h"
|
||||
|
||||
namespace tt {
|
||||
|
||||
@@ -15,13 +15,13 @@ static const Configuration* config_instance = NULL;
|
||||
// region Default services
|
||||
|
||||
namespace service {
|
||||
namespace gui { extern const ServiceManifest manifest; }
|
||||
namespace loader { extern const ServiceManifest manifest; }
|
||||
namespace screenshot { extern const ServiceManifest manifest; }
|
||||
namespace statusbar { extern const ServiceManifest manifest; }
|
||||
namespace gui { extern const Manifest manifest; }
|
||||
namespace loader { extern const Manifest manifest; }
|
||||
namespace screenshot { extern const Manifest manifest; }
|
||||
namespace statusbar { extern const Manifest manifest; }
|
||||
}
|
||||
|
||||
static const std::vector<const ServiceManifest*> system_services = {
|
||||
static const std::vector<const service::Manifest*> system_services = {
|
||||
&service::loader::manifest,
|
||||
&service::gui::manifest, // depends on loader service
|
||||
#ifndef ESP_PLATFORM // Screenshots don't work yet on ESP32
|
||||
@@ -35,26 +35,26 @@ static const std::vector<const ServiceManifest*> system_services = {
|
||||
// region Default apps
|
||||
|
||||
namespace app {
|
||||
namespace desktop { extern const AppManifest manifest; }
|
||||
namespace files { extern const AppManifest manifest; }
|
||||
namespace gpio { extern const AppManifest manifest; }
|
||||
namespace image_viewer { extern const AppManifest manifest; }
|
||||
namespace screenshot { extern const AppManifest manifest; }
|
||||
namespace settings { extern const AppManifest manifest; }
|
||||
namespace settings::display { extern const AppManifest manifest; }
|
||||
namespace settings::i2c { extern const AppManifest manifest; }
|
||||
namespace settings::power { extern const AppManifest manifest; }
|
||||
namespace system_info { extern const AppManifest manifest; }
|
||||
namespace text_viewer { extern const AppManifest manifest; }
|
||||
namespace wifi_connect { extern const AppManifest manifest; }
|
||||
namespace wifi_manage { extern const AppManifest manifest; }
|
||||
namespace desktop { extern const Manifest manifest; }
|
||||
namespace files { extern const Manifest manifest; }
|
||||
namespace gpio { extern const Manifest manifest; }
|
||||
namespace image_viewer { extern const Manifest manifest; }
|
||||
namespace screenshot { extern const Manifest manifest; }
|
||||
namespace settings { extern const Manifest manifest; }
|
||||
namespace settings::display { extern const Manifest manifest; }
|
||||
namespace settings::i2c { extern const Manifest manifest; }
|
||||
namespace settings::power { extern const Manifest manifest; }
|
||||
namespace system_info { extern const Manifest manifest; }
|
||||
namespace text_viewer { extern const Manifest manifest; }
|
||||
namespace wifi_connect { extern const Manifest manifest; }
|
||||
namespace wifi_manage { extern const Manifest manifest; }
|
||||
}
|
||||
|
||||
#ifndef ESP_PLATFORM
|
||||
extern const AppManifest screenshot_app;
|
||||
extern const app::Manifest screenshot_app;
|
||||
#endif
|
||||
|
||||
static const std::vector<const AppManifest*> system_apps = {
|
||||
static const std::vector<const app::Manifest*> system_apps = {
|
||||
&app::desktop::manifest,
|
||||
&app::files::manifest,
|
||||
&app::gpio::manifest,
|
||||
@@ -84,10 +84,10 @@ static void register_system_apps() {
|
||||
}
|
||||
}
|
||||
|
||||
static void register_user_apps(const AppManifest* const apps[TT_CONFIG_APPS_LIMIT]) {
|
||||
static void register_user_apps(const app::Manifest* const apps[TT_CONFIG_APPS_LIMIT]) {
|
||||
TT_LOG_I(TAG, "Registering user apps");
|
||||
for (size_t i = 0; i < TT_CONFIG_APPS_LIMIT; i++) {
|
||||
const AppManifest* manifest = apps[i];
|
||||
const app::Manifest* manifest = apps[i];
|
||||
if (manifest != nullptr) {
|
||||
app_manifest_registry_add(manifest);
|
||||
} else {
|
||||
@@ -100,18 +100,18 @@ static void register_user_apps(const AppManifest* const apps[TT_CONFIG_APPS_LIMI
|
||||
static void register_and_start_system_services() {
|
||||
TT_LOG_I(TAG, "Registering and starting system services");
|
||||
for (const auto& service_manifest: system_services) {
|
||||
service_registry_add(service_manifest);
|
||||
tt_check(service_registry_start(service_manifest->id));
|
||||
addService(service_manifest);
|
||||
tt_check(service::startService(service_manifest->id));
|
||||
}
|
||||
}
|
||||
|
||||
static void register_and_start_user_services(const ServiceManifest* const services[TT_CONFIG_SERVICES_LIMIT]) {
|
||||
static void register_and_start_user_services(const service::Manifest* const services[TT_CONFIG_SERVICES_LIMIT]) {
|
||||
TT_LOG_I(TAG, "Registering and starting user services");
|
||||
for (size_t i = 0; i < TT_CONFIG_SERVICES_LIMIT; i++) {
|
||||
const ServiceManifest* manifest = services[i];
|
||||
const service::Manifest* manifest = services[i];
|
||||
if (manifest != nullptr) {
|
||||
service_registry_add(manifest);
|
||||
tt_check(service_registry_start(manifest->id));
|
||||
addService(manifest);
|
||||
tt_check(service::startService(manifest->id));
|
||||
} else {
|
||||
// reached end of list
|
||||
break;
|
||||
@@ -127,9 +127,9 @@ void init(const Configuration* config) {
|
||||
|
||||
initHeadless(*config->hardware);
|
||||
|
||||
lvgl_init(config->hardware);
|
||||
ui::initLvgl(config->hardware);
|
||||
|
||||
app_manifest_registry_init();
|
||||
app::app_manifest_registry_init();
|
||||
|
||||
// Note: the order of starting apps and services is critical!
|
||||
// System services are registered first so the apps below can find them if needed
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "AppManifest.h"
|
||||
#include "Hal/Configuration.h"
|
||||
#include "ServiceManifest.h"
|
||||
#include "app/Manifest.h"
|
||||
#include "hal/Configuration.h"
|
||||
#include "service/Manifest.h"
|
||||
#include "TactilityConfig.h"
|
||||
|
||||
namespace tt {
|
||||
@@ -10,8 +10,8 @@ namespace tt {
|
||||
typedef struct {
|
||||
const hal::Configuration* hardware;
|
||||
// List of user applications
|
||||
const AppManifest* const apps[TT_CONFIG_APPS_LIMIT];
|
||||
const ServiceManifest* const services[TT_CONFIG_SERVICES_LIMIT];
|
||||
const app::Manifest* const apps[TT_CONFIG_APPS_LIMIT];
|
||||
const service::Manifest* const services[TT_CONFIG_SERVICES_LIMIT];
|
||||
const char* auto_start_app_id;
|
||||
} Configuration;
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#include "App_i.h"
|
||||
#include "app/App.h"
|
||||
|
||||
namespace tt {
|
||||
namespace tt::app {
|
||||
|
||||
#define TAG "app"
|
||||
|
||||
void AppInstance::setState(AppState newState) {
|
||||
void AppInstance::setState(State newState) {
|
||||
mutex.acquire(TtWaitForever);
|
||||
state = newState;
|
||||
mutex.release();
|
||||
}
|
||||
|
||||
AppState AppInstance::getState() {
|
||||
State AppInstance::getState() {
|
||||
mutex.acquire(TtWaitForever);
|
||||
auto result = state;
|
||||
mutex.release();
|
||||
@@ -23,18 +23,18 @@ AppState AppInstance::getState() {
|
||||
* Consider creating MutableBundle vs Bundle.
|
||||
* Consider not exposing bundle, but expose `app_get_bundle_int(key)` methods with locking in it.
|
||||
*/
|
||||
const AppManifest& AppInstance::getManifest() {
|
||||
const Manifest& AppInstance::getManifest() {
|
||||
return manifest;
|
||||
}
|
||||
|
||||
AppFlags AppInstance::getFlags() {
|
||||
Flags AppInstance::getFlags() {
|
||||
mutex.acquire(TtWaitForever);
|
||||
auto result = flags;
|
||||
mutex.release();
|
||||
return result;
|
||||
}
|
||||
|
||||
void AppInstance::setFlags(AppFlags newFlags) {
|
||||
void AppInstance::setFlags(Flags newFlags) {
|
||||
mutex.acquire(TtWaitForever);
|
||||
flags = newFlags;
|
||||
mutex.release();
|
||||
@@ -57,7 +57,7 @@ const Bundle& AppInstance::getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
App tt_app_alloc(const AppManifest& manifest, const Bundle& parameters) {
|
||||
App tt_app_alloc(const Manifest& manifest, const Bundle& parameters) {
|
||||
auto* instance = new AppInstance(manifest, parameters);
|
||||
return static_cast<App>(instance);
|
||||
}
|
||||
@@ -67,23 +67,23 @@ void tt_app_free(App app) {
|
||||
delete instance;
|
||||
}
|
||||
|
||||
void tt_app_set_state(App app, AppState state) {
|
||||
void tt_app_set_state(App app, State state) {
|
||||
static_cast<AppInstance*>(app)->setState(state);
|
||||
}
|
||||
|
||||
AppState tt_app_get_state(App app) {
|
||||
State tt_app_get_state(App app) {
|
||||
return static_cast<AppInstance*>(app)->getState();
|
||||
}
|
||||
|
||||
const AppManifest& tt_app_get_manifest(App app) {
|
||||
const Manifest& tt_app_get_manifest(App app) {
|
||||
return static_cast<AppInstance*>(app)->getManifest();
|
||||
}
|
||||
|
||||
AppFlags tt_app_get_flags(App app) {
|
||||
Flags tt_app_get_flags(App app) {
|
||||
return static_cast<AppInstance*>(app)->getFlags();
|
||||
}
|
||||
|
||||
void tt_app_set_flags(App app, AppFlags flags) {
|
||||
void tt_app_set_flags(App app, Flags flags) {
|
||||
return static_cast<AppInstance*>(app)->setFlags(flags);
|
||||
}
|
||||
|
||||
@@ -1,32 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "AppManifest.h"
|
||||
#include "Manifest.h"
|
||||
#include "Bundle.h"
|
||||
#include "Mutex.h"
|
||||
|
||||
namespace tt {
|
||||
namespace tt::app {
|
||||
|
||||
typedef enum {
|
||||
AppStateInitial, // App is being activated in loader
|
||||
AppStateStarted, // App is in memory
|
||||
AppStateShowing, // App view is created
|
||||
AppStateHiding, // App view is destroyed
|
||||
AppStateStopped // App is not in memory
|
||||
} AppState;
|
||||
StateInitial, // App is being activated in loader
|
||||
StateStarted, // App is in memory
|
||||
StateShowing, // App view is created
|
||||
StateHiding, // App view is destroyed
|
||||
StateStopped // App is not in memory
|
||||
} State;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
bool show_statusbar : 1;
|
||||
};
|
||||
unsigned char flags;
|
||||
} AppFlags;
|
||||
} Flags;
|
||||
|
||||
|
||||
class AppInstance {
|
||||
|
||||
private:
|
||||
|
||||
Mutex mutex = Mutex(MutexTypeNormal);
|
||||
const AppManifest& manifest;
|
||||
AppState state = AppStateInitial;
|
||||
AppFlags flags = { .show_statusbar = true };
|
||||
const Manifest& manifest;
|
||||
State state = StateInitial;
|
||||
Flags flags = { .show_statusbar = true };
|
||||
/** @brief Optional parameters to start the app with
|
||||
* When these are stored in the app struct, the struct takes ownership.
|
||||
* Do not mutate after app creation.
|
||||
@@ -38,21 +41,23 @@ class AppInstance {
|
||||
* These manifest methods can optionally allocate/free data that is attached here.
|
||||
*/
|
||||
void* _Nullable data = nullptr;
|
||||
|
||||
public:
|
||||
AppInstance(const AppManifest& manifest) :
|
||||
|
||||
AppInstance(const Manifest& manifest) :
|
||||
manifest(manifest) {}
|
||||
|
||||
AppInstance(const AppManifest& manifest, const Bundle& parameters) :
|
||||
AppInstance(const Manifest& manifest, const Bundle& parameters) :
|
||||
manifest(manifest),
|
||||
parameters(parameters) {}
|
||||
|
||||
void setState(AppState state);
|
||||
AppState getState();
|
||||
void setState(State state);
|
||||
State getState();
|
||||
|
||||
const AppManifest& getManifest();
|
||||
const Manifest& getManifest();
|
||||
|
||||
AppFlags getFlags();
|
||||
void setFlags(AppFlags flags);
|
||||
Flags getFlags();
|
||||
void setFlags(Flags flags);
|
||||
|
||||
_Nullable void* getData();
|
||||
void setData(void* data);
|
||||
@@ -66,22 +71,22 @@ public:
|
||||
* @return
|
||||
*/
|
||||
[[deprecated("use class")]]
|
||||
App tt_app_alloc(const AppManifest& manifest, const Bundle& parameters);
|
||||
App tt_app_alloc(const Manifest& manifest, const Bundle& parameters);
|
||||
[[deprecated("use class")]]
|
||||
void tt_app_free(App app);
|
||||
|
||||
[[deprecated("use class")]]
|
||||
void tt_app_set_state(App app, AppState state);
|
||||
void tt_app_set_state(App app, State state);
|
||||
[[deprecated("use class")]]
|
||||
AppState tt_app_get_state(App app);
|
||||
State tt_app_get_state(App app);
|
||||
|
||||
[[deprecated("use class")]]
|
||||
const AppManifest& tt_app_get_manifest(App app);
|
||||
const Manifest& tt_app_get_manifest(App app);
|
||||
|
||||
[[deprecated("use class")]]
|
||||
AppFlags tt_app_get_flags(App app);
|
||||
Flags tt_app_get_flags(App app);
|
||||
[[deprecated("use class")]]
|
||||
void tt_app_set_flags(App app, AppFlags flags);
|
||||
void tt_app_set_flags(App app, Flags flags);
|
||||
|
||||
[[deprecated("use class")]]
|
||||
void* _Nullable tt_app_get_data(App app);
|
||||
+8
-8
@@ -1,21 +1,21 @@
|
||||
#include "AppManifestRegistry.h"
|
||||
#include "app/ManifestRegistry.h"
|
||||
#include "Assets.h"
|
||||
#include "Check.h"
|
||||
#include "lvgl.h"
|
||||
#include <algorithm>
|
||||
#include "Services/Loader/Loader.h"
|
||||
#include "service/loader/Loader.h"
|
||||
|
||||
namespace tt::app::desktop {
|
||||
|
||||
static void on_app_pressed(lv_event_t* e) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
if (code == LV_EVENT_CLICKED) {
|
||||
const auto* manifest = static_cast<const AppManifest*>(lv_event_get_user_data(e));
|
||||
const auto* manifest = static_cast<const Manifest*>(lv_event_get_user_data(e));
|
||||
service::loader::start_app(manifest->id, false, Bundle());
|
||||
}
|
||||
}
|
||||
|
||||
static void create_app_widget(const AppManifest* manifest, void* parent) {
|
||||
static void create_app_widget(const Manifest* manifest, void* parent) {
|
||||
tt_check(parent);
|
||||
auto* list = static_cast<lv_obj_t*>(parent);
|
||||
const void* icon = !manifest->icon.empty() ? manifest->icon.c_str() : TT_ASSETS_APP_ICON_FALLBACK;
|
||||
@@ -33,23 +33,23 @@ static void desktop_show(TT_UNUSED App app, lv_obj_t* parent) {
|
||||
|
||||
lv_list_add_text(list, "User");
|
||||
for (const auto& manifest: manifests) {
|
||||
if (manifest->type == AppTypeUser) {
|
||||
if (manifest->type == TypeUser) {
|
||||
create_app_widget(manifest, list);
|
||||
}
|
||||
}
|
||||
|
||||
lv_list_add_text(list, "System");
|
||||
for (const auto& manifest: manifests) {
|
||||
if (manifest->type == AppTypeSystem) {
|
||||
if (manifest->type == TypeSystem) {
|
||||
create_app_widget(manifest, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "Desktop",
|
||||
.name = "Desktop",
|
||||
.type = AppTypeDesktop,
|
||||
.type = TypeDesktop,
|
||||
.on_show = &desktop_show,
|
||||
};
|
||||
|
||||
+5
-5
@@ -1,9 +1,9 @@
|
||||
#include "App.h"
|
||||
#include "app/App.h"
|
||||
#include "Assets.h"
|
||||
#include "DisplayPreferences.h"
|
||||
#include "Tactility.h"
|
||||
#include "Ui/Style.h"
|
||||
#include "Ui/Toolbar.h"
|
||||
#include "ui/Style.h"
|
||||
#include "ui/Toolbar.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
namespace tt::app::settings::display {
|
||||
@@ -122,11 +122,11 @@ static void app_hide(TT_UNUSED App app) {
|
||||
}
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "Display",
|
||||
.name = "Display",
|
||||
.icon = TT_ASSETS_APP_ICON_DISPLAY_SETTINGS,
|
||||
.type = AppTypeSettings,
|
||||
.type = TypeSettings,
|
||||
.on_start = nullptr,
|
||||
.on_stop = nullptr,
|
||||
.on_show = &app_show,
|
||||
@@ -1,15 +1,15 @@
|
||||
#include "FilesData.h"
|
||||
|
||||
#include "App.h"
|
||||
#include "Tactility.h"
|
||||
#include "app/App.h"
|
||||
#include "Assets.h"
|
||||
#include "Check.h"
|
||||
#include "FileUtils.h"
|
||||
#include "StringUtils.h"
|
||||
#include "Apps/ImageViewer/ImageViewer.h"
|
||||
#include "Apps/TextViewer/TextViewer.h"
|
||||
#include "app/ImageViewer/ImageViewer.h"
|
||||
#include "app/TextViewer/TextViewer.h"
|
||||
#include "lvgl.h"
|
||||
#include "Services/Loader/Loader.h"
|
||||
#include "Ui/Toolbar.h"
|
||||
#include "service/loader/Loader.h"
|
||||
#include "ui/Toolbar.h"
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -221,11 +221,11 @@ static void on_stop(App app) {
|
||||
|
||||
// endregion Lifecycle
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "Files",
|
||||
.name = "Files",
|
||||
.icon = TT_ASSETS_APP_ICON_FILES,
|
||||
.type = AppTypeSystem,
|
||||
.type = TypeSystem,
|
||||
.on_start = &on_start,
|
||||
.on_stop = &on_stop,
|
||||
.on_show = &on_show,
|
||||
@@ -1,10 +1,11 @@
|
||||
#include "Mutex.h"
|
||||
#include "Thread.h"
|
||||
#include "Services/Loader/Loader.h"
|
||||
#include "Ui/Toolbar.h"
|
||||
#include "Tactility.h"
|
||||
#include "service/loader/Loader.h"
|
||||
#include "ui/Toolbar.h"
|
||||
|
||||
#include "GpioHal.h"
|
||||
#include "Ui/LvglSync.h"
|
||||
#include "ui/LvglSync.h"
|
||||
|
||||
namespace tt::app::gpio {
|
||||
|
||||
@@ -200,10 +201,10 @@ static void on_stop(App app) {
|
||||
|
||||
// endregion App lifecycle
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "Gpio",
|
||||
.name = "GPIO",
|
||||
.type = AppTypeSystem,
|
||||
.type = TypeSystem,
|
||||
.on_start = &on_start,
|
||||
.on_stop = &on_stop,
|
||||
.on_show = &app_show,
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
#include "Assets.h"
|
||||
#include "Hal/I2c/I2c.h"
|
||||
#include "hal/i2c/I2c.h"
|
||||
#include "Tactility.h"
|
||||
#include "Ui/Style.h"
|
||||
#include "Ui/Toolbar.h"
|
||||
#include "ui/Style.h"
|
||||
#include "ui/Toolbar.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
namespace tt::app::settings::i2c {
|
||||
@@ -85,11 +85,11 @@ static void on_show(App app, lv_obj_t* parent) {
|
||||
}
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "I2cSettings",
|
||||
.name = "I2C",
|
||||
.icon = TT_ASSETS_APP_ICON_I2C_SETTINGS,
|
||||
.type = AppTypeSettings,
|
||||
.type = TypeSettings,
|
||||
.on_show = &on_show
|
||||
};
|
||||
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
#include "ImageViewer.h"
|
||||
#include "Log.h"
|
||||
#include "lvgl.h"
|
||||
#include "Ui/Style.h"
|
||||
#include "Ui/Toolbar.h"
|
||||
#include "ui/Style.h"
|
||||
#include "ui/Toolbar.h"
|
||||
|
||||
namespace tt::app::image_viewer {
|
||||
|
||||
@@ -31,10 +31,10 @@ static void on_show(App app, lv_obj_t* parent) {
|
||||
}
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "ImageViewer",
|
||||
.name = "Image Viewer",
|
||||
.type = AppTypeHidden,
|
||||
.type = TypeHidden,
|
||||
.on_show = &on_show
|
||||
};
|
||||
|
||||
@@ -6,29 +6,29 @@
|
||||
// Forward declarations
|
||||
typedef struct _lv_obj_t lv_obj_t;
|
||||
|
||||
namespace tt {
|
||||
namespace tt::app {
|
||||
|
||||
typedef void* App;
|
||||
|
||||
typedef enum {
|
||||
/** A desktop app sits at the root of the app stack managed by the Loader service */
|
||||
AppTypeDesktop,
|
||||
TypeDesktop,
|
||||
/** Apps that generally aren't started from the desktop (e.g. image viewer) */
|
||||
AppTypeHidden,
|
||||
TypeHidden,
|
||||
/** Standard apps, provided by the system. */
|
||||
AppTypeSystem,
|
||||
TypeSystem,
|
||||
/** The apps that are launched/shown by the Settings app. The Settings app itself is of type AppTypeSystem. */
|
||||
AppTypeSettings,
|
||||
TypeSettings,
|
||||
/** User-provided apps. */
|
||||
AppTypeUser
|
||||
} AppType;
|
||||
TypeUser
|
||||
} Type;
|
||||
|
||||
typedef void (*AppOnStart)(App app);
|
||||
typedef void (*AppOnStop)(App app);
|
||||
typedef void (*AppOnShow)(App app, lv_obj_t* parent);
|
||||
typedef void (*AppOnHide)(App app);
|
||||
|
||||
typedef struct AppManifest {
|
||||
typedef struct Manifest {
|
||||
/**
|
||||
* The identifier by which the app is launched by the system and other apps.
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ typedef struct AppManifest {
|
||||
/**
|
||||
* App type affects launch behaviour.
|
||||
*/
|
||||
const AppType type = AppTypeUser;
|
||||
const Type type = TypeUser;
|
||||
|
||||
/**
|
||||
* Non-blocking method to call when app is started.
|
||||
@@ -71,7 +71,7 @@ typedef struct AppManifest {
|
||||
} AppManifest;
|
||||
|
||||
struct {
|
||||
bool operator()(const AppManifest* a, const AppManifest* b) const { return a->name < b->name; }
|
||||
bool operator()(const Manifest* a, const Manifest* b) const { return a->name < b->name; }
|
||||
} SortAppManifestByName;
|
||||
|
||||
} // namespace
|
||||
+8
-8
@@ -1,13 +1,13 @@
|
||||
#include "AppManifestRegistry.h"
|
||||
#include "ManifestRegistry.h"
|
||||
#include "Mutex.h"
|
||||
#include "TactilityCore.h"
|
||||
#include <unordered_map>
|
||||
|
||||
#define TAG "app_registry"
|
||||
|
||||
namespace tt {
|
||||
namespace tt::app {
|
||||
|
||||
typedef std::unordered_map<std::string, const AppManifest*> AppManifestMap;
|
||||
typedef std::unordered_map<std::string, const Manifest*> AppManifestMap;
|
||||
|
||||
static AppManifestMap app_manifest_map;
|
||||
static Mutex* hash_mutex = nullptr;
|
||||
@@ -26,7 +26,7 @@ void app_manifest_registry_init() {
|
||||
tt_assert(hash_mutex == nullptr);
|
||||
hash_mutex = tt_mutex_alloc(MutexTypeNormal);
|
||||
}
|
||||
void app_manifest_registry_add(const AppManifest* manifest) {
|
||||
void app_manifest_registry_add(const Manifest* manifest) {
|
||||
TT_LOG_I(TAG, "adding %s", manifest->id.c_str());
|
||||
|
||||
app_registry_lock();
|
||||
@@ -34,16 +34,16 @@ void app_manifest_registry_add(const AppManifest* manifest) {
|
||||
app_registry_unlock();
|
||||
}
|
||||
|
||||
_Nullable const AppManifest * app_manifest_registry_find_by_id(const std::string& id) {
|
||||
_Nullable const Manifest * app_manifest_registry_find_by_id(const std::string& id) {
|
||||
app_registry_lock();
|
||||
auto iterator = app_manifest_map.find(id);
|
||||
_Nullable const AppManifest* result = iterator != app_manifest_map.end() ? iterator->second : nullptr;
|
||||
_Nullable const Manifest* result = iterator != app_manifest_map.end() ? iterator->second : nullptr;
|
||||
app_registry_unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<const AppManifest*> app_manifest_registry_get() {
|
||||
std::vector<const AppManifest*> manifests;
|
||||
std::vector<const Manifest*> app_manifest_registry_get() {
|
||||
std::vector<const Manifest*> manifests;
|
||||
app_registry_lock();
|
||||
for (const auto& item: app_manifest_map) {
|
||||
manifests.push_back(item.second);
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "Manifest.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
void app_manifest_registry_init();
|
||||
void app_manifest_registry_add(const Manifest* manifest);
|
||||
void app_manifest_registry_remove(const Manifest* manifest);
|
||||
const Manifest _Nullable* app_manifest_registry_find_by_id(const std::string& id);
|
||||
std::vector<const Manifest*> app_manifest_registry_get();
|
||||
|
||||
} // namespace
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "App.h"
|
||||
#include "app/App.h"
|
||||
#include "Assets.h"
|
||||
#include "lvgl.h"
|
||||
#include "Tactility.h"
|
||||
#include "Timer.h"
|
||||
#include "Ui/LvglSync.h"
|
||||
#include "Ui/Style.h"
|
||||
#include "Ui/Toolbar.h"
|
||||
#include "ui/LvglSync.h"
|
||||
#include "ui/Style.h"
|
||||
#include "ui/Toolbar.h"
|
||||
|
||||
namespace tt::app::settings::power {
|
||||
|
||||
@@ -22,11 +22,11 @@ typedef struct {
|
||||
|
||||
static void app_update_ui(void* callbackContext) {
|
||||
auto* data = (AppData*)callbackContext;
|
||||
bool charging_enabled = data->power->is_charging_enabled();
|
||||
const char* charge_state = data->power->is_charging() ? "yes" : "no";
|
||||
uint8_t charge_level = data->power->get_charge_level();
|
||||
bool charging_enabled = data->power->isChargingEnabled();
|
||||
const char* charge_state = data->power->isCharging() ? "yes" : "no";
|
||||
uint8_t charge_level = data->power->getChargeLevel();
|
||||
uint16_t charge_level_scaled = (int16_t)charge_level * 100 / 255;
|
||||
int32_t current = data->power->get_current();
|
||||
int32_t current = data->power->getCurrent();
|
||||
|
||||
lvgl::lock(ms_to_ticks(1000));
|
||||
lv_obj_set_state(data->enable_switch, LV_STATE_CHECKED, charging_enabled);
|
||||
@@ -46,8 +46,8 @@ static void on_power_enabled_change(lv_event_t* event) {
|
||||
if (code == LV_EVENT_VALUE_CHANGED) {
|
||||
bool is_on = lv_obj_has_state(enable_switch, LV_STATE_CHECKED);
|
||||
auto* data = static_cast<AppData*>(lv_event_get_user_data(event));
|
||||
if (data->power->is_charging_enabled() != is_on) {
|
||||
data->power->set_charging_enabled(is_on);
|
||||
if (data->power->isChargingEnabled() != is_on) {
|
||||
data->power->setChargingEnabled(is_on);
|
||||
app_update_ui(data);
|
||||
}
|
||||
}
|
||||
@@ -109,11 +109,11 @@ static void app_stop(App app) {
|
||||
delete data;
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "Power",
|
||||
.name = "Power",
|
||||
.icon = TT_ASSETS_APP_ICON_POWER_SETTINGS,
|
||||
.type = AppTypeSettings,
|
||||
.type = TypeSettings,
|
||||
.on_start = &app_start,
|
||||
.on_stop = &app_stop,
|
||||
.on_show = &app_show,
|
||||
+2
-2
@@ -17,11 +17,11 @@ static void on_stop(App app) {
|
||||
free(ui);
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "Screenshot",
|
||||
.name = "_Screenshot", // So it gets put at the bottom of the desktop and becomes less visible on small screen devices
|
||||
.icon = LV_SYMBOL_IMAGE,
|
||||
.type = AppTypeSystem,
|
||||
.type = TypeSystem,
|
||||
.on_start = &on_start,
|
||||
.on_stop = &on_stop,
|
||||
.on_show = &on_show,
|
||||
+5
-5
@@ -1,10 +1,10 @@
|
||||
#include "ScreenshotUi.h"
|
||||
|
||||
#include "TactilityCore.h"
|
||||
#include "Hal/Sdcard.h"
|
||||
#include "Services/Gui/Gui.h"
|
||||
#include "Services/Screenshot/Screenshot.h"
|
||||
#include "Ui/Toolbar.h"
|
||||
#include "hal/sdcard/Sdcard.h"
|
||||
#include "service/gui/Gui.h"
|
||||
#include "service/screenshot/Screenshot.h"
|
||||
#include "ui/Toolbar.h"
|
||||
|
||||
namespace tt::app::screenshot {
|
||||
|
||||
@@ -106,7 +106,7 @@ static void create_path_ui(ScreenshotUi* ui, lv_obj_t* parent) {
|
||||
lv_obj_set_flex_grow(path_textarea, 1);
|
||||
ui->path_textarea = path_textarea;
|
||||
if (get_platform() == PlatformEsp) {
|
||||
if (hal::sdcard::get_state() == hal::sdcard::StateMounted) {
|
||||
if (hal::sdcard::getState() == hal::sdcard::StateMounted) {
|
||||
lv_textarea_set_text(path_textarea, "A:/sdcard");
|
||||
} else {
|
||||
lv_textarea_set_text(path_textarea, "Error: no SD card");
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "App.h"
|
||||
#include "app/App.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
namespace tt::app::screenshot {
|
||||
+8
-8
@@ -1,8 +1,8 @@
|
||||
#include "AppManifestRegistry.h"
|
||||
#include "app/ManifestRegistry.h"
|
||||
#include "Assets.h"
|
||||
#include "Check.h"
|
||||
#include "Services/Loader/Loader.h"
|
||||
#include "Ui/Toolbar.h"
|
||||
#include "service/loader/Loader.h"
|
||||
#include "ui/Toolbar.h"
|
||||
#include "lvgl.h"
|
||||
#include <algorithm>
|
||||
|
||||
@@ -11,12 +11,12 @@ namespace tt::app::settings {
|
||||
static void on_app_pressed(lv_event_t* e) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
if (code == LV_EVENT_CLICKED) {
|
||||
const auto* manifest = static_cast<const AppManifest*>(lv_event_get_user_data(e));
|
||||
const auto* manifest = static_cast<const Manifest*>(lv_event_get_user_data(e));
|
||||
service::loader::start_app(manifest->id, false, Bundle());
|
||||
}
|
||||
}
|
||||
|
||||
static void create_app_widget(const AppManifest* manifest, void* parent) {
|
||||
static void create_app_widget(const Manifest* manifest, void* parent) {
|
||||
tt_check(parent);
|
||||
auto* list = (lv_obj_t*)parent;
|
||||
const void* icon = !manifest->icon.empty() ? manifest->icon.c_str() : TT_ASSETS_APP_ICON_FALLBACK;
|
||||
@@ -36,17 +36,17 @@ static void on_show(App app, lv_obj_t* parent) {
|
||||
auto manifests = app_manifest_registry_get();
|
||||
std::sort(manifests.begin(), manifests.end(), SortAppManifestByName);
|
||||
for (const auto& manifest: manifests) {
|
||||
if (manifest->type == AppTypeSettings) {
|
||||
if (manifest->type == TypeSettings) {
|
||||
create_app_widget(manifest, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "Settings",
|
||||
.name = "Settings",
|
||||
.icon = TT_ASSETS_APP_ICON_SETTINGS,
|
||||
.type = AppTypeSystem,
|
||||
.type = TypeSystem,
|
||||
.on_start = nullptr,
|
||||
.on_stop = nullptr,
|
||||
.on_show = &on_show,
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
#include "Assets.h"
|
||||
#include "lvgl.h"
|
||||
#include "Tactility.h"
|
||||
#include "Ui/Toolbar.h"
|
||||
#include "ui/Toolbar.h"
|
||||
|
||||
namespace tt::app::system_info {
|
||||
|
||||
@@ -101,11 +101,11 @@ static void on_show(App app, lv_obj_t* parent) {
|
||||
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "SystemInfo",
|
||||
.name = "System Info",
|
||||
.icon = TT_ASSETS_APP_ICON_SYSTEM_INFO,
|
||||
.type = AppTypeSystem,
|
||||
.type = TypeSystem,
|
||||
.on_start = nullptr,
|
||||
.on_stop = nullptr,
|
||||
.on_show = &on_show
|
||||
+5
-5
@@ -1,9 +1,9 @@
|
||||
#include "Log.h"
|
||||
#include "TextViewer.h"
|
||||
#include "lvgl.h"
|
||||
#include "Ui/LabelUtils.h"
|
||||
#include "Ui/Style.h"
|
||||
#include "Ui/Toolbar.h"
|
||||
#include "ui/LabelUtils.h"
|
||||
#include "ui/Style.h"
|
||||
#include "ui/Toolbar.h"
|
||||
|
||||
#define TAG "text_viewer"
|
||||
|
||||
@@ -31,10 +31,10 @@ static void on_show(App app, lv_obj_t* parent) {
|
||||
}
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "TextViewer",
|
||||
.name = "Text Viewer",
|
||||
.type = AppTypeHidden,
|
||||
.type = TypeHidden,
|
||||
.on_show = &on_show
|
||||
};
|
||||
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
#include "WifiConnect.h"
|
||||
|
||||
#include "App.h"
|
||||
#include "app/App.h"
|
||||
#include "TactilityCore.h"
|
||||
#include "WifiConnectStateUpdating.h"
|
||||
#include "Services/Loader/Loader.h"
|
||||
#include "Services/Wifi/Wifi.h"
|
||||
#include "Ui/LvglSync.h"
|
||||
#include "service/loader/Loader.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
#include "ui/LvglSync.h"
|
||||
|
||||
namespace tt::app::wifi_connect {
|
||||
|
||||
@@ -132,11 +132,11 @@ static void app_stop(App app) {
|
||||
tt_app_set_data(app, nullptr);
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "WifiConnect",
|
||||
.name = "Wi-Fi Connect",
|
||||
.icon = LV_SYMBOL_WIFI,
|
||||
.type = AppTypeSettings,
|
||||
.type = TypeSettings,
|
||||
.on_start = &app_start,
|
||||
.on_stop = &app_stop,
|
||||
.on_show = &app_show,
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
#include "WifiConnectBindings.h"
|
||||
#include "WifiConnectState.h"
|
||||
#include "WifiConnectView.h"
|
||||
#include "Services/Wifi/Wifi.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
|
||||
namespace tt::app::wifi_connect {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Services/Wifi/WifiSettings.h"
|
||||
#include "service/wifi/WifiSettings.h"
|
||||
|
||||
namespace tt::app::wifi_connect {
|
||||
|
||||
+2
-3
@@ -1,8 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "App.h"
|
||||
#include "Services/Wifi/Wifi.h"
|
||||
#include "Services/Wifi/WifiSettings.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
#include "service/wifi/WifiSettings.h"
|
||||
|
||||
namespace tt::app::wifi_connect {
|
||||
|
||||
+4
-4
@@ -6,10 +6,10 @@
|
||||
#include "WifiConnectState.h"
|
||||
#include "WifiConnectStateUpdating.h"
|
||||
#include "lvgl.h"
|
||||
#include "Services/Gui/Gui.h"
|
||||
#include "Services/Wifi/WifiSettings.h"
|
||||
#include "Ui/Style.h"
|
||||
#include "Ui/Toolbar.h"
|
||||
#include "service/gui/Gui.h"
|
||||
#include "service/wifi/WifiSettings.h"
|
||||
#include "ui/Style.h"
|
||||
#include "ui/Toolbar.h"
|
||||
|
||||
namespace tt::app::wifi_connect {
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/App.h"
|
||||
#include "WifiConnectBindings.h"
|
||||
#include "WifiConnectState.h"
|
||||
#include "lvgl.h"
|
||||
+7
-7
@@ -1,11 +1,11 @@
|
||||
#include "WifiManage.h"
|
||||
|
||||
#include "App.h"
|
||||
#include "Apps/WifiConnect/WifiConnectBundle.h"
|
||||
#include "app/App.h"
|
||||
#include "app/WifiConnect/WifiConnectBundle.h"
|
||||
#include "TactilityCore.h"
|
||||
#include "Services/Loader/Loader.h"
|
||||
#include "Services/Wifi/WifiSettings.h"
|
||||
#include "Ui/LvglSync.h"
|
||||
#include "service/loader/Loader.h"
|
||||
#include "service/wifi/WifiSettings.h"
|
||||
#include "ui/LvglSync.h"
|
||||
#include "WifiManageStateUpdating.h"
|
||||
#include "WifiManageView.h"
|
||||
|
||||
@@ -166,11 +166,11 @@ static void app_stop(App app) {
|
||||
tt_app_set_data(app, nullptr);
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "WifiManage",
|
||||
.name = "Wi-Fi",
|
||||
.icon = LV_SYMBOL_WIFI,
|
||||
.type = AppTypeSettings,
|
||||
.type = TypeSettings,
|
||||
.on_start = &app_start,
|
||||
.on_stop = &app_stop,
|
||||
.on_show = &app_show,
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "Mutex.h"
|
||||
#include "WifiManageView.h"
|
||||
#include "Services/Wifi/Wifi.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
|
||||
namespace tt::app::wifi_manage {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Services/Wifi/Wifi.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
|
||||
namespace tt::app::wifi_manage {
|
||||
|
||||
+4
-4
@@ -2,10 +2,10 @@
|
||||
|
||||
#include "Log.h"
|
||||
#include "WifiManageState.h"
|
||||
#include "Services/Statusbar/Statusbar.h"
|
||||
#include "Services/Wifi/Wifi.h"
|
||||
#include "Ui/Style.h"
|
||||
#include "Ui/Toolbar.h"
|
||||
#include "service/statusbar/Statusbar.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
#include "ui/Style.h"
|
||||
#include "ui/Toolbar.h"
|
||||
|
||||
namespace tt::app::wifi_manage {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "App.h"
|
||||
#include "app/App.h"
|
||||
#include "WifiManageBindings.h"
|
||||
#include "WifiManageState.h"
|
||||
#include "lvgl.h"
|
||||
@@ -1,9 +1,8 @@
|
||||
#include "Services/Gui/Gui_i.h"
|
||||
|
||||
#include "Tactility.h"
|
||||
#include "Services/Loader/Loader.h"
|
||||
#include "Ui/LvglKeypad.h"
|
||||
#include "Ui/LvglSync.h"
|
||||
#include "service/gui/Gui_i.h"
|
||||
#include "service/loader/Loader.h"
|
||||
#include "ui/LvglKeypad.h"
|
||||
#include "ui/LvglSync.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "freertos/FreeRTOS.h"
|
||||
@@ -25,8 +24,8 @@ typedef void (*PubSubCallback)(const void* message, void* context);
|
||||
void loader_callback(const void* message, TT_UNUSED void* context) {
|
||||
auto* event = static_cast<const loader::LoaderEvent*>(message);
|
||||
if (event->type == loader::LoaderEventTypeApplicationShowing) {
|
||||
App* app = event->app_showing.app;
|
||||
const AppManifest& app_manifest = tt_app_get_manifest(app);
|
||||
app::App* app = event->app_showing.app;
|
||||
const app::Manifest& app_manifest = app::tt_app_get_manifest(app);
|
||||
show_app(app, app_manifest.on_show, app_manifest.on_hide);
|
||||
} else if (event->type == loader::LoaderEventTypeApplicationHiding) {
|
||||
hide_app();
|
||||
@@ -36,7 +35,7 @@ void loader_callback(const void* message, TT_UNUSED void* context) {
|
||||
Gui* gui_alloc() {
|
||||
auto* instance = static_cast<Gui*>(malloc(sizeof(Gui)));
|
||||
memset(instance, 0, sizeof(Gui));
|
||||
tt_check(instance != NULL);
|
||||
tt_check(instance != nullptr);
|
||||
instance->thread = new Thread(
|
||||
"gui",
|
||||
4096, // Last known minimum was 2800 for launching desktop
|
||||
@@ -84,9 +83,9 @@ void request_draw() {
|
||||
thread_flags_set(thread_id, GUI_THREAD_FLAG_DRAW);
|
||||
}
|
||||
|
||||
void show_app(App app, ViewPortShowCallback on_show, ViewPortHideCallback on_hide) {
|
||||
void show_app(app::App app, ViewPortShowCallback on_show, ViewPortHideCallback on_hide) {
|
||||
lock();
|
||||
tt_check(gui->app_view_port == NULL);
|
||||
tt_check(gui->app_view_port == nullptr);
|
||||
gui->app_view_port = view_port_alloc(app, on_show, on_hide);
|
||||
unlock();
|
||||
request_draw();
|
||||
@@ -95,7 +94,7 @@ void show_app(App app, ViewPortShowCallback on_show, ViewPortHideCallback on_hid
|
||||
void hide_app() {
|
||||
lock();
|
||||
ViewPort* view_port = gui->app_view_port;
|
||||
tt_check(view_port != NULL);
|
||||
tt_check(view_port != nullptr);
|
||||
|
||||
// We must lock the LVGL port, because the viewport hide callbacks
|
||||
// might call LVGL APIs (e.g. to remove the keyboard from the screen root)
|
||||
@@ -155,10 +154,10 @@ static void stop(TT_UNUSED Service& service) {
|
||||
gui_free(gui);
|
||||
}
|
||||
|
||||
extern const ServiceManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "Gui",
|
||||
.on_start = &start,
|
||||
.on_stop = &stop
|
||||
.onStart = &start,
|
||||
.onStop = &stop
|
||||
};
|
||||
|
||||
// endregion
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "App.h"
|
||||
#include "ServiceManifest.h"
|
||||
#include "app/App.h"
|
||||
#include "ViewPort.h"
|
||||
|
||||
namespace tt::service::gui {
|
||||
@@ -15,7 +14,7 @@ typedef struct Gui Gui;
|
||||
* @param on_show
|
||||
* @param on_hide
|
||||
*/
|
||||
void show_app(App app, ViewPortShowCallback on_show, ViewPortHideCallback on_hide);
|
||||
void show_app(app::App app, ViewPortShowCallback on_show, ViewPortHideCallback on_hide);
|
||||
|
||||
/**
|
||||
* Hide the current app's viewport.
|
||||
+7
-7
@@ -1,15 +1,15 @@
|
||||
#include "Check.h"
|
||||
#include "Log.h"
|
||||
#include "Services/Gui/Gui_i.h"
|
||||
#include "Ui/LvglSync.h"
|
||||
#include "Ui/Statusbar.h"
|
||||
#include "Ui/Style.h"
|
||||
#include "service/gui/Gui_i.h"
|
||||
#include "ui/LvglSync.h"
|
||||
#include "ui/Statusbar.h"
|
||||
#include "ui/Style.h"
|
||||
|
||||
namespace tt::service::gui {
|
||||
|
||||
#define TAG "gui"
|
||||
|
||||
static lv_obj_t* create_app_views(Gui* gui, lv_obj_t* parent, App app) {
|
||||
static lv_obj_t* create_app_views(Gui* gui, lv_obj_t* parent, app::App app) {
|
||||
lvgl::obj_set_style_bg_blacken(parent);
|
||||
|
||||
lv_obj_t* vertical_container = lv_obj_create(parent);
|
||||
@@ -19,7 +19,7 @@ static lv_obj_t* create_app_views(Gui* gui, lv_obj_t* parent, App app) {
|
||||
lvgl::obj_set_style_bg_blacken(vertical_container);
|
||||
|
||||
// TODO: Move statusbar into separate ViewPort
|
||||
AppFlags flags = tt_app_get_flags(app);
|
||||
app::Flags flags = app::tt_app_get_flags(app);
|
||||
if (flags.show_statusbar) {
|
||||
lvgl::statusbar_create(vertical_container);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ void redraw(Gui* gui) {
|
||||
|
||||
ViewPort* view_port = gui->app_view_port;
|
||||
if (view_port != nullptr) {
|
||||
App app = view_port->app;
|
||||
app::App app = view_port->app;
|
||||
lv_obj_t* container = create_app_views(gui, gui->lvgl_parent, app);
|
||||
view_port_show(view_port, container);
|
||||
} else {
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
#include "Services/Gui/Gui_i.h"
|
||||
|
||||
#include "Check.h"
|
||||
#include "TactilityConfig.h"
|
||||
#include "Ui/LvglKeypad.h"
|
||||
#include "Ui/LvglSync.h"
|
||||
#include "service/gui/Gui_i.h"
|
||||
#include "ui/LvglKeypad.h"
|
||||
#include "ui/LvglSync.h"
|
||||
|
||||
namespace tt::service::gui {
|
||||
|
||||
+3
-3
@@ -1,15 +1,15 @@
|
||||
#include "ViewPort.h"
|
||||
|
||||
#include "Check.h"
|
||||
#include "Services/Gui/ViewPort_i.h"
|
||||
#include "Ui/Style.h"
|
||||
#include "service/gui/ViewPort_i.h"
|
||||
#include "ui/Style.h"
|
||||
|
||||
namespace tt::service::gui {
|
||||
|
||||
#define TAG "viewport"
|
||||
|
||||
ViewPort* view_port_alloc(
|
||||
App app,
|
||||
app::App app,
|
||||
ViewPortShowCallback on_show,
|
||||
ViewPortHideCallback on_hide
|
||||
) {
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "App.h"
|
||||
#include "app/App.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
namespace tt::service::gui {
|
||||
@@ -8,13 +8,13 @@ namespace tt::service::gui {
|
||||
/** ViewPort Draw callback
|
||||
* @warning called from GUI thread
|
||||
*/
|
||||
typedef void (*ViewPortShowCallback)(App app, lv_obj_t* parent);
|
||||
typedef void (*ViewPortHideCallback)(App app);
|
||||
typedef void (*ViewPortShowCallback)(app::App app, lv_obj_t* parent);
|
||||
typedef void (*ViewPortHideCallback)(app::App app);
|
||||
|
||||
// TODO: Move internally, use handle publicly
|
||||
|
||||
typedef struct {
|
||||
App app;
|
||||
app::App app;
|
||||
ViewPortShowCallback on_show;
|
||||
ViewPortHideCallback _Nullable on_hide;
|
||||
bool app_toolbar;
|
||||
@@ -30,7 +30,7 @@ typedef struct {
|
||||
* @return ViewPort instance
|
||||
*/
|
||||
ViewPort* view_port_alloc(
|
||||
App app,
|
||||
app::App app,
|
||||
ViewPortShowCallback on_show,
|
||||
ViewPortHideCallback on_hide
|
||||
);
|
||||
+63
-57
@@ -1,16 +1,17 @@
|
||||
#include "ApiLock.h"
|
||||
#include "AppManifest.h"
|
||||
#include "AppManifestRegistry.h"
|
||||
#include "App_i.h"
|
||||
#include "ServiceManifest.h"
|
||||
#include "Services/Gui/Gui.h"
|
||||
#include "Services/Loader/Loader_i.h"
|
||||
#include "Tactility.h"
|
||||
#include "app/Manifest.h"
|
||||
#include "app/ManifestRegistry.h"
|
||||
#include "service/Manifest.h"
|
||||
#include "service/gui/Gui.h"
|
||||
#include "service/loader/Loader_i.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "esp_heap_caps.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#else
|
||||
#include "FreeRTOS.h"
|
||||
#include "ui/LvglSync.h"
|
||||
|
||||
#endif
|
||||
|
||||
namespace tt::service::loader {
|
||||
@@ -39,7 +40,7 @@ static Loader* loader_alloc() {
|
||||
);
|
||||
loader_singleton->mutex = tt_mutex_alloc(MutexTypeRecursive);
|
||||
loader_singleton->app_stack_index = -1;
|
||||
memset(loader_singleton->app_stack, 0, sizeof(App) * APP_STACK_SIZE);
|
||||
memset(loader_singleton->app_stack, 0, sizeof(app::App) * APP_STACK_SIZE);
|
||||
return loader_singleton;
|
||||
}
|
||||
|
||||
@@ -67,6 +68,7 @@ static void loader_unlock() {
|
||||
|
||||
LoaderStatus start_app(const std::string& id, bool blocking, const Bundle& bundle) {
|
||||
tt_assert(loader_singleton);
|
||||
|
||||
LoaderMessageLoaderStatusResult result = {
|
||||
.value = LoaderStatusOk
|
||||
};
|
||||
@@ -74,15 +76,19 @@ LoaderStatus start_app(const std::string& id, bool blocking, const Bundle& bundl
|
||||
auto* start_message = new LoaderMessageAppStart(id, bundle);
|
||||
LoaderMessage message(start_message, result);
|
||||
|
||||
ApiLock lock = blocking ? tt_api_lock_alloc_locked() : nullptr;
|
||||
if (lock != nullptr) {
|
||||
message.setLock(lock);
|
||||
EventFlag* event_flag = blocking ? new EventFlag() : nullptr;
|
||||
if (event_flag != nullptr) {
|
||||
message.setApiLock(event_flag);
|
||||
}
|
||||
|
||||
loader_singleton->queue.put(&message, TtWaitForever);
|
||||
|
||||
if (lock != nullptr) {
|
||||
tt_api_lock_wait_unlock_and_free(message.api_lock);
|
||||
if (event_flag != nullptr) {
|
||||
/* TODO: Check if task id is not the LVGL one,
|
||||
because otherwise this fails as the apps starting logic will try to lock lvgl
|
||||
to update the UI and fail. */
|
||||
event_flag->wait(TT_API_LOCK_EVENT);
|
||||
delete event_flag;
|
||||
}
|
||||
|
||||
return result.value;
|
||||
@@ -94,10 +100,10 @@ void stop_app() {
|
||||
loader_singleton->queue.put(&message, TtWaitForever);
|
||||
}
|
||||
|
||||
App _Nullable get_current_app() {
|
||||
app::App _Nullable get_current_app() {
|
||||
tt_assert(loader_singleton);
|
||||
loader_lock();
|
||||
App app = (loader_singleton->app_stack_index >= 0)
|
||||
app::App app = (loader_singleton->app_stack_index >= 0)
|
||||
? loader_singleton->app_stack[loader_singleton->app_stack_index]
|
||||
: nullptr;
|
||||
loader_unlock();
|
||||
@@ -112,26 +118,26 @@ PubSub* get_pubsub() {
|
||||
return loader_singleton->pubsub_external;
|
||||
}
|
||||
|
||||
static const char* app_state_to_string(AppState state) {
|
||||
static const char* app_state_to_string(app::State state) {
|
||||
switch (state) {
|
||||
case AppStateInitial:
|
||||
case app::StateInitial:
|
||||
return "initial";
|
||||
case AppStateStarted:
|
||||
case app::StateStarted:
|
||||
return "started";
|
||||
case AppStateShowing:
|
||||
case app::StateShowing:
|
||||
return "showing";
|
||||
case AppStateHiding:
|
||||
case app::StateHiding:
|
||||
return "hiding";
|
||||
case AppStateStopped:
|
||||
case app::StateStopped:
|
||||
return "stopped";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
static void app_transition_to_state(App app, AppState state) {
|
||||
const AppManifest& manifest = tt_app_get_manifest(app);
|
||||
const AppState old_state = tt_app_get_state(app);
|
||||
static void app_transition_to_state(app::App app, app::State state) {
|
||||
const app::Manifest& manifest = app::tt_app_get_manifest(app);
|
||||
const app::State old_state = app::tt_app_get_state(app);
|
||||
|
||||
TT_LOG_I(
|
||||
TAG,
|
||||
@@ -142,49 +148,49 @@ static void app_transition_to_state(App app, AppState state) {
|
||||
);
|
||||
|
||||
switch (state) {
|
||||
case AppStateInitial:
|
||||
tt_app_set_state(app, AppStateInitial);
|
||||
case app::StateInitial:
|
||||
tt_app_set_state(app, app::StateInitial);
|
||||
break;
|
||||
case AppStateStarted:
|
||||
case app::StateStarted:
|
||||
if (manifest.on_start != nullptr) {
|
||||
manifest.on_start(app);
|
||||
}
|
||||
tt_app_set_state(app, AppStateStarted);
|
||||
tt_app_set_state(app, app::StateStarted);
|
||||
break;
|
||||
case AppStateShowing: {
|
||||
case app::StateShowing: {
|
||||
LoaderEvent event_showing = {
|
||||
.type = LoaderEventTypeApplicationShowing,
|
||||
.app_showing = {
|
||||
.app = static_cast<App*>(app)
|
||||
.app = static_cast<app::App*>(app)
|
||||
}
|
||||
};
|
||||
tt_pubsub_publish(loader_singleton->pubsub_external, &event_showing);
|
||||
tt_app_set_state(app, AppStateShowing);
|
||||
tt_app_set_state(app, app::StateShowing);
|
||||
break;
|
||||
}
|
||||
case AppStateHiding: {
|
||||
case app::StateHiding: {
|
||||
LoaderEvent event_hiding = {
|
||||
.type = LoaderEventTypeApplicationHiding,
|
||||
.app_hiding = {
|
||||
.app = static_cast<App*>(app)
|
||||
.app = static_cast<app::App*>(app)
|
||||
}
|
||||
};
|
||||
tt_pubsub_publish(loader_singleton->pubsub_external, &event_hiding);
|
||||
tt_app_set_state(app, AppStateHiding);
|
||||
tt_app_set_state(app, app::StateHiding);
|
||||
break;
|
||||
}
|
||||
case AppStateStopped:
|
||||
case app::StateStopped:
|
||||
if (manifest.on_stop) {
|
||||
manifest.on_stop(app);
|
||||
}
|
||||
tt_app_set_data(app, nullptr);
|
||||
tt_app_set_state(app, AppStateStopped);
|
||||
app::tt_app_set_data(app, nullptr);
|
||||
tt_app_set_state(app, app::StateStopped);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static LoaderStatus loader_do_start_app_with_manifest(
|
||||
const AppManifest* manifest,
|
||||
const app::Manifest* manifest,
|
||||
const Bundle& bundle
|
||||
) {
|
||||
TT_LOG_I(TAG, "start with manifest %s", manifest->id.c_str());
|
||||
@@ -199,19 +205,19 @@ static LoaderStatus loader_do_start_app_with_manifest(
|
||||
int8_t previous_index = loader_singleton->app_stack_index;
|
||||
loader_singleton->app_stack_index++;
|
||||
|
||||
App app = tt_app_alloc(*manifest, bundle);
|
||||
app::App app = tt_app_alloc(*manifest, bundle);
|
||||
tt_check(loader_singleton->app_stack[loader_singleton->app_stack_index] == nullptr);
|
||||
loader_singleton->app_stack[loader_singleton->app_stack_index] = app;
|
||||
app_transition_to_state(app, AppStateInitial);
|
||||
app_transition_to_state(app, AppStateStarted);
|
||||
app_transition_to_state(app, app::StateInitial);
|
||||
app_transition_to_state(app, app::StateStarted);
|
||||
|
||||
// We might have to hide the previous app first
|
||||
if (previous_index != -1) {
|
||||
App previous_app = loader_singleton->app_stack[previous_index];
|
||||
app_transition_to_state(previous_app, AppStateHiding);
|
||||
app::App previous_app = loader_singleton->app_stack[previous_index];
|
||||
app_transition_to_state(previous_app, app::StateHiding);
|
||||
}
|
||||
|
||||
app_transition_to_state(app, AppStateShowing);
|
||||
app_transition_to_state(app, app::StateShowing);
|
||||
|
||||
loader_unlock();
|
||||
|
||||
@@ -221,7 +227,7 @@ static LoaderStatus loader_do_start_app_with_manifest(
|
||||
LoaderEvent event_external = {
|
||||
.type = LoaderEventTypeApplicationStarted,
|
||||
.app_started = {
|
||||
.app = static_cast<App*>(app)
|
||||
.app = static_cast<app::App*>(app)
|
||||
}
|
||||
};
|
||||
tt_pubsub_publish(loader_singleton->pubsub_external, &event_external);
|
||||
@@ -235,7 +241,7 @@ static LoaderStatus do_start_by_id(
|
||||
) {
|
||||
TT_LOG_I(TAG, "Start by id %s", id.c_str());
|
||||
|
||||
const AppManifest* manifest = app_manifest_registry_find_by_id(id);
|
||||
const app::Manifest* manifest = app::app_manifest_registry_find_by_id(id);
|
||||
if (manifest == nullptr) {
|
||||
return LoaderStatusErrorUnknownApp;
|
||||
} else {
|
||||
@@ -262,12 +268,12 @@ static void do_stop_app() {
|
||||
}
|
||||
|
||||
// Stop current app
|
||||
App app_to_stop = loader_singleton->app_stack[current_app_index];
|
||||
const AppManifest& manifest = tt_app_get_manifest(app_to_stop);
|
||||
app_transition_to_state(app_to_stop, AppStateHiding);
|
||||
app_transition_to_state(app_to_stop, AppStateStopped);
|
||||
app::App app_to_stop = loader_singleton->app_stack[current_app_index];
|
||||
const app::Manifest& manifest = app::tt_app_get_manifest(app_to_stop);
|
||||
app_transition_to_state(app_to_stop, app::StateHiding);
|
||||
app_transition_to_state(app_to_stop, app::StateStopped);
|
||||
|
||||
tt_app_free(app_to_stop);
|
||||
app::tt_app_free(app_to_stop);
|
||||
loader_singleton->app_stack[current_app_index] = nullptr;
|
||||
loader_singleton->app_stack_index--;
|
||||
|
||||
@@ -277,8 +283,8 @@ static void do_stop_app() {
|
||||
|
||||
// Resume previous app
|
||||
tt_assert(loader_singleton->app_stack[loader_singleton->app_stack_index] != nullptr);
|
||||
App app_to_resume = loader_singleton->app_stack[loader_singleton->app_stack_index];
|
||||
app_transition_to_state(app_to_resume, AppStateShowing);
|
||||
app::App app_to_resume = loader_singleton->app_stack[loader_singleton->app_stack_index];
|
||||
app_transition_to_state(app_to_resume, app::StateShowing);
|
||||
|
||||
loader_unlock();
|
||||
|
||||
@@ -309,7 +315,7 @@ static int32_t loader_main(TT_UNUSED void* parameter) {
|
||||
message.payload.start->bundle
|
||||
);
|
||||
if (message.api_lock != nullptr) {
|
||||
tt_api_lock_unlock(message.api_lock);
|
||||
message.api_lock->set(TT_API_LOCK_EVENT);
|
||||
}
|
||||
message.cleanup();
|
||||
break;
|
||||
@@ -354,10 +360,10 @@ static void loader_stop(TT_UNUSED Service& service) {
|
||||
loader_singleton = nullptr;
|
||||
}
|
||||
|
||||
extern const ServiceManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "Loader",
|
||||
.on_start = &loader_start,
|
||||
.on_stop = &loader_stop
|
||||
.onStart = &loader_start,
|
||||
.onStop = &loader_stop
|
||||
};
|
||||
|
||||
// endregion
|
||||
+7
-8
@@ -1,10 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "AppManifest.h"
|
||||
#include "app/Manifest.h"
|
||||
#include "Bundle.h"
|
||||
#include "Pubsub.h"
|
||||
#include "ServiceManifest.h"
|
||||
#include "TactilityCore.h"
|
||||
#include "service/Manifest.h"
|
||||
|
||||
namespace tt::service::loader {
|
||||
|
||||
@@ -25,19 +24,19 @@ typedef enum {
|
||||
} LoaderEventType;
|
||||
|
||||
typedef struct {
|
||||
App* app;
|
||||
app::App* app;
|
||||
} LoaderEventAppStarted;
|
||||
|
||||
typedef struct {
|
||||
App* app;
|
||||
app::App* app;
|
||||
} LoaderEventAppShowing;
|
||||
|
||||
typedef struct {
|
||||
App* app;
|
||||
app::App* app;
|
||||
} LoaderEventAppHiding;
|
||||
|
||||
typedef struct {
|
||||
const AppManifest* manifest;
|
||||
const app::Manifest* manifest;
|
||||
} LoaderEventAppStopped;
|
||||
|
||||
typedef struct {
|
||||
@@ -64,7 +63,7 @@ LoaderStatus start_app(const std::string& id, bool blocking, const Bundle& bundl
|
||||
*/
|
||||
void stop_app();
|
||||
|
||||
App _Nullable get_current_app();
|
||||
app::App _Nullable get_current_app();
|
||||
|
||||
/**
|
||||
* @brief PubSub for LoaderEvent
|
||||
+10
-10
@@ -3,15 +3,15 @@
|
||||
|
||||
#include "Mutex.h"
|
||||
#include "ScreenshotTask.h"
|
||||
#include "Service.h"
|
||||
#include "ServiceRegistry.h"
|
||||
#include "service/Service.h"
|
||||
#include "service/ServiceRegistry.h"
|
||||
#include "TactilityCore.h"
|
||||
|
||||
namespace tt::service::screenshot {
|
||||
|
||||
#define TAG "sdcard_service"
|
||||
|
||||
extern const ServiceManifest manifest;
|
||||
extern const Manifest manifest;
|
||||
|
||||
typedef struct {
|
||||
Mutex* mutex;
|
||||
@@ -57,7 +57,7 @@ static void on_stop(Service& service) {
|
||||
}
|
||||
|
||||
void start_apps(const char* path) {
|
||||
_Nullable auto* service = service_find(manifest.id);
|
||||
_Nullable auto* service = findServiceById(manifest.id);
|
||||
if (service == nullptr) {
|
||||
TT_LOG_E(TAG, "Service not found");
|
||||
return;
|
||||
@@ -76,7 +76,7 @@ void start_apps(const char* path) {
|
||||
}
|
||||
|
||||
void start_timed(const char* path, uint8_t delay_in_seconds, uint8_t amount) {
|
||||
_Nullable auto* service = service_find(manifest.id);
|
||||
_Nullable auto* service = findServiceById(manifest.id);
|
||||
if (service == nullptr) {
|
||||
TT_LOG_E(TAG, "Service not found");
|
||||
return;
|
||||
@@ -95,7 +95,7 @@ void start_timed(const char* path, uint8_t delay_in_seconds, uint8_t amount) {
|
||||
}
|
||||
|
||||
void stop() {
|
||||
_Nullable Service* service = service_find(manifest.id);
|
||||
_Nullable Service* service = findServiceById(manifest.id);
|
||||
if (service == nullptr) {
|
||||
TT_LOG_E(TAG, "Service not found");
|
||||
return;
|
||||
@@ -115,7 +115,7 @@ void stop() {
|
||||
}
|
||||
|
||||
ScreenshotMode get_mode() {
|
||||
_Nullable auto* service = service_find(manifest.id);
|
||||
_Nullable auto* service = findServiceById(manifest.id);
|
||||
if (service == nullptr) {
|
||||
TT_LOG_E(TAG, "Service not found");
|
||||
return ScreenshotModeNone;
|
||||
@@ -132,10 +132,10 @@ bool is_started() {
|
||||
return get_mode() != ScreenshotModeNone;
|
||||
}
|
||||
|
||||
extern const ServiceManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "Screenshot",
|
||||
.on_start = &on_start,
|
||||
.on_stop = &on_stop
|
||||
.onStart = &on_start,
|
||||
.onStop = &on_stop
|
||||
};
|
||||
|
||||
} // namespace
|
||||
+5
-5
@@ -1,12 +1,12 @@
|
||||
#include "ScreenshotTask.h"
|
||||
#include "lv_screenshot.h"
|
||||
|
||||
#include "App.h"
|
||||
#include "app/App.h"
|
||||
#include "Mutex.h"
|
||||
#include "TactilityCore.h"
|
||||
#include "Thread.h"
|
||||
#include "Services/Loader/Loader.h"
|
||||
#include "Ui/LvglSync.h"
|
||||
#include "service/loader/Loader.h"
|
||||
#include "ui/LvglSync.h"
|
||||
|
||||
namespace tt::service::screenshot {
|
||||
|
||||
@@ -98,9 +98,9 @@ static int32_t screenshot_task(void* context) {
|
||||
break; // Interrupted loop
|
||||
}
|
||||
} else if (data->work.type == TASK_WORK_TYPE_APPS) {
|
||||
App _Nullable app = loader::get_current_app();
|
||||
app::App _Nullable app = loader::get_current_app();
|
||||
if (app) {
|
||||
const AppManifest& manifest = tt_app_get_manifest(app);
|
||||
const app::Manifest& manifest = app::tt_app_get_manifest(app);
|
||||
if (manifest.id != last_app_id) {
|
||||
delay_ms(100);
|
||||
last_app_id = manifest.id;
|
||||
+10
-10
@@ -1,11 +1,11 @@
|
||||
#include "Assets.h"
|
||||
#include "Hal/Power.h"
|
||||
#include "Hal/Sdcard.h"
|
||||
#include "hal/Power.h"
|
||||
#include "hal/sdcard/Sdcard.h"
|
||||
#include "Mutex.h"
|
||||
#include "Service.h"
|
||||
#include "Services/Wifi/Wifi.h"
|
||||
#include "service/Service.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
#include "Tactility.h"
|
||||
#include "Ui/Statusbar.h"
|
||||
#include "ui/Statusbar.h"
|
||||
|
||||
namespace tt::service::statusbar {
|
||||
|
||||
@@ -86,7 +86,7 @@ static _Nullable const char* sdcard_get_status_icon(hal::sdcard::State state) {
|
||||
}
|
||||
|
||||
static void update_sdcard_icon(ServiceData* data) {
|
||||
hal::sdcard::State state = hal::sdcard::get_state();
|
||||
hal::sdcard::State state = hal::sdcard::getState();
|
||||
const char* desired_icon = sdcard_get_status_icon(state);
|
||||
if (data->sdcard_last_icon != desired_icon) {
|
||||
lvgl::statusbar_icon_set_image(data->sdcard_icon_id, desired_icon);
|
||||
@@ -102,7 +102,7 @@ static void update_sdcard_icon(ServiceData* data) {
|
||||
static _Nullable const char* power_get_status_icon() {
|
||||
_Nullable const hal::Power* power = getConfiguration()->hardware->power;
|
||||
if (power != nullptr) {
|
||||
uint8_t charge = power->get_charge_level();
|
||||
uint8_t charge = power->getChargeLevel();
|
||||
if (charge >= 230) {
|
||||
return TT_ASSETS_ICON_POWER_100;
|
||||
} else if (charge >= 161) {
|
||||
@@ -207,10 +207,10 @@ static void on_stop(Service& service) {
|
||||
service_data_free(data);
|
||||
}
|
||||
|
||||
extern const ServiceManifest manifest = {
|
||||
extern const Manifest manifest = {
|
||||
.id = "Statusbar",
|
||||
.on_start = &on_start,
|
||||
.on_stop = &on_stop
|
||||
.onStart = &on_start,
|
||||
.onStop = &on_stop
|
||||
};
|
||||
|
||||
// endregion service
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "Apps/Display/DisplayPreferences.h"
|
||||
#include "app/Display/DisplayPreferences.h"
|
||||
#include "lvgl.h"
|
||||
#include "LvglInit_i.h"
|
||||
#include "hal/Configuration.h"
|
||||
|
||||
namespace tt {
|
||||
namespace tt::ui {
|
||||
|
||||
void lvgl_init(const hal::Configuration* config) {
|
||||
void initLvgl(const hal::Configuration* config) {
|
||||
hal::SetBacklightDuty set_backlight_duty = config->display.setBacklightDuty;
|
||||
if (set_backlight_duty != nullptr) {
|
||||
int32_t backlight_duty = app::settings::display::preferences_get_backlight_duty();
|
||||
@@ -1,27 +1,25 @@
|
||||
#include "LvglSync.h"
|
||||
|
||||
#include "Check.h"
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
static LvglLock lock_singleton = nullptr;
|
||||
static LvglUnlock unlock_singleton = nullptr;
|
||||
|
||||
void sync_set(LvglLock lock, LvglUnlock unlock) {
|
||||
void syncSet(LvglLock lock, LvglUnlock unlock) {
|
||||
lock_singleton = lock;
|
||||
unlock_singleton = unlock;
|
||||
}
|
||||
|
||||
bool lock(uint32_t timeout_ticks) {
|
||||
if (lock_singleton) {
|
||||
return lock_singleton(timeout_ticks);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
tt_check(lock_singleton);
|
||||
return lock_singleton(timeout_ticks);
|
||||
}
|
||||
|
||||
void unlock() {
|
||||
if (unlock_singleton) {
|
||||
unlock_singleton();
|
||||
}
|
||||
tt_check(unlock_singleton);
|
||||
unlock_singleton();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdint>
|
||||
|
||||
namespace tt::lvgl {
|
||||
@@ -8,7 +7,7 @@ namespace tt::lvgl {
|
||||
typedef bool (*LvglLock)(uint32_t timeout_ticks);
|
||||
typedef void (*LvglUnlock)();
|
||||
|
||||
void sync_set(LvglLock lock, LvglUnlock unlock);
|
||||
void syncSet(LvglLock lock, LvglUnlock unlock);
|
||||
bool lock(uint32_t timeout_ticks);
|
||||
void unlock();
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "Mutex.h"
|
||||
#include "Pubsub.h"
|
||||
#include "TactilityCore.h"
|
||||
#include "Ui/Spacer.h"
|
||||
#include "Ui/Style.h"
|
||||
#include "ui/Spacer.h"
|
||||
#include "ui/Style.h"
|
||||
|
||||
#include "LvglSync.h"
|
||||
#include "lvgl.h"
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "lvgl.h"
|
||||
#include "App.h"
|
||||
#include "app/App.h"
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration
|
||||
#include "Toolbar.h"
|
||||
#include "Tactility.h"
|
||||
|
||||
#include "Services/Loader/Loader.h"
|
||||
#include "Ui/Spacer.h"
|
||||
#include "Ui/Style.h"
|
||||
#include "service/loader/Loader.h"
|
||||
#include "ui/Spacer.h"
|
||||
#include "ui/Style.h"
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
@@ -85,8 +86,8 @@ lv_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
lv_obj_t* toolbar_create(lv_obj_t* parent, App app) {
|
||||
const AppManifest& manifest = tt_app_get_manifest(app);
|
||||
lv_obj_t* toolbar_create(lv_obj_t* parent, app::App app) {
|
||||
const app::Manifest& manifest = app::tt_app_get_manifest(app);
|
||||
lv_obj_t* toolbar = toolbar_create(parent, manifest.name);
|
||||
toolbar_set_nav_action(toolbar, LV_SYMBOL_CLOSE, &stop_app, nullptr);
|
||||
return toolbar;
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "lvgl.h"
|
||||
#include "App.h"
|
||||
#include "app/App.h"
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
@@ -19,7 +19,7 @@ typedef struct {
|
||||
} ToolbarAction;
|
||||
|
||||
lv_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title);
|
||||
lv_obj_t* toolbar_create(lv_obj_t* parent, tt::App app);
|
||||
lv_obj_t* toolbar_create(lv_obj_t* parent, app::App app);
|
||||
void toolbar_set_title(lv_obj_t* obj, const std::string& title);
|
||||
void toolbar_set_nav_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* user_data);
|
||||
uint8_t toolbar_add_action(lv_obj_t* obj, const char* icon, const char* text, lv_event_cb_t callback, void* user_data);
|
||||
Reference in New Issue
Block a user