Skip to content

Commit 0317f38

Browse files
boot.py: remove gesture handling (done by ui now)
1 parent b283ca2 commit 0317f38

File tree

2 files changed

+6
-56
lines changed

2 files changed

+6
-56
lines changed

internal_filesystem/boot.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -81,57 +81,4 @@
8181
lv.init()
8282
display.set_rotation(lv.DISPLAY_ROTATION._90) # must be done after initializing display and creating the touch drivers, to ensure proper handling
8383

84-
# Gesture IDs:
85-
# 0: press
86-
# 1: swipe from left to USB port
87-
# 2: swipe from USB port to left
88-
# 3: top to bottom
89-
# 4: bottom to top
90-
# 5: release
91-
# 12: long press
92-
93-
start_y = None # Variable to store the starting Y-coordinate of a touch
94-
def handle_gesture(pin):
95-
global start_y # Access the global start_y variable
96-
indev._read_reg(0x01)
97-
gesture_id = indev._rx_buf[0]
98-
indev._read_reg(0x02)
99-
finger_num = indev._rx_buf[0]
100-
indev._read_reg(0x03)
101-
x_h = indev._rx_buf[0]
102-
indev._read_reg(0x04)
103-
x_l = indev._rx_buf[0]
104-
x = ((x_h & 0x0F) << 8) | x_l
105-
indev._read_reg(0x05)
106-
y_h = indev._rx_buf[0]
107-
indev._read_reg(0x06)
108-
y_l = indev._rx_buf[0]
109-
y = ((y_h & 0x0F) << 8) | y_l
110-
#print(f"GestureID={gesture_id},FingerNum={finger_num},X={x},Y={y}")
111-
temp = y
112-
y = TFT_VER_RES - x
113-
#x = TFT_HOR_RES - temp
114-
x = temp
115-
#print(f"Corrected GestureID={gesture_id},FingerNum={finger_num},X={x},Y={y}")
116-
if gesture_id == 0x00 and start_y is None: # Press (touch start)
117-
# Store the starting Y-coordinate
118-
start_y = y
119-
#print(f"Touch started at Y={start_y}")
120-
elif gesture_id == 0x04: # Swipe up
121-
# print("Swipe Up Detected")
122-
mpos.ui.close_drawer()
123-
start_y = None # Clear start_y after gesture
124-
elif gesture_id == 0x03: # Swipe down
125-
if start_y is not None and start_y <= mpos.ui.NOTIFICATION_BAR_HEIGHT:
126-
# print("Swipe Down Detected from Notification Bar")
127-
mpos.ui.open_drawer()
128-
start_y = None # Clear start_y after gesture
129-
elif gesture_id == 0x05: # Release
130-
start_y = None # Clear start_y on release
131-
132-
indev._write_reg(0xEC,0x06)
133-
indev._write_reg(0xFA,0x50)
134-
irq_pin=machine.Pin(46,machine.Pin.IN,machine.Pin.PULL_UP)
135-
irq_pin.irq(trigger=machine.Pin.IRQ_FALLING, handler=handle_gesture)
136-
13784
print("boot.py finished")

internal_filesystem/lib/mpos/ui.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def drawer_swipe_cb(event):
5252
x, end_y = get_pointer_xy()
5353
if end_y < drawer_swipe_start_y - NOTIFICATION_BAR_HEIGHT:
5454
mpos.ui.close_drawer()
55+
drawer_swipe_start_y = 0
5556

5657

5758
# Shutdown function to run in main thread
@@ -497,11 +498,13 @@ def back_screen():
497498

498499
# Would be better to somehow save other events, like clicks, and pass them down to the layers below if released with x < 60
499500
def back_swipe_cb(event):
500-
#global rect
501+
if drawer_open:
502+
print("ignoring back gesture because drawer is open")
503+
return
501504

502505
event_code = event.get_code()
503-
name = mpos.ui.get_event_name(event_code)
504-
print(f"back_swipe_cb {event_code} and {name}")
506+
#name = mpos.ui.get_event_name(event_code)
507+
#print(f"back_swipe_cb {event_code} and {name}")
505508

506509
#xa = rect.get_x_aligned()
507510
#ya = rect.get_y_aligned()

0 commit comments

Comments
 (0)