Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit32b4204

Browse files
Use as activity
1 parent3eb2908 commit32b4204

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

‎internal_filesystem/builtin/system/button.py‎

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
print("button.py running")
22

3+
importlvglaslv
4+
35
frommachineimportPin,Timer
46
importtime
57
import_thread
68

7-
importmpos.apps
9+
frommpos.appsimportActivity,ActivityNavigator,Intent
10+
11+
#import mpos.config
12+
#import mpos.ui
13+
14+
#import mpos.apps
815

916
# Configure IO0 as input with pull-up resistor
1017
button=Pin(0,Pin.IN,Pin.PULL_UP)
@@ -17,28 +24,38 @@
1724
# Timer for checking long press
1825
timer=Timer(-1)
1926

20-
message="Bootloader mode activated.\nYou can now install firmware over USB.\n\n"
27+
message="Bootloader mode activated.\nYou can now install firmware over USB.\n\nReset the device to cancel."
28+
29+
classBootloader(Activity):
30+
31+
defonCreate(self):
32+
print(message)
33+
screen=lv.obj()
34+
label=lv.label(screen)
35+
label.set_text(message)
36+
label.center()
37+
self.setContentView(screen)
38+
39+
defonResume(self,screen):
40+
# Use a timer, otherwise the UI won't have time to update:
41+
timer=lv.timer_create(self.start_bootloader,1000,None)# give it some time (at least 500ms) for the new screen animation
42+
timer.set_repeat_count(1)
2143

22-
defhandle_long_press():
23-
print(message)
24-
importlvglaslv
25-
screen=lv.obj()
26-
label=lv.label(screen)
27-
label.set_text(message)
28-
label.center()
29-
lv.screen_load(screen)
30-
time.sleep(1)
31-
importmachine
32-
machine.bootloader()
44+
defstart_bootloader(self,timer):
45+
importmachine
46+
machine.bootloader()
3347

3448
defon_long_press(t):# Callback for when long press duration is reached.
3549
print("button.py: long press detected")
3650
globaltimer
3751
timer.deinit()# Stop the timer
3852
globalis_pressed
3953
ifis_pressedandbutton.value()==0:# Ensure button is still pressed
40-
_thread.stack_size(mpos.apps.good_stack_size())
41-
_thread.start_new_thread(handle_long_press, ())
54+
#_thread.stack_size(mpos.apps.good_stack_size())
55+
#_thread.start_new_thread(handle_long_press, ())
56+
#lv.async_call(lambda l: handle_long_press(), None)
57+
intent=Intent(activity_class=Bootloader)
58+
ActivityNavigator.startActivity(intent)
4259
else:
4360
is_pressed=False
4461

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp