- 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
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
#include <TactilityCore.h>
|
|
#include "TextViewer.h"
|
|
#include "lvgl.h"
|
|
#include "lvgl/LabelUtils.h"
|
|
#include "lvgl/Style.h"
|
|
#include "lvgl/Toolbar.h"
|
|
|
|
#define TAG "text_viewer"
|
|
|
|
namespace tt::app::textviewer {
|
|
|
|
static void onShow(AppContext& app, lv_obj_t* parent) {
|
|
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
|
lvgl::toolbar_create(parent, app);
|
|
|
|
lv_obj_t* wrapper = lv_obj_create(parent);
|
|
lv_obj_set_width(wrapper, LV_PCT(100));
|
|
lv_obj_set_flex_grow(wrapper, 1);
|
|
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN);
|
|
lvgl::obj_set_style_no_padding(wrapper);
|
|
lvgl::obj_set_style_bg_invisible(wrapper);
|
|
|
|
lv_obj_t* label = lv_label_create(wrapper);
|
|
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());
|
|
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());
|
|
}
|
|
}
|
|
|
|
extern const AppManifest manifest = {
|
|
.id = "TextViewer",
|
|
.name = "Text Viewer",
|
|
.type = TypeHidden,
|
|
.onShow = onShow
|
|
};
|
|
|
|
} // namespace
|