|
| 1 | +frommpos.appsimportActivity |
| 2 | +importlvglaslv |
| 3 | + |
| 4 | +classResetIntoBootloader(Activity): |
| 5 | +message="Bootloader mode activated.\nYou can now install firmware over USB.\n\nReset the device to cancel." |
| 6 | + |
| 7 | +defonCreate(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 | +defonResume(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 | +defstart_bootloader(self,timer): |
| 21 | +try: |
| 22 | +importmachine |
| 23 | +machine.bootloader() |
| 24 | +exceptExceptionase: |
| 25 | +print(f"Could not reset into bootloader because:{e}") |