Skip to content

Instantly share code, notes, and snippets.

View todbot's full-sized avatar
💭
doing the blink1

Tod Kurt todbot

💭
doing the blink1
View GitHub Profile
// lightly modified to print out the top level directory as strings,
// like for use with a display
/*********************************************************************
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
MIT license, check LICENSE for more information
Copyright (c) 2019 Ha Thach for Adafruit Industries
@todbot
todbot / displayio_grapher.py
Last active February 5, 2024 19:54
Draw a funciton on the screen, like an oscilloscope, building on @jedgarpark Parsec on circle drawing
# builds on John Park's Parsec on drawing circle https://www.youtube.com/watch?v=nI55N6q0sUo
import math
import time
import random
# Set up the display
display = board.DISPLAY
# Create a blank displayio group
group = displayio.Group()
@todbot
todbot / spinny_radar_box_code.py
Last active February 1, 2024 21:57
spinning sorta radar based off of John Park's CircuitPython Parsec 1 Feb 2024
import board
import displayio
import math
import time
# Set up the display
display = board.DISPLAY
# Create a blank displayio group
tilegroup = displayio.Group()
@todbot
todbot / midi_solenoids.ino
Last active February 1, 2024 22:13
midi_solenoids for Arduino and TinyUSB
// Port of code at https://efundies.com/src/arduino/midi-solenoids.ino
// to use fortyseveneffects MIDI library and Adafuit_TinyUSB
// Be sure to set Tools -> USB Stack: Adafruit TinyUSB in Arduino IDE
#include <Adafruit_TinyUSB.h>
#include <MIDI.h>
// USB MIDI object
Adafruit_USBD_MIDI usb_midi;
// Create a new instance of the Arduino MIDI Library,
// and attach usb_midi as the transport.
@todbot
todbot / led_animations_audio.py
Created January 29, 2024 23:59
Neopixel LED animations + playing audio on Pico RP2040
# led animations + audio on RP2040 Pico
#
import os, time, random
import board, keypad
import audiomixer, audiocore
import audiopwmio
import neopixel
from adafruit_led_animation.animation.rainbow import Rainbow
from adafruit_led_animation.animation.rainbowchase import RainbowChase
from adafruit_led_animation.animation.rainbowcomet import RainbowComet
@todbot
todbot / sleepy_keys.py
Last active January 25, 2024 23:51
Sleep a Windows box with CircuitPython using USB HID
# SPDX-FileCopyrightText: Copyright (c) 2023 Tod Kurt
#
# SPDX-License-Identifier: MIT
"""
`sleepy_keys`
=============
HID System Control Powerdown / Sleep / Wake device helper library
* Author(s): Tod Kurt
@todbot
todbot / usb_host_midi_demo.py
Last active November 29, 2023 00:11
demo new USB MIDI Host capability in CircuiPython
# usb_host_midi_demo.py - demo new USB MIDI Host capability in CircuiPython
# 27 Nov 2023 - @todbot / Tod Kurt
# adapted from https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_MIDI/blob/main/examples/usb_host_midi_simpletest.py
# needs "circup install adafruit_midi adafruit_usb_host_descriptors"
# and hand-copy library from https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_MIDI
import time
import board
import usb.core
import adafruit_usb_host_midi
import adafruit_midi
@todbot
todbot / phase_accum_oscillator.py
Created November 14, 2023 18:35
phase accumulation oscillator experiment in circuitpython
# phase accumulation oscillator experiment
# 13 Nov 2023 - @todbot
# basically just copying
# https://github.com/wntrblm/Sol/blob/master/firmware/winterbloom_sol/lfo.py
#
import time
import math
from supervisor import ticks_ms
# "output" a waveform of a given length at a given frequency
import time
import math
# frequency in Hz of wave
frequency = 3
# length of the wave, number of samples in the wave
LENGTH = 13
# diagnose https://old.reddit.com/r/circuitpython/comments/17snve6/trouble_with_ssd1306_and_asyncio/
# 11 Nov 2023
import asyncio
import random # for creating synthetic data
import time
import board
import digitalio
import busio
import displayio
import adafruit_displayio_ssd1306