Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preliminary support for dropping to bootloader #220

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 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,17 @@ 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()
self.interface.baudrate = 460800
# 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(CP.Integer.pack(0xDECAFBAD))

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