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

Commit0642c39

Browse files
Add Restart to Bootloader setting
1 parent0ff2ff2 commit0642c39

File tree

3 files changed

+16
-32
lines changed

3 files changed

+16
-32
lines changed

‎CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
=====
33
- Tweak button size in drawer and add "Settings" button
44
- Show "Brightness" text in drawer
5-
- Add builtin "Settings" app with settings for dark/light theme, theme color
5+
- Save and restore "Brightness" setting
6+
- Add builtin "Settings" app with settings for Light/Dark Theme, Theme Color, Restart to Bootloader
67

78
0.0.5
89
=====

‎internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
frommpos.appsimportActivity,Intent
1+
frommpos.appsimportActivity,ActivityNavigator,Intent
2+
23
importmpos.config
34
importmpos.ui
45

5-
classHello(Activity):
6-
7-
defonCreate(self):
8-
screen=lv.obj()
9-
label=lv.label(screen)
10-
label.set_text('Hello World!')
11-
label.center()
12-
self.setContentView(screen)
13-
146

157
# Used to list and edit all settings:
168
classSettingsActivity(Activity):
@@ -20,9 +12,10 @@ def __init__(self):
2012
self.settings= [
2113
{"title":"Light/Dark Theme","key":"theme_light_dark","value_label":None,"cont":None},
2214
{"title":"Theme Color","key":"theme_primary_color","value_label":None,"cont":None,"placeholder":"HTML hex color, like: EC048C"},
15+
{"title":"Restart to Bootloader","key":"boot_mode","value_label":None,"cont":None},# special that doesn't get saved
16+
# This is currently only in the drawer but would make sense to have it here for completeness:
2317
#{"title": "Display Brightness", "key": "display_brightness", "value_label": None, "cont": None, "placeholder": "A value from 0 to 100."},
2418
# Maybe also add font size (but ideally then all fonts should scale up/down)
25-
#{"title": "Reboot into Bootloader", "key": "boot_mode", "value_label": None, "cont": None}, # special that doesn't get saved
2619
#{"title": "Timezone", "key": "timezone", "value_label": None, "cont": None, "placeholder": "Example: Europe/Prague"},
2720
]
2821

@@ -238,6 +231,13 @@ def cambutton_cb_unused(self, event):
238231
self.startActivityForResult(Intent(activity_class=CameraApp).putExtra("scanqr_mode",True),self.gotqr_result_callback)
239232

240233
defsave_setting(self,setting):
234+
ifsetting["key"]=="boot_mode"andself.radio_container:
235+
ifself.active_radio_index==1:
236+
frommpos.bootloaderimportResetIntoBootloader
237+
intent=Intent(activity_class=ResetIntoBootloader)
238+
ActivityNavigator.startActivity(intent)
239+
return
240+
241241
if (setting["key"]=="theme_light_dark"orsetting["key"]=="boot_mode" )andself.radio_container:
242242
ifsetting["key"]=="boot_mode":
243243
options= [("Normal","normal"), ("Bootloader","bootloader")]

‎internal_filesystem/builtin/system/button.py‎

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
frommpos.appsimportActivity,ActivityNavigator,Intent
1010

11+
frommpos.bootloaderimportResetIntoBootloader
12+
1113
#import mpos.config
1214
#import mpos.ui
1315

@@ -24,26 +26,7 @@
2426
# Timer for checking long press
2527
timer=Timer(-1)
2628

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)
4329

44-
defstart_bootloader(self,timer):
45-
importmachine
46-
machine.bootloader()
4730

4831
defon_long_press(t):# Callback for when long press duration is reached.
4932
print("button.py: long press detected")
@@ -54,7 +37,7 @@ def on_long_press(t): # Callback for when long press duration is reached.
5437
#_thread.stack_size(mpos.apps.good_stack_size())
5538
#_thread.start_new_thread(handle_long_press, ())
5639
#lv.async_call(lambda l: handle_long_press(), None)
57-
intent=Intent(activity_class=Bootloader)
40+
intent=Intent(activity_class=ResetIntoBootloader)
5841
ActivityNavigator.startActivity(intent)
5942
else:
6043
is_pressed=False

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp