Skip to content

Commit

Permalink
Add enter_bootloader
Browse files Browse the repository at this point in the history
  • Loading branch information
bessman committed Nov 15, 2023
1 parent 0a9350b commit d2b08ec
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pslab/sciencelab.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
if you need to use several at once the ScienceLab class provides a convenient
collection.
"""
import time
from typing import Iterable, List

import pslab.protocol as CP
Expand Down Expand Up @@ -126,6 +127,16 @@ def reset(self):
self.send_byte(CP.COMMON)
self.send_byte(CP.RESTORE_STANDALONE)

def enter_bootloader(self):
"""Reboot and stay in bootloader mode."""
self.reset()
# The PSLab's RGB LED flashes some colors on boot.
boot_lightshow_time = 0.6
# Wait before sending magic number to make sure UART is initialized.
time.sleep(boot_lightshow_time / 2)
# PIC24 UART RX buffer is four bytes deep; no need to time it perfectly.
self.write(0xDECAFBAD.to_bytes(4, "little"))

def rgb_led(self, colors: List, output: str = "RGB", order: str = "GRB"):
"""Set shade of a WS2812B RGB LED.
Expand Down

0 comments on commit d2b08ec

Please sign in to comment.