From e821b94c0e15e77610cdcf3573df7e1254f0ed3e Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Sun, 26 Oct 2025 09:36:46 +0100 Subject: [PATCH] Remove the old "long press on button" script This didn't work properly, and the user should be able to go to the settings app to enable bootloader mode. If that doesn't work, the hardware buttons are a foolproof method. --- internal_filesystem/builtin/system/button.py | 54 -------------------- internal_filesystem/main.py | 2 - 2 files changed, 56 deletions(-) delete mode 100644 internal_filesystem/builtin/system/button.py diff --git a/internal_filesystem/builtin/system/button.py b/internal_filesystem/builtin/system/button.py deleted file mode 100644 index 8e18f674..00000000 --- a/internal_filesystem/builtin/system/button.py +++ /dev/null @@ -1,54 +0,0 @@ -print("button.py running") - -import lvgl as lv - -from machine import Pin, Timer -import time -import _thread - -from mpos.apps import Activity, ActivityNavigator, Intent -from mpos.bootloader import ResetIntoBootloader - -# Configure IO0 as input with pull-up resistor -button = Pin(0, Pin.IN, Pin.PULL_UP) - -# Variables for long press detection -long_press_duration = 3000 -press_start_time = 0 -is_pressed = False - -# Timer for checking long press -timer = Timer(-1) - -def on_long_press(t): # Callback for when long press duration is reached. - print("button.py: long press detected") - global timer - timer.deinit() # Stop the timer - global is_pressed - if is_pressed and button.value() == 0: # Ensure button is still pressed - #_thread.stack_size(mpos.apps.good_stack_size()) - #_thread.start_new_thread(handle_long_press, ()) - #lv.async_call(lambda l: handle_long_press(), None) - intent = Intent(activity_class=ResetIntoBootloader) - ActivityNavigator.startActivity(intent) - else: - is_pressed = False - -def button_handler(pin): - """Interrupt handler for button press and release.""" - global press_start_time, is_pressed, timer - if button.value() == 0: # Button pressed (LOW due to pull-up) - print("Button IO0 pressed") - press_start_time = time.ticks_ms() - is_pressed = True - # Start timer to check for long press after long_press_duration - timer.init(mode=Timer.ONE_SHOT, period=long_press_duration, callback=on_long_press) - else: # Button released (HIGH) - print("Button IO0 released") - timer.deinit() # Cancel timer if button is released early - is_pressed = False - -# Set up interrupt for both falling (press) and rising (release) edges -button.irq(trigger=Pin.IRQ_FALLING | Pin.IRQ_RISING, handler=button_handler) - -print("button.py finished") diff --git a/internal_filesystem/main.py b/internal_filesystem/main.py index 0fd399cd..b15fb607 100644 --- a/internal_filesystem/main.py +++ b/internal_filesystem/main.py @@ -49,8 +49,6 @@ except Exception as e: # This will throw an exception if there is already a "/builtin" folder present print("main.py: WARNING: could not import/run freezefs_mount_builtin: ", e) -mpos.apps.execute_script("builtin/system/button.py", True) # Install button handler through IRQ - try: import mpos.wifi _thread.stack_size(mpos.apps.good_stack_size())