Various improvements (#461)
* **New Features** * Time and delay utilities added (ticks, ms, µs); SD card now uses an expansion-header CS pin; HTTP downloads warn when run on the GUI task and yield to avoid blocking. * **Bug Fixes / Reliability** * Many hard-crash paths converted to guarded checks to reduce abrupt termination and improve stability. * **Tests** * Unit tests added to validate time and delay accuracy. * **Chores** * License header and build/macro updates.
This commit is contained in:
committed by
GitHub
parent
619b5aa53b
commit
e6abd496f9
@@ -1,5 +1,7 @@
|
||||
#include <Tactility/service/gui/GuiService.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <Tactility/app/AppInstance.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
@@ -15,6 +17,15 @@ extern const ServiceManifest manifest;
|
||||
static const auto LOGGER = Logger("GuiService");
|
||||
using namespace loader;
|
||||
|
||||
constexpr auto* GUI_TASK_NAME = "gui";
|
||||
|
||||
void warnIfRunningOnGuiTask(const char* context) {
|
||||
const char* task_name = pcTaskGetName(nullptr);
|
||||
if (strcmp(GUI_TASK_NAME, task_name) == 0) {
|
||||
LOGGER.warn("{} shouldn't run on the GUI task", context);
|
||||
}
|
||||
}
|
||||
|
||||
// region AppManifest
|
||||
|
||||
void GuiService::onLoaderEvent(LoaderService::Event event) {
|
||||
@@ -114,7 +125,7 @@ void GuiService::redraw() {
|
||||
unlock();
|
||||
}
|
||||
|
||||
bool GuiService::onStart(TT_UNUSED ServiceContext& service) {
|
||||
bool GuiService::onStart(ServiceContext& service) {
|
||||
auto* screen_root = lv_screen_active();
|
||||
if (screen_root == nullptr) {
|
||||
LOGGER.error("No display found");
|
||||
@@ -122,11 +133,13 @@ bool GuiService::onStart(TT_UNUSED ServiceContext& service) {
|
||||
}
|
||||
|
||||
thread = new Thread(
|
||||
"gui",
|
||||
GUI_TASK_NAME,
|
||||
4096, // Last known minimum was 2800 for launching desktop
|
||||
[]() { return guiMain(); }
|
||||
);
|
||||
|
||||
thread->setPriority(THREAD_PRIORITY_SERVICE);
|
||||
|
||||
const auto loader = findLoaderService();
|
||||
assert(loader != nullptr);
|
||||
loader_pubsub_subscription = loader->getPubsub()->subscribe([this](auto event) {
|
||||
@@ -169,7 +182,7 @@ bool GuiService::onStart(TT_UNUSED ServiceContext& service) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void GuiService::onStop(TT_UNUSED ServiceContext& service) {
|
||||
void GuiService::onStop(ServiceContext& service) {
|
||||
lock();
|
||||
|
||||
const auto loader = findLoaderService();
|
||||
@@ -186,7 +199,7 @@ void GuiService::onStop(TT_UNUSED ServiceContext& service) {
|
||||
|
||||
unlock();
|
||||
|
||||
tt_check(lvgl::lock(1000 / portTICK_PERIOD_MS));
|
||||
check(lvgl::lock(1000 / portTICK_PERIOD_MS));
|
||||
lv_group_delete(keyboardGroup);
|
||||
lvgl::unlock();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user