def enter_bootloader(): global ctrl, disp disp.fill(0) disp.text(10, 10, '''Bootloader Mode Entered''', size=2) ctrl.on_next_reset(ctrl.RunMode.BOOTLOADER) ctrl.reset()
def reset_bootloader(): try: import machine machine.bootloader() except ImportError: import microcontroller microcontroller.on_next_reset(microcontroller.RunMode.BOOTLOADER) microcontroller.reset()
def poll_for_host_comms(self): poll_time = time.monotonic() cmd, name, value = self.get_memory() if cmd == _CMD_GET: self._process_host_get(name) elif cmd == _CMD_SET: self._process_host_set(name, value) elif cmd == _CMD_RESET: if value == _CMD_RESET_USB: stdout("Host resetting USB IC") self.reset() self.configure() elif value == _CMD_RESET_MCU: stdout("Host rebooting MCU") microcontroller.reset() elif value == _CMD_RESET_BOOTLOADER: stdout("Host rebooting MCU into bootloader mode") microcontroller.on_next_reset( microcontroller.RunMode.BOOTLOADER) microcontroller.reset() elif cmd == _CMD_SAVE: stdout("Saving configuration to INI file") result = self._save_config_to_ini() self.set_memory(_CMD_SAVE, 0, result) if self._last_poll_time is not None and self.config["reset_on_delay"]: if poll_time - self._last_poll_time > self.config[ "loop_delay"] * 10: ## Still need to reset history, otherwise RuntimeError will be ## continously raised once the first delay occurs. self._last_poll_time = poll_time raise RuntimeError("Excessive loop delay") self._last_poll_time = poll_time
def reset_into_bootloader(): import microcontroller microcontroller.on_next_reset(microcontroller.RunMode.BOOTLOADER) microcontroller.reset()
import time import random import microcontroller from adafruit_circuitplayground.express import cpx # This is a special command that will cause a single-press RESET to go # into bootloader more (instead of double-click) to make it easier for # MakeCode-rs who don't intend to use CircuitPython! microcontroller.on_next_reset(microcontroller.RunMode.BOOTLOADER) # Set this to True to turn on the capacitive touch tones TOUCH_PIANO = True # NeoPixel color names WHITE = (50, 50, 50) OFF = (0, 0, 0) # Not too bright! cpx.pixels.brightness = 0.08 def wheel(pos): # Input a value 0 to 255 to get a color value. # The colours are a transition r - g - b - back to r. if (pos < 0) or (pos > 255): return (0, 0, 0) if pos < 85: return (int(255 - pos*3), int(pos*3), 0) elif pos < 170: pos -= 85 return (0, int(255 - (pos*3)), int(pos*3))
# Robert Cameron cpx code # 2019 October # have a sound and single sequence of lights flash in response to input motion or other signal trigger # the response should last about 1 second, and then the cpx board should go dark and quiet and wait for the next input trigger import time import random import microcontroller from adafruit_circuitplayground.express import cpx # This is a special command that will cause a single-press RESET to go # into bootloader more (instead of double-click) to make it easier for # MakeCode-rs who don't intend to use CircuitPython! microcontroller.on_next_reset(microcontroller.RunMode.BOOTLOADER) # Set this to True to turn on the capacitive touch tones TOUCH_PIANO = False # NeoPixel color names WHITE = (50, 50, 50) OFF = (0, 0, 0) # Not too bright! cpx.pixels.brightness = 0.3 def wheel(pos): # Input a value 0 to 255 to get a color value. # The colours are a transition r - g - b - back to r. if (pos < 0) or (pos > 255):
def reset_on_pin(): if safe.value is False: import microcontroller microcontroller.on_next_reset(microcontroller.RunMode.SAFE_MODE) microcontroller.reset()
import board import busio import gc import os import sys import time import microcontroller from config import * if LOAD_WATCHDOG: from watchdog import WatchDogMode w = microcontroller.watchdog w.timeout = 60.0 w.mode = WatchDogMode.RESET w.feed() microcontroller.on_next_reset(microcontroller.RunMode.NORMAL) print("import libraries") if LOAD_FREEDOM: import freedomrobotics if LOAD_DISPLAY: import displayio import terminalio import adafruit_displayio_ssd1306 from adafruit_display_text import label displayio.release_displays() if LOAD_BME680: import adafruit_bme680 if LOAD_SGP30: import adafruit_sgp30
def bootloader(*args, **kwargs): import microcontroller microcontroller.on_next_reset(microcontroller.RunMode.BOOTLOADER) microcontroller.reset()