This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # demonstrate blocking of usb.core.Device.read() | |
| # 4 May 2024 - @todbot and @jedgarpark | |
| """ | |
| This sketch demonstrates how `device.read()` blocks infinitely, which is different from established behavior. | |
| The normal semantics of `device.read()` when using either `busio.UART` or `usb_midi.PortIn` | |
| is that the read() does not noticably block if a `timeout` is given. | |
| (Explicitly in the constructor of `busio.UART` and apparently implicitly in just how `usb_midi` works) | |
| But for the `usb.core.Device` that is returned (as demo'd below), the `device.read()` blocks forever. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: Copyright (c) 2023 Scott Shawcroft for Adafruit Industries | |
| # SPDX-FileCopyrightText: Copyright (c) 2024 Tod Kurt | |
| # | |
| # SPDX-License-Identifier: Unlicense | |
| # | |
| # Forward MIDI from device on USB Host port to computer via USB MIDI | |
| # and 5-pin serial MIDI via MIDI Feather Wing or similar MIDI output. | |
| # Suppots hot-plug of the device on the USB Host port. | |
| # | |
| # adapted from https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_MIDI/blob/main/examples/usb_host_midi_simpletest.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # quick-n-dirty MIDI controller with Circuit Playground Express | |
| # 30 Apr 2024 - @todbot / Tod Kurt | |
| # Works on Circuit Playground Express in CircuitPython 9, | |
| # but will also work on also any board with touchio, like Trinket M0 or QTPy M0 | |
| # Uses the minimal number of libraries to save RAM on the tiny M0 in the CPX | |
| # (e.g. cannot load `adafruit_circuitpython`, `adafruit_midi`, and `adafruit_debouncer` on CPX) | |
| import board | |
| import touchio | |
| import usb_midi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // samd21 blink LED on PA10 on Trinket M0 | |
| // adapted / stolen from: | |
| // https://github.com/LifeWithDavid/RaspberryPiPico-BareMetalAdventures/blob/main/Chapter%2004/assembly.s | |
| .cpu cortex-m0 | |
| .syntax unified | |
| .thumb | |
| .global main // used in startup.s | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // originally from: https://github.com/dwelch67/atsamd_samples/tree/master/ATSAMD21/sparkfun/blinker01 | |
| #include <stdint.h> // for uint32_t | |
| int main(void) { | |
| unsigned int ra; | |
| unsigned int rx; | |
| uint32_t* PORT_A_DIR = (uint32_t*)0x41004400; // "PORT" from Table 12-1 & 23.7 of SAMD21 Datasheet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # bitmapfilter_play3_code.py -- chops + blur on random lines | |
| # 2 Apr 2024 - @todbot / Tod Kurt | |
| import time, math, random | |
| import board | |
| import rainbowio | |
| import vectorio | |
| import displayio | |
| import bitmaptools | |
| import bitmapfilter | |
| import gc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # bitmapfilter_play2_code.py -- spirograph fun w/ bitmapfilter | |
| # 1 Apr 2024 - @todbot / Tod Kurt | |
| import time, math, random | |
| import board | |
| import rainbowio | |
| import vectorio | |
| import displayio | |
| import bitmaptools | |
| import bitmapfilter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Make an internet clock with CircuitPython using WorldTimeAPI.org | |
| # 31 Mar 2024 - @todbot / Tod Kurt | |
| # Use resulting strings for displaying on a display of some kind | |
| import os, time | |
| import wifi | |
| import adafruit_requests | |
| import socketpool | |
| import ssl | |
| time_url = "http://worldtimeapi.org/api/ip" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # starting to play with bitmapfilter | |
| # 31 Mar 2024 - @todbot / Tod Kurt | |
| import time, math, random | |
| import board | |
| import vectorio | |
| import displayio | |
| import bitmaptools | |
| import bitmapfilter | |
| display = board.DISPLAY |