Various improvements and fixes (#128)
- Fix for display orientation assumption in Display app - Update logo (added colours) - Fix for double stopping the Files app - Deny registration of apps and services that are already registered - Updated `ideas.md` for these changes - Other cleanup
This commit is contained in:
committed by
GitHub
parent
1b89065c99
commit
49bf8e824c
@@ -16,14 +16,19 @@ void addApp(const AppManifest* manifest) {
|
||||
TT_LOG_I(TAG, "Registering manifest %s", manifest->id.c_str());
|
||||
|
||||
hash_mutex.acquire(TtWaitForever);
|
||||
app_manifest_map[manifest->id] = manifest;
|
||||
|
||||
if (app_manifest_map[manifest->id] == nullptr) {
|
||||
app_manifest_map[manifest->id] = manifest;
|
||||
} else {
|
||||
TT_LOG_E(TAG, "App id in use: %s", manifest->id.c_str());
|
||||
}
|
||||
|
||||
hash_mutex.release();
|
||||
}
|
||||
|
||||
_Nullable const AppManifest * findAppById(const std::string& id) {
|
||||
hash_mutex.acquire(TtWaitForever);
|
||||
auto iterator = app_manifest_map.find(id);
|
||||
_Nullable const AppManifest* result = iterator != app_manifest_map.end() ? iterator->second : nullptr;
|
||||
_Nullable const AppManifest* result = app_manifest_map[id.c_str()];
|
||||
hash_mutex.release();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -49,8 +49,10 @@ static void onShow(TT_UNUSED AppContext& app, lv_obj_t* parent) {
|
||||
lv_obj_set_flex_grow(wrapper, 1);
|
||||
|
||||
auto* display = lv_obj_get_display(parent);
|
||||
auto orientation = lv_display_get_rotation(display);
|
||||
if (orientation == LV_DISPLAY_ROTATION_0 || orientation == LV_DISPLAY_ROTATION_180) {
|
||||
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;
|
||||
if (is_landscape_display) {
|
||||
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_ROW);
|
||||
} else {
|
||||
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN);
|
||||
|
||||
@@ -30,17 +30,17 @@ static void onSliderEvent(lv_event_t* event) {
|
||||
}
|
||||
}
|
||||
|
||||
#define ORIENTATION_LANDSCAPE 0
|
||||
#define ORIENTATION_LANDSCAPE_FLIPPED 1
|
||||
#define ORIENTATION_PORTRAIT_LEFT 2
|
||||
#define ORIENTATION_PORTRAIT_RIGHT 3
|
||||
#define ROTATION_DEFAULT 0
|
||||
#define ROTATION_180 1
|
||||
#define ROTATION_270 2
|
||||
#define ROTATION_90 3
|
||||
|
||||
static lv_display_rotation_t orientationSettingToDisplayOrientation(uint32_t setting) {
|
||||
if (setting == ORIENTATION_LANDSCAPE_FLIPPED) {
|
||||
static lv_display_rotation_t orientationSettingToDisplayRotation(uint32_t setting) {
|
||||
if (setting == ROTATION_180) {
|
||||
return LV_DISPLAY_ROTATION_180;
|
||||
} else if (setting == ORIENTATION_PORTRAIT_LEFT) {
|
||||
} else if (setting == ROTATION_270) {
|
||||
return LV_DISPLAY_ROTATION_270;
|
||||
} else if (setting == ORIENTATION_PORTRAIT_RIGHT) {
|
||||
} else if (setting == ROTATION_90) {
|
||||
return LV_DISPLAY_ROTATION_90;
|
||||
} else {
|
||||
return LV_DISPLAY_ROTATION_0;
|
||||
@@ -49,13 +49,13 @@ static lv_display_rotation_t orientationSettingToDisplayOrientation(uint32_t set
|
||||
|
||||
static uint32_t dipslayOrientationToOrientationSetting(lv_display_rotation_t orientation) {
|
||||
if (orientation == LV_DISPLAY_ROTATION_90) {
|
||||
return ORIENTATION_PORTRAIT_RIGHT;
|
||||
return ROTATION_90;
|
||||
} else if (orientation == LV_DISPLAY_ROTATION_180) {
|
||||
return ORIENTATION_LANDSCAPE_FLIPPED;
|
||||
return ROTATION_180;
|
||||
} else if (orientation == LV_DISPLAY_ROTATION_270) {
|
||||
return ORIENTATION_PORTRAIT_LEFT;
|
||||
return ROTATION_270;
|
||||
} else {
|
||||
return ORIENTATION_LANDSCAPE;
|
||||
return ROTATION_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ static void onOrientationSet(lv_event_t* event) {
|
||||
auto* dropdown = static_cast<lv_obj_t*>(lv_event_get_target(event));
|
||||
uint32_t selected = lv_dropdown_get_selected(dropdown);
|
||||
TT_LOG_I(TAG, "Selected %ld", selected);
|
||||
lv_display_rotation_t rotation = orientationSettingToDisplayOrientation(selected);
|
||||
lv_display_rotation_t rotation = orientationSettingToDisplayRotation(selected);
|
||||
if (lv_display_get_rotation(lv_display_get_default()) != rotation) {
|
||||
lv_display_set_rotation(lv_display_get_default(), rotation);
|
||||
setRotation(rotation);
|
||||
@@ -111,8 +111,17 @@ static void onShow(AppContext& app, lv_obj_t* parent) {
|
||||
lv_label_set_text(orientation_label, "Orientation");
|
||||
lv_obj_align(orientation_label, LV_ALIGN_TOP_LEFT, 0, 40);
|
||||
|
||||
auto horizontal_px = lv_display_get_horizontal_resolution(lvgl_display);
|
||||
auto vertical_px = lv_display_get_vertical_resolution(lvgl_display);
|
||||
bool is_landscape_display = horizontal_px > vertical_px;
|
||||
|
||||
lv_obj_t* orientation_dropdown = lv_dropdown_create(wrapper);
|
||||
lv_dropdown_set_options(orientation_dropdown, "Landscape\nLandscape (flipped)\nPortrait Left\nPortrait Right");
|
||||
if (is_landscape_display) {
|
||||
lv_dropdown_set_options(orientation_dropdown, "Landscape\nLandscape (flipped)\nPortrait Left\nPortrait Right");
|
||||
} else {
|
||||
lv_dropdown_set_options(orientation_dropdown, "Portrait\nPortrait (flipped)\nLandscape Left\nLandscape Right");
|
||||
}
|
||||
|
||||
lv_obj_align(orientation_dropdown, LV_ALIGN_TOP_RIGHT, 0, 32);
|
||||
lv_obj_add_event_cb(orientation_dropdown, onOrientationSet, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
uint32_t orientation_selected = dipslayOrientationToOrientationSetting(
|
||||
|
||||
@@ -100,10 +100,6 @@ static void onNavigateUpPressed(TT_UNUSED lv_event_t* event) {
|
||||
updateViews(files_data);
|
||||
}
|
||||
|
||||
static void onExitAppPressed(TT_UNUSED lv_event_t* event) {
|
||||
service::loader::stopApp();
|
||||
}
|
||||
|
||||
static void viewFile(const char* path, const char* filename) {
|
||||
size_t path_len = strlen(path);
|
||||
size_t filename_len = strlen(filename);
|
||||
@@ -222,7 +218,6 @@ static void onShow(AppContext& app, lv_obj_t* parent) {
|
||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
||||
|
||||
lv_obj_t* toolbar = lvgl::toolbar_create(parent, "Files");
|
||||
lvgl::toolbar_set_nav_action(toolbar, LV_SYMBOL_CLOSE, &onExitAppPressed, nullptr);
|
||||
lvgl::toolbar_add_action(toolbar, LV_SYMBOL_UP, &onNavigateUpPressed, nullptr);
|
||||
|
||||
data->list = lv_list_create(parent);
|
||||
|
||||
Reference in New Issue
Block a user