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:
committed by
GitHub
parent
7187e5e49e
commit
ff4287e2ce
@@ -6,6 +6,8 @@
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
class Paths;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
bool showStatusbar : 1;
|
||||
@@ -33,6 +35,68 @@ public:
|
||||
virtual void setResult(Result result) = 0;
|
||||
virtual void setResult(Result result, std::shared_ptr<const Bundle> bundle)= 0;
|
||||
virtual bool hasResult() const = 0;
|
||||
virtual std::unique_ptr<Paths> getPaths() const = 0;
|
||||
};
|
||||
|
||||
class Paths {
|
||||
|
||||
public:
|
||||
|
||||
Paths() = default;
|
||||
virtual ~Paths() = default;
|
||||
|
||||
/**
|
||||
* Returns the directory path for the data location for an app.
|
||||
* The data directory is intended to survive OS upgrades.
|
||||
* The path will not end with a "/".
|
||||
*/
|
||||
virtual std::string getDataDirectory() const = 0;
|
||||
|
||||
/**
|
||||
* @see getDataDirectory(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getDataDirectoryLvgl() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the full path for an entry inside the data location for an app.
|
||||
* The data directory is intended to survive OS upgrades.
|
||||
* Configuration data should be stored here.
|
||||
* @param[in] childPath the path without a "/" prefix
|
||||
*/
|
||||
virtual std::string getDataPath(const std::string& childPath) const = 0;
|
||||
|
||||
/**
|
||||
* @see getDataPath(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getDataPathLvgl(const std::string& childPath) const = 0;
|
||||
|
||||
/**
|
||||
* Returns the directory path for the system location for an app.
|
||||
* The system directory is not intended to survive OS upgrades.
|
||||
* You should not store configuration data here.
|
||||
* The path will not end with a "/".
|
||||
* This is mainly used for core apps (system/boot/settings type).
|
||||
*/
|
||||
virtual std::string getSystemDirectory() const = 0;
|
||||
|
||||
/**
|
||||
* @see getSystemDirectory(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getSystemDirectoryLvgl() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the full path for an entry inside the system location for an app.
|
||||
* The data directory is not intended to survive OS upgrades.
|
||||
* You should not store configuration data here.
|
||||
* This is mainly used for core apps (system/boot/settings type).
|
||||
* @param[in] childPath the path without a "/" prefix
|
||||
*/
|
||||
virtual std::string getSystemPath(const std::string& childPath) const = 0;
|
||||
|
||||
/**
|
||||
* @see getSystemPath(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getSystemPathLvgl(const std::string& childPath) const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "app/AppInstance.h"
|
||||
#include "app/AppInstancePaths.h"
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
@@ -81,4 +82,8 @@ bool AppInstance::hasResult() const {
|
||||
return has_result;
|
||||
}
|
||||
|
||||
std::unique_ptr<Paths> AppInstance::getPaths() const {
|
||||
return std::make_unique<AppInstancePaths>(manifest);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#include "app/AppInstancePaths.h"
|
||||
#include "Partitions.h"
|
||||
|
||||
#define LVGL_PATH_PREFIX std::string("A:/")
|
||||
#ifdef ESP_PLATFORM
|
||||
#define PARTITION_PREFIX std::string("/")
|
||||
#else
|
||||
#define PARTITION_PREFIX std::string("")
|
||||
#endif
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
std::string AppInstancePaths::getDataDirectory() const {
|
||||
return PARTITION_PREFIX + DATA_PARTITION_NAME + "/app/" + manifest.id;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getDataDirectoryLvgl() const {
|
||||
return LVGL_PATH_PREFIX + DATA_PARTITION_NAME + "/app/" + manifest.id;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getDataPath(const std::string& childPath) const {
|
||||
assert(!childPath.starts_with('/'));
|
||||
return PARTITION_PREFIX + DATA_PARTITION_NAME + "/app/" + manifest.id + '/' + childPath;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getDataPathLvgl(const std::string& childPath) const {
|
||||
assert(!childPath.starts_with('/'));
|
||||
return LVGL_PATH_PREFIX + DATA_PARTITION_NAME + "/app/" + manifest.id + '/' + childPath;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getSystemDirectory() const {
|
||||
return PARTITION_PREFIX + SYSTEM_PARTITION_NAME + "/app/" + manifest.id;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getSystemDirectoryLvgl() const {
|
||||
return LVGL_PATH_PREFIX + SYSTEM_PARTITION_NAME + "/app/" + manifest.id;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getSystemPath(const std::string& childPath) const {
|
||||
assert(!childPath.starts_with('/'));
|
||||
return PARTITION_PREFIX + SYSTEM_PARTITION_NAME + "/app/" + manifest.id + '/' + childPath;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getSystemPathLvgl(const std::string& childPath) const {
|
||||
return LVGL_PATH_PREFIX + SYSTEM_PARTITION_NAME + "/app/" + manifest.id + '/' + childPath;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
#define CONFIG_TT_SPLASH_DURATION 0
|
||||
#endif
|
||||
|
||||
#define TAG "Boot"
|
||||
#define TAG "boot"
|
||||
|
||||
namespace tt::app::boot {
|
||||
|
||||
@@ -90,11 +90,11 @@ static void onShow(TT_UNUSED AppContext& app, lv_obj_t* parent) {
|
||||
lv_obj_t* image = lv_image_create(parent);
|
||||
lv_obj_set_size(image, LV_PCT(100), LV_PCT(100));
|
||||
|
||||
if (hal::usb::isUsbBootMode()) {
|
||||
lv_image_set_src(image, TT_ASSETS_BOOT_LOGO_USB);
|
||||
} else {
|
||||
lv_image_set_src(image, TT_ASSETS_BOOT_LOGO);
|
||||
}
|
||||
auto paths = app.getPaths();
|
||||
const char* logo = hal::usb::isUsbBootMode() ? "logo_usb.png" : "logo.png";
|
||||
auto logo_path = paths->getSystemPathLvgl(logo);
|
||||
TT_LOG_I(TAG, "%s", logo_path.c_str());
|
||||
lv_image_set_src(image, logo_path.c_str());
|
||||
|
||||
lvgl::obj_set_style_bg_blacken(parent);
|
||||
|
||||
|
||||
@@ -25,9 +25,8 @@ std::string getUrlFromCrashData() {
|
||||
|
||||
std::stringstream stream;
|
||||
|
||||
stream << "https://oops.bytewelder.com?";
|
||||
stream << "i=1"; // Application id
|
||||
stream << "&v=" << TT_VERSION; // Version
|
||||
stream << "https://oops.tactility.one";
|
||||
stream << "?v=" << TT_VERSION; // Version
|
||||
stream << "&a=" << CONFIG_IDF_TARGET; // Architecture
|
||||
stream << "&s="; // Stacktrace
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "app/AppContext.h"
|
||||
#include "app/ManifestRegistry.h"
|
||||
#include "Check.h"
|
||||
#include "lvgl.h"
|
||||
#include "service/loader/Loader.h"
|
||||
#include "Assets.h"
|
||||
|
||||
namespace tt::app::desktop {
|
||||
|
||||
@@ -61,9 +63,13 @@ static void onShow(TT_UNUSED AppContext& app, lv_obj_t* parent) {
|
||||
int32_t available_width = lv_display_get_horizontal_resolution(display) - (3 * 80);
|
||||
int32_t padding = TT_MIN(available_width / 4, 64);
|
||||
|
||||
createAppButton(wrapper, "Apps", "A:/assets/desktop_icon_apps.png", "AppList", 0);
|
||||
createAppButton(wrapper, "Files", "A:/assets/desktop_icon_files.png", "Files", padding);
|
||||
createAppButton(wrapper, "Settings", "A:/assets/desktop_icon_settings.png", "Settings", padding);
|
||||
auto paths = app.getPaths();
|
||||
auto apps_icon_path = paths->getSystemPathLvgl("icon_apps.png");
|
||||
auto files_icon_path = paths->getSystemPathLvgl("icon_files.png");
|
||||
auto settings_icon_path = paths->getSystemPathLvgl("icon_settings.png");
|
||||
createAppButton(wrapper, "Apps", apps_icon_path.c_str(), "AppList", 0);
|
||||
createAppButton(wrapper, "Files", files_icon_path.c_str(), "Files", padding);
|
||||
createAppButton(wrapper, "Settings", settings_icon_path.c_str(), "Settings", padding);
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
|
||||
@@ -36,6 +36,7 @@ int scandir(
|
||||
ScandirFilter _Nullable filterMethod,
|
||||
ScandirSort _Nullable sortMethod
|
||||
) {
|
||||
TT_LOG_I(TAG, "scandir start");
|
||||
DIR* dir = opendir(path.c_str());
|
||||
if (dir == nullptr) {
|
||||
TT_LOG_E(TAG, "Failed to open dir %s", path.c_str());
|
||||
@@ -55,6 +56,7 @@ int scandir(
|
||||
sort(outList.begin(), outList.end(), sortMethod);
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "scandir finish");
|
||||
return (int)outList.size();
|
||||
};
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "kernel/Kernel.h"
|
||||
#include "Log.h"
|
||||
#include "FileUtils.h"
|
||||
#include "Partitions.h"
|
||||
#include "hal/SdCard.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -51,17 +53,17 @@ bool State::setEntriesForPath(const std::string& path) {
|
||||
dir_entries.push_back({
|
||||
.d_ino = 0,
|
||||
.d_type = TT_DT_DIR,
|
||||
.d_name = "assets"
|
||||
.d_name = SYSTEM_PARTITION_NAME
|
||||
});
|
||||
dir_entries.push_back({
|
||||
.d_ino = 1,
|
||||
.d_type = TT_DT_DIR,
|
||||
.d_name = "config"
|
||||
.d_name = DATA_PARTITION_NAME
|
||||
});
|
||||
dir_entries.push_back({
|
||||
.d_ino = 2,
|
||||
.d_type = TT_DT_DIR,
|
||||
.d_name = "sdcard"
|
||||
.d_name = TT_SDCARD_MOUNT_NAME
|
||||
});
|
||||
|
||||
current_path = path;
|
||||
|
||||
@@ -24,11 +24,16 @@ static void onShow(AppContext& app, lv_obj_t* parent) {
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
auto parameters = app.getParameters();
|
||||
tt_check(parameters != nullptr, "Parameters missing");
|
||||
bool success = false;
|
||||
std::string file_argument;
|
||||
if (parameters->optString(TEXT_VIEWER_FILE_ARGUMENT, file_argument)) {
|
||||
TT_LOG_I(TAG, "Opening %s", file_argument.c_str());
|
||||
lvgl::label_set_text_file(label, file_argument.c_str());
|
||||
} else {
|
||||
if (lvgl::label_set_text_file(label, file_argument.c_str())) {
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
lv_label_set_text_fmt(label, "Failed to load %s", file_argument.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "WifiManage.h"
|
||||
|
||||
#include "Log.h"
|
||||
#include "Assets.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
#include "lvgl/Style.h"
|
||||
#include "lvgl/Toolbar.h"
|
||||
@@ -19,11 +18,11 @@ std::shared_ptr<WifiManage> _Nullable optWifiManage();
|
||||
|
||||
const char* getWifiStatusIconForRssi(int rssi) {
|
||||
if (rssi >= -60) {
|
||||
return TT_ASSETS_ICON_WIFI_SIGNAL_STRONG_BLACK;
|
||||
return "signal_strong.png";
|
||||
} else if (rssi >= -70) {
|
||||
return TT_ASSETS_ICON_WIFI_SIGNAL_MEDIUM_BLACK;
|
||||
return "signal_medium.png";
|
||||
} else {
|
||||
return TT_ASSETS_ICON_WIFI_SIGNAL_WEAK_BLACK;
|
||||
return "signal_weak.png";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,13 +110,15 @@ void View::createSsidListItem(const service::wifi::WifiApRecord& record, bool is
|
||||
lv_obj_align_to(connecting_spinner, info_wrapper, LV_ALIGN_OUT_LEFT_MID, -8, 0);
|
||||
} else {
|
||||
const char* icon = getWifiStatusIconForRssi(record.rssi);
|
||||
auto icon_path = paths->getSystemPathLvgl(icon);
|
||||
lv_obj_t* rssi_image = lv_image_create(wrapper);
|
||||
lv_image_set_src(rssi_image, icon);
|
||||
lv_image_set_src(rssi_image, icon_path.c_str());
|
||||
lv_obj_align(rssi_image, LV_ALIGN_RIGHT_MID, -42, 0);
|
||||
|
||||
if (record.auth_mode != WIFI_AUTH_OPEN) {
|
||||
lv_obj_t* lock_image = lv_image_create(wrapper);
|
||||
lv_image_set_src(lock_image, TT_ASSETS_ICON_WIFI_LOCK_BLACK);
|
||||
auto lock = paths->getSystemPathLvgl("lock.png");
|
||||
lv_image_set_src(lock_image, lock.c_str());
|
||||
lv_obj_align(lock_image, LV_ALIGN_RIGHT_MID, -62, 0);
|
||||
}
|
||||
}
|
||||
@@ -232,6 +233,8 @@ void View::updateEnableOnBootToggle() {
|
||||
void View::init(const AppContext& app, lv_obj_t* parent) {
|
||||
root = parent;
|
||||
|
||||
paths = std::move(app.getPaths());
|
||||
|
||||
// Toolbar
|
||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_t* toolbar = lvgl::toolbar_create(parent, app);
|
||||
|
||||
@@ -13,6 +13,7 @@ private:
|
||||
|
||||
Bindings* bindings;
|
||||
State* state;
|
||||
std::unique_ptr<app::Paths> paths;
|
||||
lv_obj_t* root = nullptr;
|
||||
lv_obj_t* enable_switch = nullptr;
|
||||
lv_obj_t* enable_on_boot_switch = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user