Filesystem improvements and more (#148)

- Rename `assets` and `config` partitions to `system` and `data`
- Change partition type from `spiffs` to `fat`, so we can have sub-directories
- Fix crash when doing WiFi scan: Increased system event task size to 3kB. 
- Free up IRAM on ESP32 (it was required for the Core2, but I also freed up the same amount for Yellow Board)
- Introduced `Paths` objects that can be retrieved by `AppContext` and `ServiceContext`. Apps and services now have their own relative paths. Assets were re-arranged into the correct paths.
- Rename simulator window title to "Tactility"
- Refactored statusbar widget so it persists icon paths properly (it kept a const char* reference, but didn't copy it, so it crashed when the related std::string was destroyed)
- Created `Partitions.h` to expose some useful variables
- Moved USB config in various `sdkconfig`  (it was part of the "default" section, but it shouldn't be)
- Updated domain name
This commit is contained in:
Ken Van Hoeylandt
2025-01-05 20:44:33 +01:00
committed by GitHub
parent 7187e5e49e
commit ff4287e2ce
107 changed files with 592 additions and 259 deletions
+7 -2
View File
@@ -5,9 +5,14 @@ namespace tt::lvgl {
#define TAG "tt_lv_label"
void label_set_text_file(lv_obj_t* label, const char* filepath) {
bool label_set_text_file(lv_obj_t* label, const char* filepath) {
auto text = file::readString(filepath);
lv_label_set_text(label, (const char*)text.get());
if (text != nullptr) {
lv_label_set_text(label, (const char*)text.get());
return true;
} else {
return false;
}
}
} // namespace
+1 -1
View File
@@ -4,6 +4,6 @@
namespace tt::lvgl {
void label_set_text_file(lv_obj_t* label, const char* filepath);
bool label_set_text_file(lv_obj_t* label, const char* filepath);
} // namespace
-13
View File
@@ -1,13 +0,0 @@
#include "Spacer.h"
#include "Style.h"
namespace tt::lvgl {
lv_obj_t* spacer_create(lv_obj_t* parent, int32_t width, int32_t height) {
lv_obj_t* spacer = lv_obj_create(parent);
lv_obj_set_size(spacer, width, height);
obj_set_style_bg_invisible(spacer);
return spacer;
}
} // namespace
-10
View File
@@ -1,10 +0,0 @@
#pragma once
#include "lvgl.h"
namespace tt::lvgl {
[[deprecated("Use margin")]]
lv_obj_t* spacer_create(lv_obj_t* parent, int32_t width, int32_t height);
} // namespace
+15 -10
View File
@@ -4,7 +4,6 @@
#include "Mutex.h"
#include "Pubsub.h"
#include "TactilityCore.h"
#include "lvgl/Spacer.h"
#include "lvgl/Style.h"
#include "LvglSync.h"
@@ -15,7 +14,7 @@ namespace tt::lvgl {
#define TAG "statusbar"
struct StatusbarIcon {
const char* image = nullptr;
std::string image;
bool visible = false;
bool claimed = false;
};
@@ -89,8 +88,8 @@ static void statusbar_destructor(TT_UNUSED const lv_obj_class_t* class_p, lv_obj
}
static void update_icon(lv_obj_t* image, const StatusbarIcon* icon) {
if (icon->image != nullptr && icon->visible && icon->claimed) {
lv_image_set_src(image, icon->image);
if (!icon->image.empty() && icon->visible && icon->claimed) {
lv_image_set_src(image, icon->image.c_str());
lv_obj_remove_flag(image, LV_OBJ_FLAG_HIDDEN);
} else {
lv_obj_add_flag(image, LV_OBJ_FLAG_HIDDEN);
@@ -110,7 +109,9 @@ lv_obj_t* statusbar_create(lv_obj_t* parent) {
lv_obj_center(obj);
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_ROW);
lv_obj_t* left_spacer = spacer_create(obj, 1, 1);
lv_obj_t* left_spacer = lv_obj_create(obj);
lv_obj_set_size(left_spacer, 1, 1);
obj_set_style_bg_invisible(left_spacer);
lv_obj_set_flex_grow(left_spacer, 1);
statusbar_lock(TtWaitForever);
@@ -154,13 +155,13 @@ static void statusbar_event(TT_UNUSED const lv_obj_class_t* class_p, lv_event_t*
}
}
int8_t statusbar_icon_add(const char* _Nullable image) {
int8_t statusbar_icon_add(const std::string& image) {
statusbar_lock(TtWaitForever);
int8_t result = -1;
for (int8_t i = 0; i < STATUSBAR_ICON_LIMIT; ++i) {
if (!statusbar_data.icons[i].claimed) {
statusbar_data.icons[i].claimed = true;
statusbar_data.icons[i].visible = (image != nullptr);
statusbar_data.icons[i].visible = !image.empty();
statusbar_data.icons[i].image = image;
result = i;
TT_LOG_I(TAG, "id %d: added", i);
@@ -172,6 +173,10 @@ int8_t statusbar_icon_add(const char* _Nullable image) {
return result;
}
int8_t statusbar_icon_add() {
return statusbar_icon_add("");
}
void statusbar_icon_remove(int8_t id) {
TT_LOG_I(TAG, "id %d: remove", id);
tt_check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
@@ -179,13 +184,13 @@ void statusbar_icon_remove(int8_t id) {
StatusbarIcon* icon = &statusbar_data.icons[id];
icon->claimed = false;
icon->visible = false;
icon->image = nullptr;
icon->image = "";
tt_pubsub_publish(statusbar_data.pubsub, nullptr);
statusbar_unlock();
}
void statusbar_icon_set_image(int8_t id, const char* image) {
TT_LOG_I(TAG, "id %d: set image %s", id, image ? image : "(none)");
void statusbar_icon_set_image(int8_t id, const std::string& image) {
TT_LOG_I(TAG, "id %d: set image %s", id, image.empty() ? "(none)" : image.c_str());
tt_check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
if (statusbar_lock(50 / portTICK_PERIOD_MS)) {
StatusbarIcon* icon = &statusbar_data.icons[id];
+3 -2
View File
@@ -10,9 +10,10 @@ namespace tt::lvgl {
#define STATUSBAR_HEIGHT (STATUSBAR_ICON_SIZE + 4) // 4 extra pixels for border and outline
lv_obj_t* statusbar_create(lv_obj_t* parent);
int8_t statusbar_icon_add(const char* _Nullable image);
int8_t statusbar_icon_add(const std::string& image);
int8_t statusbar_icon_add();
void statusbar_icon_remove(int8_t id);
void statusbar_icon_set_image(int8_t id, const char* image);
void statusbar_icon_set_image(int8_t id, const std::string& image);
void statusbar_icon_set_visibility(int8_t id, bool visible);
} // namespace
-1
View File
@@ -3,7 +3,6 @@
#include "Toolbar.h"
#include "service/loader/Loader.h"
#include "lvgl/Spacer.h"
#include "lvgl/Style.h"
#include "Spinner.h"
+1
View File
@@ -16,4 +16,5 @@ void toolbar_set_nav_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callb
lv_obj_t* toolbar_add_button_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* user_data);
lv_obj_t* toolbar_add_switch_action(lv_obj_t* obj);
lv_obj_t* toolbar_add_spinner_action(lv_obj_t* obj);
} // namespace