Skip to content

Commit f5c5b1d

Browse files
Add bootloader.py
1 parent 5e81bf2 commit f5c5b1d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from mpos.apps import Activity
2+
import lvgl as lv
3+
4+
class ResetIntoBootloader(Activity):
5+
message = "Bootloader mode activated.\nYou can now install firmware over USB.\n\nReset the device to cancel."
6+
7+
def onCreate(self):
8+
print(self.message)
9+
screen = lv.obj()
10+
label = lv.label(screen)
11+
label.set_text(self.message)
12+
label.center()
13+
self.setContentView(screen)
14+
15+
def onResume(self, screen):
16+
# Use a timer, otherwise the UI won't have time to update:
17+
timer = lv.timer_create(self.start_bootloader, 1000, None) # give it some time (at least 500ms) for the new screen animation
18+
timer.set_repeat_count(1)
19+
20+
def start_bootloader(self, timer):
21+
try:
22+
import machine
23+
machine.bootloader()
24+
except Exception as e:
25+
print(f"Could not reset into bootloader because: {e}")

0 commit comments

Comments
 (0)