Support GPIO app in vertical orientation (#129)

... and fix getting proper display in Display app
This commit is contained in:
Ken Van Hoeylandt
2024-12-15 22:07:34 +01:00
committed by GitHub
parent 49bf8e824c
commit e4b8519f67
3 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -94,7 +94,7 @@ static void onShow(AppContext& app, lv_obj_t* parent) {
lv_slider_set_range(brightness_slider, 0, 255);
lv_obj_add_event_cb(brightness_slider, onSliderEvent, LV_EVENT_VALUE_CHANGED, nullptr);
auto* lvgl_display = lv_display_get_default();
auto* lvgl_display = lv_obj_get_display(parent);
tt_assert(lvgl_display != nullptr);
auto* hal_display = (tt::hal::Display*)lv_display_get_user_data(lvgl_display);
tt_assert(hal_display != nullptr);
+7 -2
View File
@@ -127,9 +127,14 @@ void Gpio::onShow(AppContext& app, lv_obj_t* parent) {
lv_obj_set_flex_grow(wrapper, 1);
lv_obj_set_style_border_width(wrapper, 0, 0);
uint8_t column = 0;
uint8_t column_limit = 10;
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;
uint8_t column = 0;
uint8_t column_limit = is_landscape_display ? 10 : 5;
lv_obj_t* row_wrapper = createGpioRowWrapper(wrapper);
lv_obj_align(row_wrapper, LV_ALIGN_TOP_MID, 0, 0);