supervisor – Supervisor settings

Available on these boards
  • 8086 Commander
  • @sarfata shIRtty
  • ARAMCON Badge 2019
  • ARAMCON2 Badge
  • ATMegaZero ESP32-S2
  • Adafruit BLM Badge
  • Adafruit CLUE nRF52840 Express
  • Adafruit Circuit Playground Bluefruit
  • Adafruit Circuit Playground Express 4-H
  • Adafruit CircuitPlayground Express
  • Adafruit CircuitPlayground Express with Crickit libraries
  • Adafruit CircuitPlayground Express with displayio
  • Adafruit EdgeBadge
  • Adafruit Feather Bluefruit Sense
  • Adafruit Feather M0 Adalogger
  • Adafruit Feather M0 Basic
  • Adafruit Feather M0 Express
  • Adafruit Feather M0 Express with Crickit libraries
  • Adafruit Feather M0 RFM69
  • Adafruit Feather M0 RFM9x
  • Adafruit Feather M4 CAN
  • Adafruit Feather M4 Express
  • Adafruit Feather MIMXRT1011
  • Adafruit Feather RP2040
  • Adafruit Feather STM32F405 Express
  • Adafruit Feather nRF52840 Express
  • Adafruit FunHouse
  • Adafruit Gemma M0
  • Adafruit Gemma M0 PyCon 2018
  • Adafruit Grand Central M4 Express
  • Adafruit Hallowing M4 Express
  • Adafruit ItsyBitsy M0 Express
  • Adafruit ItsyBitsy M4 Express
  • Adafruit ItsyBitsy RP2040
  • Adafruit ItsyBitsy nRF52840 Express
  • Adafruit LED Glasses Driver nRF52840
  • Adafruit Macropad RP2040
  • Adafruit MagTag
  • Adafruit Matrix Portal M4
  • Adafruit Metro ESP32S2
  • Adafruit Metro M0 Express
  • Adafruit Metro M4 Airlift Lite
  • Adafruit Metro M4 Express
  • Adafruit Metro nRF52840 Express
  • Adafruit Monster M4SK
  • Adafruit NeoKey Trinkey M0
  • Adafruit NeoPixel Trinkey M0
  • Adafruit ProxLight Trinkey M0
  • Adafruit PyGamer
  • Adafruit PyPortal
  • Adafruit PyPortal Pynt
  • Adafruit PyPortal Titano
  • Adafruit PyRuler
  • Adafruit Pybadge
  • Adafruit QT Py M0
  • Adafruit QT Py M0 Haxpress
  • Adafruit QT Py RP2040
  • Adafruit QT2040 Trinkey
  • Adafruit Rotary Trinkey M0
  • Adafruit Slide Trinkey M0
  • Adafruit Trellis M4 Express
  • Adafruit Trinket M0
  • AloriumTech Evo M51
  • Arduino MKR Zero
  • Arduino MKR1300
  • Arduino Nano 33 BLE
  • Arduino Nano 33 IoT
  • Arduino Nano RP2040 Connect
  • Arduino Zero
  • Artisense Reference Design RD00
  • AtelierDuMaker nRF52840 Breakout
  • BDMICRO VINA-D21
  • BDMICRO VINA-D51
  • BLE-SS dev board Multi Sensor
  • BastBLE
  • BastWiFi
  • BlueMicro840
  • CP Sapling M0
  • CP Sapling M0 w/ SPI Flash
  • CP32-M4
  • Capable Robot Programmable USB Hub
  • Cedar Grove StringCar M0 Express
  • Challenger RP2040 WiFi
  • Circuit Playground Express Digi-Key PyCon 2019
  • CircuitBrains Basic
  • CircuitBrains Deluxe
  • CrumpS2
  • Cytron Maker Pi RP2040
  • DynOSSAT-EDU-EPS
  • DynOSSAT-EDU-OBC
  • DynaLoRa_USB
  • ESP 12k NodeMCU
  • Electronic Cats Bast Pro Mini M0
  • Electronic Cats CatWAN USBStick
  • Electronic Cats Hunter Cat NFC
  • Electronic Cats NFC Copy Cat
  • Electronut Labs Blip
  • Electronut Labs Papyr
  • EncoderPad RP2040
  • Escornabot Makech
  • Espruino Pico
  • Espruino Wifi
  • Feather ESP32S2 without PSRAM
  • Feather MIMXRT1011
  • Feather MIMXRT1062
  • FeatherS2
  • FeatherS2 Neo
  • FeatherS2 PreRelease
  • Fluff M0
  • Fomu
  • Franzininho WIFI w/Wroom
  • Franzininho WIFI w/Wrover
  • Gravitech Cucumber M
  • Gravitech Cucumber MS
  • Gravitech Cucumber R
  • Gravitech Cucumber RS
  • HMI-DevKit-1.1
  • Hacked Feather M0 Express with 8Mbyte SPI flash
  • HalloWing M0 Express
  • HiiBot BlueFi
  • IMXRT1010-EVK
  • IkigaiSense Vita nRF52840
  • J&J Studios datum-Distance
  • J&J Studios datum-IMU
  • J&J Studios datum-Light
  • J&J Studios datum-Weather
  • Kaluga 1
  • LILYGO TTGO T8 ESP32-S2 w/Display
  • LoC BeR M4 base board
  • MDBT50Q-DB-40
  • MDBT50Q-RX Dongle
  • MEOWBIT
  • MORPHEANS MorphESP-240
  • MakerDiary nRF52840 MDK
  • MakerDiary nRF52840 MDK USB Dongle
  • Makerdiary M60 Keyboard
  • Makerdiary Pitaya Go
  • Makerdiary nRF52840 M.2 Developer Kit
  • Meow Meow
  • Metro MIMXRT1011
  • Mini SAM M4
  • NUCLEO STM32F746
  • NUCLEO STM32F767
  • NUCLEO STM32H743
  • OPENMV-H7 R1
  • Oak Dev Tech PixelWing ESP32S2
  • Open Hardware Summit 2020 Badge
  • PCA10056 nRF52840-DK
  • PCA10059 nRF52840 Dongle
  • PCA10100 nRF52833 Dongle
  • PYB LR Nano V2
  • Particle Argon
  • Particle Boron
  • Particle Xenon
  • PewPew 10.2
  • PewPew 13
  • PewPew M4
  • PicoPlanet
  • Pimoroni Interstate 75
  • Pimoroni Keybow 2040
  • Pimoroni PGA2040
  • Pimoroni Pico LiPo (16MB)
  • Pimoroni Pico LiPo (4MB)
  • Pimoroni PicoSystem
  • Pimoroni Plasma 2040
  • Pimoroni Tiny 2040
  • PyCubedv04
  • PyCubedv04-MRAM
  • PyboardV1_1
  • Raspberry Pi Pico
  • Robo HAT MM1 M4
  • S2Mini
  • SAM E54 Xplained Pro
  • SAM32v26
  • SPRESENSE
  • ST STM32F746G Discovery
  • STM32F411E_DISCO
  • STM32F412G_DISCO
  • STM32F4_DISCO
  • Saola 1 w/Wroom
  • Saola 1 w/Wrover
  • Seeeduino Wio Terminal
  • Seeeduino XIAO
  • Serpente
  • Silicognition LLC M4-Shim
  • Simmel
  • SparkFun LUMIDrive
  • SparkFun MicroMod RP2040 Processor
  • SparkFun MicroMod SAMD51 Processor
  • SparkFun MicroMod nRF52840 Processor
  • SparkFun Pro Micro RP2040
  • SparkFun Pro nRF52840 Mini
  • SparkFun Qwiic Micro
  • SparkFun RedBoard Turbo
  • SparkFun SAMD21 Dev Breakout
  • SparkFun SAMD21 Mini Breakout
  • SparkFun STM32 MicroMod Processor
  • SparkFun Thing Plus - RP2040
  • SparkFun Thing Plus - SAMD51
  • Sprite_v2b
  • StackRduino M0 PRO
  • TG-Boards' Datalore IP M4
  • TG-Watch
  • THUNDERPACK_v11
  • THUNDERPACK_v12
  • Targett Module Clip w/Wroom
  • Targett Module Clip w/Wrover
  • Teensy 4.0
  • Teensy 4.1
  • Teknikio Bluebird
  • The Open Book Feather
  • TinkeringTech ScoutMakes Azul
  • TinyS2
  • Trinket M0 Haxpress
  • UARTLogger II
  • WarmBit BluePixel nRF52840
  • Winterbloom Big Honking Button
  • Winterbloom Sol
  • XinaBox CC03
  • XinaBox CS11
  • iMX RT 1020 EVK
  • iMX RT 1060 EVK
  • keithp.com snekboard
  • micro:bit v2
  • microS2
  • nanoESP32-S2 w/Wrover
  • nanoESP32-S2 w/Wroom
  • ndGarage[n°] Bit6: FeatherSnow-v2
  • ndGarage[n°]Bit6:FeatherSnow
  • nice!nano
  • senseBox MCU
  • stm32f411ce-blackpill
  • stm32f411ce-blackpill-with-flash
  • uChip
  • uGame10

