Merge develop into main (#337)
- Implement `UiScale` in `hal::Configuration`: small screens with no touch can now opt for a more optimized experience (e.g. Cardputer, Waveshare 1.47, Waveshare 1.3", etc.) - Fix for Cardputer UART configuration and added I2C configuration - Fix for software keyboard bug in Gui - Removed deprecated fields from `hal::Configuration` - Updated the simulator devices to use the new HAL config - add `bool tt::hal::hasDevice(Device::Type)` - Cleanup of `AppList` app code - Improve `Gpio` app for small screen devices - Added various ESP32 GCC wrappers to wrap LVGL functions (with manipulations for small screen devices) - Moved `Launcher` assets to `assets/` subfolder - Optimized `Toolbar` for small screen devices - Stop showing `system/` partition in `FileBrowser` because it's read-only and not very useful. Created `config::SHOW_SYSTEM_PARTITION` to override this behaviour. - Hide apps when their required hardware isn't available (I2C, UART, PowerDevice) - Fix for `CYD-2432S032C` DPI setting
This commit is contained in:
committed by
GitHub
parent
ce8ac61d42
commit
53b711584f
@@ -3,18 +3,14 @@
|
||||
#include "Tactility/lvgl/Toolbar.h"
|
||||
|
||||
#include <Tactility/Assets.h>
|
||||
#include <Tactility/Check.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <algorithm>
|
||||
|
||||
namespace tt::app::applist {
|
||||
|
||||
|
||||
class AppListApp : public App {
|
||||
|
||||
private:
|
||||
|
||||
static void onAppPressed(lv_event_t* e) {
|
||||
const auto* manifest = static_cast<const AppManifest*>(lv_event_get_user_data(e));
|
||||
service::loader::startApp(manifest->id);
|
||||
@@ -23,7 +19,7 @@ private:
|
||||
static void createAppWidget(const std::shared_ptr<AppManifest>& manifest, lv_obj_t* list) {
|
||||
const void* icon = !manifest->icon.empty() ? manifest->icon.c_str() : TT_ASSETS_APP_ICON_FALLBACK;
|
||||
lv_obj_t* btn = lv_list_add_button(list, icon, manifest->name.c_str());
|
||||
lv_obj_add_event_cb(btn, &onAppPressed, LV_EVENT_SHORT_CLICKED, (void*)manifest.get());
|
||||
lv_obj_add_event_cb(btn, &onAppPressed, LV_EVENT_SHORT_CLICKED, manifest.get());
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -41,7 +37,7 @@ public:
|
||||
lv_obj_set_height(list, parent_content_height - toolbar_height);
|
||||
|
||||
auto manifests = getApps();
|
||||
std::sort(manifests.begin(), manifests.end(), SortAppManifestByName);
|
||||
std::ranges::sort(manifests, SortAppManifestByName);
|
||||
|
||||
for (const auto& manifest: manifests) {
|
||||
if (manifest->type == Type::User || manifest->type == Type::System) {
|
||||
@@ -51,7 +47,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "AppList",
|
||||
.name = "Apps",
|
||||
|
||||
@@ -101,10 +101,20 @@ void GpioApp::stopTask() {
|
||||
|
||||
// endregion Task
|
||||
|
||||
static int getSquareSpacing(hal::UiScale uiScale) {
|
||||
if (uiScale == hal::UiScale::Smallest) {
|
||||
return 0;
|
||||
} else {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
void GpioApp::onShow(AppContext& app, lv_obj_t* parent) {
|
||||
auto ui_scale = hal::getConfiguration()->uiScale;
|
||||
|
||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
|
||||
|
||||
auto* toolbar = lvgl::toolbar_create(parent, app);
|
||||
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||
|
||||
@@ -113,13 +123,16 @@ void GpioApp::onShow(AppContext& app, lv_obj_t* parent) {
|
||||
lv_obj_set_width(wrapper, LV_PCT(100));
|
||||
lv_obj_set_flex_grow(wrapper, 1);
|
||||
lv_obj_set_style_border_width(wrapper, 0, LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_all(wrapper, 0, LV_STATE_DEFAULT);
|
||||
|
||||
auto* display = lv_obj_get_display(parent);
|
||||
auto horizontal_px = lv_display_get_horizontal_resolution(display);
|
||||
auto vertical_px = lv_display_get_vertical_resolution(display);
|
||||
bool is_landscape_display = horizontal_px > vertical_px;
|
||||
|
||||
int32_t x_spacing = 20;
|
||||
constexpr auto block_width = 16;
|
||||
const auto square_spacing = getSquareSpacing(ui_scale);
|
||||
int32_t x_spacing = block_width + square_spacing;
|
||||
uint8_t column = 0;
|
||||
const uint8_t offset_from_left_label = 4;
|
||||
const uint8_t column_limit = is_landscape_display ? 10 : 5;
|
||||
@@ -138,7 +151,7 @@ void GpioApp::onShow(AppContext& app, lv_obj_t* parent) {
|
||||
|
||||
// Add a new GPIO status indicator
|
||||
auto* status_label = lv_label_create(row_wrapper);
|
||||
lv_obj_set_pos(status_label, (int32_t)((column+1) * x_spacing + offset_from_left_label), 0);
|
||||
lv_obj_set_pos(status_label, (column+1) * x_spacing + offset_from_left_label, 0);
|
||||
lv_label_set_text_fmt(status_label, "%s", LV_SYMBOL_STOP);
|
||||
lv_obj_set_style_text_color(status_label, lv_color_background_darkest(), LV_STATE_DEFAULT);
|
||||
lvPins[i] = status_label;
|
||||
@@ -153,7 +166,7 @@ void GpioApp::onShow(AppContext& app, lv_obj_t* parent) {
|
||||
|
||||
// Add a new row wrapper underneath the last one
|
||||
auto* new_row_wrapper = createGpioRowWrapper(wrapper);
|
||||
lv_obj_align_to(new_row_wrapper, row_wrapper, LV_ALIGN_BOTTOM_LEFT, 0, 4);
|
||||
lv_obj_align_to(new_row_wrapper, row_wrapper, LV_ALIGN_BOTTOM_LEFT, 0, square_spacing);
|
||||
row_wrapper = new_row_wrapper;
|
||||
|
||||
column = 0;
|
||||
|
||||
@@ -30,7 +30,8 @@ class ImageViewerApp : public App {
|
||||
lv_obj_align_to(image_wrapper, toolbar, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
|
||||
lv_obj_set_width(image_wrapper, LV_PCT(100));
|
||||
auto parent_height = lv_obj_get_height(wrapper);
|
||||
lv_obj_set_height(image_wrapper, parent_height - TOOLBAR_HEIGHT);
|
||||
auto toolbar_height = lv_obj_get_height(toolbar);
|
||||
lv_obj_set_height(image_wrapper, parent_height - toolbar_height);
|
||||
lv_obj_set_flex_flow(image_wrapper, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_align(image_wrapper, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||
lv_obj_set_style_pad_all(image_wrapper, 0, 0);
|
||||
|
||||
@@ -11,11 +11,20 @@
|
||||
namespace tt::app::launcher {
|
||||
|
||||
constexpr auto* TAG = "Launcher";
|
||||
constexpr auto BUTTON_SIZE = 64;
|
||||
|
||||
static int getButtonSize(hal::UiScale scale) {
|
||||
if (scale == hal::UiScale::Smallest) {
|
||||
return 40;
|
||||
} else {
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
|
||||
class LauncherApp final : public App {
|
||||
|
||||
static lv_obj_t* createAppButton(lv_obj_t* parent, const char* imageFile, const char* appId, int32_t horizontalMargin) {
|
||||
static lv_obj_t* createAppButton(lv_obj_t* parent, hal::UiScale uiScale, const char* imageFile, const char* appId, int32_t horizontalMargin) {
|
||||
auto button_size = getButtonSize(uiScale);
|
||||
|
||||
auto* apps_button = lv_button_create(parent);
|
||||
lv_obj_set_style_pad_all(apps_button, 0, LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_margin_hor(apps_button, horizontalMargin, LV_STATE_DEFAULT);
|
||||
@@ -28,7 +37,7 @@ class LauncherApp final : public App {
|
||||
lv_obj_set_style_image_recolor_opa(button_image, LV_OPA_COVER, LV_STATE_DEFAULT);
|
||||
// Ensure buttons are still tappable when the asset fails to load
|
||||
// Icon images are 40x40, so we get some extra padding too
|
||||
lv_obj_set_size(button_image, BUTTON_SIZE, BUTTON_SIZE);
|
||||
lv_obj_set_size(button_image, button_size, button_size);
|
||||
|
||||
lv_obj_add_event_cb(apps_button, onAppPressed, LV_EVENT_SHORT_CLICKED, (void*)appId);
|
||||
|
||||
@@ -73,6 +82,9 @@ public:
|
||||
void onShow(TT_UNUSED AppContext& app, lv_obj_t* parent) override {
|
||||
auto* buttons_wrapper = lv_obj_create(parent);
|
||||
|
||||
auto ui_scale = hal::getConfiguration()->uiScale;
|
||||
auto button_size = getButtonSize(ui_scale);
|
||||
|
||||
lv_obj_align(buttons_wrapper, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_set_style_pad_all(buttons_wrapper, 0, LV_STATE_DEFAULT);
|
||||
lv_obj_set_size(buttons_wrapper, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
@@ -89,17 +101,17 @@ public:
|
||||
lv_obj_set_flex_flow(buttons_wrapper, LV_FLEX_FLOW_COLUMN);
|
||||
}
|
||||
|
||||
const int32_t available_width = lv_display_get_horizontal_resolution(display) - (3 * BUTTON_SIZE);
|
||||
const int32_t margin = is_landscape_display ? std::min<int32_t>(available_width / 16, BUTTON_SIZE) : 0;
|
||||
const int32_t available_width = lv_display_get_horizontal_resolution(display) - (3 * button_size);
|
||||
const int32_t margin = is_landscape_display ? std::min<int32_t>(available_width / 16, button_size) : 0;
|
||||
|
||||
const auto paths = app.getPaths();
|
||||
const auto apps_icon_path = paths->getSystemPathLvgl("icon_apps.png");
|
||||
const auto files_icon_path = paths->getSystemPathLvgl("icon_files.png");
|
||||
const auto settings_icon_path = paths->getSystemPathLvgl("icon_settings.png");
|
||||
const auto apps_icon_path = paths->getSystemPathLvgl("assets/icon_apps.png");
|
||||
const auto files_icon_path = paths->getSystemPathLvgl("assets/icon_files.png");
|
||||
const auto settings_icon_path = paths->getSystemPathLvgl("assets/icon_settings.png");
|
||||
|
||||
createAppButton(buttons_wrapper, apps_icon_path.c_str(), "AppList", margin);
|
||||
createAppButton(buttons_wrapper, files_icon_path.c_str(), "Files", margin);
|
||||
createAppButton(buttons_wrapper, settings_icon_path.c_str(), "Settings", margin);
|
||||
createAppButton(buttons_wrapper, ui_scale, apps_icon_path.c_str(), "AppList", margin);
|
||||
createAppButton(buttons_wrapper, ui_scale, files_icon_path.c_str(), "Files", margin);
|
||||
createAppButton(buttons_wrapper, ui_scale, settings_icon_path.c_str(), "Settings", margin);
|
||||
|
||||
if (shouldShowPowerButton()) {
|
||||
auto* power_button = lv_btn_create(parent);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "Tactility/TactilityConfig.h"
|
||||
#include "Tactility/lvgl/Toolbar.h"
|
||||
|
||||
#include <Tactility/Assets.h>
|
||||
@@ -141,7 +142,12 @@ static void addMemoryBar(lv_obj_t* parent, const char* label, uint64_t free, uin
|
||||
lv_label_set_text_fmt(bottom_label, "%s / %s %s used", used_converted.c_str(), total_converted.c_str(), unit_label.c_str());
|
||||
lv_obj_set_width(bottom_label, LV_PCT(100));
|
||||
lv_obj_set_style_text_align(bottom_label, LV_TEXT_ALIGN_RIGHT, 0);
|
||||
lv_obj_set_style_pad_bottom(bottom_label, 12, LV_STATE_DEFAULT);
|
||||
|
||||
if (hal::getConfiguration()->uiScale == hal::UiScale::Smallest) {
|
||||
lv_obj_set_style_pad_bottom(bottom_label, 2, LV_STATE_DEFAULT);
|
||||
} else {
|
||||
lv_obj_set_style_pad_bottom(bottom_label, 12, LV_STATE_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
#if configUSE_TRACE_FACILITY
|
||||
@@ -245,9 +251,6 @@ class SystemInfoApp : public App {
|
||||
uint64_t storage_total = 0;
|
||||
uint64_t storage_free = 0;
|
||||
|
||||
if (esp_vfs_fat_info(file::MOUNT_POINT_SYSTEM, &storage_total, &storage_free) == ESP_OK) {
|
||||
addMemoryBar(storage_tab, file::MOUNT_POINT_SYSTEM, storage_free, storage_total);
|
||||
}
|
||||
|
||||
if (esp_vfs_fat_info(file::MOUNT_POINT_DATA, &storage_total, &storage_free) == ESP_OK) {
|
||||
addMemoryBar(storage_tab, file::MOUNT_POINT_DATA, storage_free, storage_total);
|
||||
@@ -264,6 +267,13 @@ class SystemInfoApp : public App {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (config::SHOW_SYSTEM_PARTITION) {
|
||||
if (esp_vfs_fat_info(file::MOUNT_POINT_SYSTEM, &storage_total, &storage_free) == ESP_OK) {
|
||||
addMemoryBar(storage_tab, file::MOUNT_POINT_SYSTEM, storage_free, storage_total);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if configUSE_TRACE_FACILITY
|
||||
|
||||
Reference in New Issue
Block a user