Boot splash and more (#98)

* Boot splash and more

- Added developer sdkconfig
- Refactored the way FreeRTOS includes are included
- Improved Gui/Loader logic
- Implemented boot app with splash screen

* Updated naming for Gui and Loader services

* Renamed Screenshot service methods

* Renames

* Service renames
This commit is contained in:
Ken Van Hoeylandt
2024-11-30 15:37:16 +01:00
committed by GitHub
parent 3f62ec2efa
commit 0188ce721c
60 changed files with 726 additions and 307 deletions
+9 -14
View File
@@ -1,14 +1,9 @@
#include "Tactility.h"
#include "service/gui/Gui_i.h"
#include "service/loader/Loader.h"
#include "service/loader/Loader_i.h"
#include "lvgl/LvglKeypad.h"
#include "lvgl/LvglSync.h"
#ifdef ESP_PLATFORM
#include "freertos/FreeRTOS.h"
#else
#include "FreeRTOS.h"
#endif
#include "RtosCompat.h"
namespace tt::service::gui {
@@ -25,9 +20,9 @@ void loader_callback(const void* message, TT_UNUSED void* context) {
if (event->type == loader::LoaderEventTypeApplicationShowing) {
app::App& app = event->app_showing.app;
const app::Manifest& app_manifest = app.getManifest();
show_app(app, app_manifest.onShow, app_manifest.onHide);
showApp(app, app_manifest.onShow, app_manifest.onHide);
} else if (event->type == loader::LoaderEventTypeApplicationHiding) {
hide_app();
hideApp();
}
}
@@ -43,7 +38,7 @@ Gui* gui_alloc() {
);
instance->mutex = tt_mutex_alloc(MutexTypeRecursive);
instance->keyboard = nullptr;
instance->loader_pubsub_subscription = tt_pubsub_subscribe(loader::get_pubsub(), &loader_callback, instance);
instance->loader_pubsub_subscription = tt_pubsub_subscribe(loader::getPubsub(), &loader_callback, instance);
tt_check(lvgl::lock(1000 / portTICK_PERIOD_MS));
instance->keyboard_group = lv_group_create();
instance->lvgl_parent = lv_scr_act();
@@ -76,21 +71,21 @@ void unlock() {
tt_check(tt_mutex_release(gui->mutex) == TtStatusOk);
}
void request_draw() {
void requestDraw() {
tt_assert(gui);
ThreadId thread_id = gui->thread->getId();
thread_flags_set(thread_id, GUI_THREAD_FLAG_DRAW);
}
void show_app(app::App& app, ViewPortShowCallback on_show, ViewPortHideCallback on_hide) {
void showApp(app::App& app, ViewPortShowCallback on_show, ViewPortHideCallback on_hide) {
lock();
tt_check(gui->app_view_port == nullptr);
gui->app_view_port = view_port_alloc(app, on_show, on_hide);
unlock();
request_draw();
requestDraw();
}
void hide_app() {
void hideApp() {
lock();
ViewPort* view_port = gui->app_view_port;
tt_check(view_port != nullptr);
+6 -6
View File
@@ -14,26 +14,26 @@ typedef struct Gui Gui;
* @param on_show
* @param on_hide
*/
void show_app(app::App& app, ViewPortShowCallback on_show, ViewPortHideCallback on_hide);
void showApp(app::App& app, ViewPortShowCallback on_show, ViewPortHideCallback on_hide);
/**
* Hide the current app's viewport.
* Does not request a re-draw because after hiding the current app,
* we always show the previous app, and there is always at least 1 app running.
*/
void hide_app();
void hideApp();
/**
* Show the on-screen keyboard.
* @param textarea the textarea to focus the input for
*/
void keyboard_show(lv_obj_t* textarea);
void keyboardShow(lv_obj_t* textarea);
/**
* Hide the on-screen keyboard.
* Has no effect when the keyboard is not visible.
*/
void keyboard_hide();
void keyboardHide();
/**
* The on-screen keyboard is only shown when both of these conditions are true:
@@ -41,7 +41,7 @@ void keyboard_hide();
* - TT_CONFIG_FORCE_ONSCREEN_KEYBOARD is set to true in tactility_config.h
* @return if we should show a on-screen keyboard for text input inside our apps
*/
bool keyboard_is_enabled();
bool keyboardIsEnabled();
/**
* Glue code for the on-screen keyboard and the hardware keyboard:
@@ -49,6 +49,6 @@ bool keyboard_is_enabled();
* - Registers the textarea to the default lv_group_t for hardware keyboards.
* @param textarea
*/
void keyboard_add_textarea(lv_obj_t* textarea);
void keyboardAddTextArea(lv_obj_t* textarea);
} // namespace
+1 -1
View File
@@ -28,7 +28,7 @@ static lv_obj_t* create_app_views(Gui* gui, lv_obj_t* parent, app::App& app) {
lv_obj_set_width(child_container, LV_PCT(100));
lv_obj_set_flex_grow(child_container, 1);
if (keyboard_is_enabled()) {
if (keyboardIsEnabled()) {
gui->keyboard = lv_keyboard_create(vertical_container);
lv_obj_add_flag(gui->keyboard, LV_OBJ_FLAG_HIDDEN);
} else {
+7 -7
View File
@@ -10,19 +10,19 @@ extern Gui* gui;
static void show_keyboard(lv_event_t* event) {
lv_obj_t* target = lv_event_get_current_target_obj(event);
keyboard_show(target);
keyboardShow(target);
lv_obj_scroll_to_view(target, LV_ANIM_ON);
}
static void hide_keyboard(TT_UNUSED lv_event_t* event) {
keyboard_hide();
keyboardHide();
}
bool keyboard_is_enabled() {
bool keyboardIsEnabled() {
return !lvgl::keypad_is_available() || TT_CONFIG_FORCE_ONSCREEN_KEYBOARD;
}
void keyboard_show(lv_obj_t* textarea) {
void keyboardShow(lv_obj_t* textarea) {
lock();
if (gui->keyboard) {
@@ -33,7 +33,7 @@ void keyboard_show(lv_obj_t* textarea) {
unlock();
}
void keyboard_hide() {
void keyboardHide() {
lock();
if (gui->keyboard) {
@@ -43,11 +43,11 @@ void keyboard_hide() {
unlock();
}
void keyboard_add_textarea(lv_obj_t* textarea) {
void keyboardAddTextArea(lv_obj_t* textarea) {
lock();
tt_check(lvgl::lock(0), "lvgl should already be locked before calling this method");
if (keyboard_is_enabled()) {
if (keyboardIsEnabled()) {
lv_obj_add_event_cb(textarea, show_keyboard, LV_EVENT_FOCUSED, nullptr);
lv_obj_add_event_cb(textarea, hide_keyboard, LV_EVENT_DEFOCUSED, nullptr);
lv_obj_add_event_cb(textarea, hide_keyboard, LV_EVENT_READY, nullptr);