Swipe in from the side edge to change pages on the Guition (0.2.29)
Page swipes were an LVGL gesture anywhere on the screen: 50 px, fast only, and almost always starting on a tile that lit up as pressed. On the Guition a touch that starts within 32 px of the left or right edge and travels 40 px inward, clearly sideways, now flips one page (from the right edge leftwards is next, from the left edge rightwards previous), at any speed and in every rotation; a swipe that starts in the middle does nothing, so taps and drags on tiles can no longer change the page by accident. The whole-screen gesture is removed from the Guition profile; the CYD keeps it. Firmware 0.2.24 for both boards, the app only reworded the setting. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
+18
-12
@@ -2,11 +2,15 @@
|
||||
# Guition ESP32-S3-4848S040 / 4-inch EU wallbox, 480x480 IPS + GT911.
|
||||
# Use guition-device.yaml; see docs/GUITION.md. CYD hardware is a separate profile.
|
||||
substitutions:
|
||||
SCREEN_FIRMWARE_VERSION: "0.2.23"
|
||||
SCREEN_FIRMWARE_VERSION: "0.2.24"
|
||||
# A tap survives a finger that drifts up to this far (480 px over 72 mm: 1 cm); further is a swipe.
|
||||
TOUCH_MOVE_LIMIT_PX: "67"
|
||||
# Shortest contact that counts as a tap; a resistive panel bounces, a capacitive one does not.
|
||||
TOUCH_MIN_PRESS_MS: "20"
|
||||
# Page swipe starts in this band along the left or right edge (about 5 mm) and needs
|
||||
# this much travel inward (about 6 mm); a swipe from the middle of the screen does nothing.
|
||||
EDGE_SWIPE_BAND_PX: "32"
|
||||
EDGE_SWIPE_TRAVEL_PX: "40"
|
||||
DYNAMIC_TILES: "true"
|
||||
DASHBOARD_INBOX_INTERNAL: "false"
|
||||
DEVICE_NAME: "guition-new"
|
||||
@@ -596,6 +600,7 @@ esphome:
|
||||
then:
|
||||
- lambda: |-
|
||||
cyd::touch_guard.configure(${TOUCH_MOVE_LIMIT_PX}, ${TOUCH_MIN_PRESS_MS});
|
||||
cyd::edge_swipe.configure(${DISPLAY_W}, ${DISPLAY_H}, ${EDGE_SWIPE_BAND_PX}, ${EDGE_SWIPE_TRAVEL_PX});
|
||||
id(last_touch_ms) = millis();
|
||||
id(display_dimmed) = false;
|
||||
lv_obj_set_style_pad_row(id(vacuum_actions), 4, 0);
|
||||
@@ -634,17 +639,6 @@ esphome:
|
||||
lv_obj_add_flag(id(vacuum_overlay), LV_OBJ_FLAG_HIDDEN);
|
||||
};
|
||||
runtime_tiles::layout_changed = []() { id(show_tile_page).execute(); };
|
||||
lv_obj_add_event_cb(id(home_page)->obj, [](lv_event_t *event) {
|
||||
if(!runtime_tiles::enabled || !runtime_tiles::swipe_pages || id(display_dimmed) || id(calibration_active) ||
|
||||
!id(active_entity).empty() || (runtime_tiles::detail_root && !lv_obj_has_flag(runtime_tiles::detail_root,LV_OBJ_FLAG_HIDDEN)))return;
|
||||
auto *input=lv_indev_active();if(!input)return;
|
||||
auto direction=lv_indev_get_gesture_dir(input);
|
||||
if(direction!=LV_DIR_LEFT && direction!=LV_DIR_RIGHT)return;
|
||||
cyd::touch_guard.consume();
|
||||
lv_indev_wait_release(input);
|
||||
id(tile_page)+=direction==LV_DIR_LEFT?1:-1;
|
||||
id(show_tile_page).execute();
|
||||
}, LV_EVENT_GESTURE, nullptr);
|
||||
runtime_tiles::refresh = []() { if (!id(ui_refresh).is_running()) id(ui_refresh).execute(); };
|
||||
runtime_tiles::bind(0, id(tile1), id(t1_title), id(t1_value), id(tile1_icon_circle), id(tile1_icon_lbl));
|
||||
runtime_tiles::bind(1, id(tile2), id(t2_title), id(t2_value), id(tile2_icon_circle), id(tile2_icon_lbl));
|
||||
@@ -1807,6 +1801,7 @@ touchscreen:
|
||||
id(last_touch_ms) = millis();
|
||||
id(touch_down) = true;
|
||||
cyd::touch_guard.begin(millis(), touch.x, touch.y, touch.id);
|
||||
cyd::edge_swipe.begin(touch.x, touch.y, static_cast<int>(id(screen_lvgl).get_rotation()));
|
||||
ESP_LOGI("touch", "GT911 press x=%u y=%u test=%d", touch.x, touch.y, id(calibration_active));
|
||||
on_update:
|
||||
- lambda: |-
|
||||
@@ -1814,6 +1809,17 @@ touchscreen:
|
||||
// Only the contact that started the touch counts; the guard ignores other ids.
|
||||
for (const auto &point : touches) {
|
||||
cyd::touch_guard.update(point.x, point.y, point.id);
|
||||
if (point.id != cyd::touch_guard.contact()) continue;
|
||||
// Swiping in from a side edge flips the page ("Vegen tussen pagina's"); the tap
|
||||
// under the finger is consumed and LVGL waits for the release.
|
||||
const int step = cyd::edge_swipe.update(point.x, point.y);
|
||||
if (!step || !runtime_tiles::enabled || !runtime_tiles::swipe_pages || id(display_dimmed) || id(calibration_active) ||
|
||||
!id(active_entity).empty() || (runtime_tiles::detail_root && !lv_obj_has_flag(runtime_tiles::detail_root, LV_OBJ_FLAG_HIDDEN))) continue;
|
||||
cyd::touch_guard.consume();
|
||||
for (auto *indev = lv_indev_get_next(nullptr); indev; indev = lv_indev_get_next(indev)) lv_indev_wait_release(indev);
|
||||
ESP_LOGI("touch", "randveeg: pagina %d -> %d", id(tile_page), id(tile_page) + step);
|
||||
id(tile_page) += step;
|
||||
id(show_tile_page).execute();
|
||||
}
|
||||
on_release:
|
||||
- lambda: |-
|
||||
|
||||
Reference in New Issue
Block a user