supervisor.runtime :Runtime

Runtime information, such as runtime.serial_connected (USB serial connection status). This object is the sole instance of supervisor.Runtime.

supervisor.enable_autoreload()None

Enable autoreload based on USB file write activity.

supervisor.disable_autoreload()None

Disable autoreload based on USB file write activity until enable_autoreload is called.

supervisor.set_rgb_status_brightness(brightness: int)None

Set brightness of status neopixel from 0-255 set_rgb_status_brightness is called.

supervisor.reload()None

Reload the main Python code and run it (equivalent to hitting Ctrl-D at the REPL).

supervisor.set_next_stack_limit(size: int)None

Set the size of the stack for the next vm run. If its too large, the default will be used.

supervisor.set_next_code_file(filename: Optional[str], *, reload_on_success: bool = False, reload_on_error: bool = False, sticky_on_success: bool = False, sticky_on_error: bool = False, sticky_on_reload: bool = False)None

Set what file to run on the next vm run.

When not None, the given filename is inserted at the front of the usual [‘code.py’, ‘main.py’] search sequence.

The optional keyword arguments specify what happens after the specified file has run:

sticky_on_… determine whether the newly set filename and options stay in effect: If True, further runs will continue to run that file (unless it says otherwise by calling set_next_code_filename() itself). If False, the settings will only affect one run and revert to the standard code.py/main.py afterwards.

