diff --git a/internal_filesystem/boot.py b/internal_filesystem/boot.py index fc45e065..ffb80d26 100644 --- a/internal_filesystem/boot.py +++ b/internal_filesystem/boot.py @@ -81,57 +81,4 @@ indev=cst816s.CST816S(touch_dev,startup_rotation=lv.DISPLAY_ROTATION._180) # but lv.init() display.set_rotation(lv.DISPLAY_ROTATION._90) # must be done after initializing display and creating the touch drivers, to ensure proper handling -# Gesture IDs: -# 0: press -# 1: swipe from left to USB port -# 2: swipe from USB port to left -# 3: top to bottom -# 4: bottom to top -# 5: release -# 12: long press - -start_y = None # Variable to store the starting Y-coordinate of a touch -def handle_gesture(pin): - global start_y # Access the global start_y variable - indev._read_reg(0x01) - gesture_id = indev._rx_buf[0] - indev._read_reg(0x02) - finger_num = indev._rx_buf[0] - indev._read_reg(0x03) - x_h = indev._rx_buf[0] - indev._read_reg(0x04) - x_l = indev._rx_buf[0] - x = ((x_h & 0x0F) << 8) | x_l - indev._read_reg(0x05) - y_h = indev._rx_buf[0] - indev._read_reg(0x06) - y_l = indev._rx_buf[0] - y = ((y_h & 0x0F) << 8) | y_l - #print(f"GestureID={gesture_id},FingerNum={finger_num},X={x},Y={y}") - temp = y - y = TFT_VER_RES - x - #x = TFT_HOR_RES - temp - x = temp - #print(f"Corrected GestureID={gesture_id},FingerNum={finger_num},X={x},Y={y}") - if gesture_id == 0x00 and start_y is None: # Press (touch start) - # Store the starting Y-coordinate - start_y = y - #print(f"Touch started at Y={start_y}") - elif gesture_id == 0x04: # Swipe up - # print("Swipe Up Detected") - mpos.ui.close_drawer() - start_y = None # Clear start_y after gesture - elif gesture_id == 0x03: # Swipe down - if start_y is not None and start_y <= mpos.ui.NOTIFICATION_BAR_HEIGHT: - # print("Swipe Down Detected from Notification Bar") - mpos.ui.open_drawer() - start_y = None # Clear start_y after gesture - elif gesture_id == 0x05: # Release - start_y = None # Clear start_y on release - -indev._write_reg(0xEC,0x06) -indev._write_reg(0xFA,0x50) -irq_pin=machine.Pin(46,machine.Pin.IN,machine.Pin.PULL_UP) -irq_pin.irq(trigger=machine.Pin.IRQ_FALLING, handler=handle_gesture) - print("boot.py finished") diff --git a/internal_filesystem/lib/mpos/ui.py b/internal_filesystem/lib/mpos/ui.py index 0672c68d..a91a4945 100644 --- a/internal_filesystem/lib/mpos/ui.py +++ b/internal_filesystem/lib/mpos/ui.py @@ -52,6 +52,7 @@ def drawer_swipe_cb(event): x, end_y = get_pointer_xy() if end_y < drawer_swipe_start_y - NOTIFICATION_BAR_HEIGHT: mpos.ui.close_drawer() + drawer_swipe_start_y = 0 # Shutdown function to run in main thread @@ -497,11 +498,13 @@ def back_screen(): # Would be better to somehow save other events, like clicks, and pass them down to the layers below if released with x < 60 def back_swipe_cb(event): - #global rect + if drawer_open: + print("ignoring back gesture because drawer is open") + return event_code = event.get_code() - name = mpos.ui.get_event_name(event_code) - print(f"back_swipe_cb {event_code} and {name}") + #name = mpos.ui.get_event_name(event_code) + #print(f"back_swipe_cb {event_code} and {name}") #xa = rect.get_x_aligned() #ya = rect.get_y_aligned()