ecad2248d9
- Fixed crash when returning to Setup app (from any of the steps) - Fixed crash when returning to TimeDateSettings app (after locale selection) - Fixed GuiService inconsistent behaviour: now always perform operations async (e.g. to show/hide apps). This fixes crashes in some onHide() calls where onHide() might be called before onShow() was called. - Fix for incorrect WebServService path - Remove CYD-4848S040C SD card functionality, but added a GPIO fix for releasing 3-wire SPI pin sharing. - Fix for saving/loading settings for various apps
106 lines
2.8 KiB
C++
106 lines
2.8 KiB
C++
#pragma once
|
|
|
|
#include <Tactility/MessageQueue.h>
|
|
#include <Tactility/PubSub.h>
|
|
#include <Tactility/RecursiveMutex.h>
|
|
#include <Tactility/app/AppContext.h>
|
|
#include <Tactility/service/Service.h>
|
|
#include <Tactility/service/loader/Loader.h>
|
|
|
|
#include <tactility/concurrent/dispatcher.h>
|
|
|
|
#include <cstdio>
|
|
#include <lvgl.h>
|
|
|
|
namespace tt::service::gui {
|
|
|
|
/**
|
|
* Output a log warning if the current task is the GUI task.
|
|
* This is meant for code that should either create their own task or use a different task to execute on.
|
|
* @param[in] context a descriptive name or label that refers to the caller of this function
|
|
*/
|
|
void warnIfRunningOnGuiTask(const char* context);
|
|
|
|
class GuiService final : public Service {
|
|
|
|
// Thread and lock
|
|
Thread* thread = nullptr;
|
|
DispatcherHandle_t dispatcher = nullptr;
|
|
bool exitRequested = false;
|
|
RecursiveMutex mutex;
|
|
PubSub<loader::LoaderService::Event>::SubscriptionHandle loader_pubsub_subscription = nullptr;
|
|
|
|
// Layers and Canvas
|
|
lv_obj_t* appRootWidget = nullptr;
|
|
lv_obj_t* statusbarWidget = nullptr;
|
|
|
|
// App-specific
|
|
std::shared_ptr<app::AppInstance> appToRender = nullptr;
|
|
|
|
lv_obj_t* keyboard = nullptr;
|
|
lv_group_t* keyboardGroup = nullptr;
|
|
|
|
bool isStarted = false;
|
|
|
|
static int32_t guiMain();
|
|
|
|
static void onGuiDispatch(void* context);
|
|
|
|
void onLoaderEvent(loader::LoaderService::Event event);
|
|
|
|
lv_obj_t* createAppViews(lv_obj_t* parent);
|
|
|
|
void redraw();
|
|
|
|
void lock() const {
|
|
check(mutex.lock(pdMS_TO_TICKS(1000)));
|
|
}
|
|
|
|
void unlock() const {
|
|
mutex.unlock();
|
|
}
|
|
|
|
void showApp(std::shared_ptr<app::AppInstance> app);
|
|
|
|
void hideApp();
|
|
|
|
public:
|
|
|
|
bool onStart(ServiceContext& service) override;
|
|
|
|
void onStop(ServiceContext& service) override;
|
|
|
|
/**
|
|
* Show the on-screen keyboard.
|
|
* @param[in] textarea the textarea to focus the input for
|
|
*/
|
|
void softwareKeyboardShow(lv_obj_t* textarea);
|
|
|
|
/**
|
|
* Hide the on-screen keyboard.
|
|
* Has no effect when the keyboard is not visible.
|
|
*/
|
|
void softwareKeyboardHide();
|
|
|
|
/**
|
|
* The on-screen keyboard is only shown when both of these conditions are true:
|
|
* - there is no hardware keyboard
|
|
* - 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 softwareKeyboardIsEnabled();
|
|
|
|
/**
|
|
* Glue code for the on-screen keyboard and the hardware keyboard:
|
|
* - Attach automatic hide/show parameters for the on-screen keyboard.
|
|
* - Registers the textarea to the default lv_group_t for hardware keyboards.
|
|
* @param[in] textarea
|
|
*/
|
|
void keyboardAddTextArea(lv_obj_t* textarea);
|
|
|
|
};
|
|
|
|
std::shared_ptr<GuiService> findService();
|
|
|
|
} // namespace
|