reload_on_… determine how to continue: If False, wait in the usual “Code done running. Waiting for reload. / Press any key to enter the REPL. Use CTRL-D to reload.” state. If True, reload immediately as if CTRL-D was pressed.

…_on_success take effect when the program runs to completion or calls sys.exit().

…_on_error take effect when the program exits with an exception, including the KeyboardInterrupt caused by CTRL-C.

…_on_reload take effect when the program is interrupted by files being written to the USB drive (auto-reload) or when it calls supervisor.reload().

These settings are stored in RAM, not in persistent memory, and will therefore only affect soft reloads. Powering off or resetting the device will always revert to standard settings.

When called multiple times in the same run, only the last call takes effect, replacing any settings made by previous ones. This is the main use of passing None as a filename: to reset to the standard search sequence.

supervisor.ticks_ms()int

Return the time in milliseconds since an unspecified reference point, wrapping after 2**29ms.

The value is initialized so that the first overflow occurs about 65 seconds after power-on, making it feasible to check that your program works properly around an overflow.

The wrap value was chosen so that it is always possible to add or subtract two ticks_ms values without overflow on a board without long ints (or without allocating any long integer objects, on boards with long ints).

This ticks value comes from a low-accuracy clock internal to the microcontroller, just like time.monotonic. Due to its low accuracy and the fact that it “wraps around” every few days, it is intended for working with short term events like advancing an LED animation, not for long term events like counting down the time until a holiday.

Addition, subtraction, and comparison of ticks values can be done with routines like the following:

_TICKS_PERIOD = const(1<<29)
_TICKS_MAX = const(_TICKS_PERIOD-1)
_TICKS_HALFPERIOD = const(_TICKS_PERIOD//2)

def ticks_add(ticks, delta):
    "Add a delta to a base number of ticks, performing wraparound at 2**29ms."
    return (a + b) % _TICKS_PERIOD

def ticks_diff(ticks1, ticks2):
    "Compute the signed difference between two ticks values, assuming that they are within 2**28 ticks"
    diff = (ticks1 - ticks2) & _TICKS_MAX
    diff = ((diff + _TICKS_HALFPERIOD) & _TICKS_MAX) - _TICKS_HALFPERIOD
    return diff

def ticks_less(ticks1, ticks2):
    "Return true iff ticks1 is less than ticks2, assuming that they are within 2**28 ticks"
    return ticks_diff(ticks1, ticks2) < 0
supervisor.get_previous_traceback()Optional[str]

If the last vm run ended with an exception (including the KeyboardInterrupt caused by CTRL-C), returns the traceback as a string. Otherwise, returns None.

An exception traceback is only preserved over a soft reload, a hard reset clears it.

Only code (main or boot) runs are considered, not REPL runs.

supervisor.disable_ble_workflow()None

Disable ble workflow until a reset. This prevents BLE advertising outside of the VM and the services used for it.

class supervisor.RunReason

The reason that CircuitPython started running.

STARTUP :object

CircuitPython started the microcontroller started up. See microcontroller.Processor.reset_reason for more detail on why the microcontroller was started.

AUTO_RELOAD :object

CircuitPython restarted due to an external write to the filesystem.

SUPERVISOR_RELOAD :object

CircuitPython restarted due to a call to supervisor.reload().

REPL_RELOAD :object

CircuitPython started due to the user typing CTRL-D in the REPL.

class supervisor.Runtime

Current status of runtime objects.

Usage:

import supervisor
if supervisor.runtime.serial_connected:
    print("Hello World!")

You cannot create an instance of supervisor.Runtime. Use supervisor.runtime to access the sole instance available.

usb_connected :bool

Returns the USB enumeration status (read-only).

serial_connected :bool

Returns the USB serial communication status (read-only).

serial_bytes_available :int

Returns the whether any bytes are available to read on the USB serial input. Allows for polling to see whether to call the built-in input() or wait. (read-only)

run_reason :RunReason

Returns why CircuitPython started running this particular time.