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
@gamblor21
gamblor21 / drums.py
Created May 31, 2023 23:53
Drums for Circuitpython synthio
import ulab.numpy as np
import random
import synthio
SAMPLE_SIZE = 200
sinwave1 = np.array(np.sin(np.linspace(0, 2*np.pi, SAMPLE_SIZE, endpoint=False)) * 32767, dtype=np.int16)
sinwave2 = np.array(np.sin(np.linspace(np.pi/2, 2.5*np.pi, SAMPLE_SIZE, endpoint=False)) * 32767, dtype=np.int16)
downwave = np.linspace(32767, -32767, num=3, dtype=np.int16)
noisewave = np.array([random.randint(-32767, 32767) for i in range(SAMPLE_SIZE)], dtype=np.int16)
@anecdata
anecdata / espnow_receiver.py
Last active November 4, 2024 20:49
CircuitPython example for Espressif ESP-NOW protocol
# SPDX-FileCopyrightText: 2023 anecdata
#
# SPDX-License-Identifier: MIT
import time
import traceback
import supervisor
import os
import rtc
import espnow
@joshka
joshka / Readme.md
Last active October 14, 2022 19:32
8/Any pin PIO based UART TX code for a Raspberry Pi Pico

Raspberry Pi Pico PIO 8 Pin UART TX

This code creates a UART TX on 8 sequential pins of the Raspberry Pi Pico. The main use case being MIDI splitter devices

The second 16 port implementation should work for any number of pins, but just acts as a pure copy to those pins instead of having individual control over every pin of every byte. Hence while less flexible, the controlling software is simpler (just send a uart byte and it's copied to every pin).

Only tested in the simulator so far. https://wokwi.com/projects/344345628967436882

Used https://wokwi.com/tools/pioasm to go from uart_tx.pio.h to uart_tx.h

@anecdata
anecdata / code.py
Last active March 30, 2023 18:39
Rough Monitor Dumper
import gc
import time
import board
import digitalio
import supervisor
import random
import wifi
import espidf
import ipaddress
@anecdata
anecdata / code.py
Last active July 27, 2024 01:50
TileGrid terminalio
import sys
import board
import displayio
import terminalio
display = board.DISPLAY # or equivalent external display library
splash = displayio.Group()
fontx, fonty = terminalio.FONT.get_bounding_box()
import time
import board
import rotaryio
import touchio
import digitalio
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.keycode import Keycode
from adafruit_hid.consumer_control import ConsumerControl
@todbot
todbot / trinkey_theremin_pitch_code.py
Last active November 8, 2024 16:20
Trinkey MIDI Theremin with Pitch! (will also work on any other CircuitPython devices with `touchio`)
# trinkey_theremin_pitch_code.py -- Trinkey MIDI Theremin! with pitch control!
# 2021 @todbot
# left antenna: pitch (by multiple MIDI notes, put your synth in legato mode)
# right antenna: filter cutoff
# video demo in comment below
#
import time
import board
import neopixel
import touchio
@dglaude
dglaude / qtpy-knob-midi.py
Created February 28, 2021 00:00
Gt-Py Knob midi control
# qtpy-knob-midi.py -- Mount a rotary encoder directly to an Adafruit QT Py,
# use it for midi CC message
#
# 2020 @todbot / Tod Kurt
# 2021 @David.Glaude / David Glaude
import time
import board
from digitalio import DigitalInOut, Direction, Pull
import rotaryio
@Neradoc
Neradoc / picopico_safe_mode_boot.py
Last active July 12, 2023 07:49
boot.py implementing waiting to start into safe mode on Raspberry pico
import board
import time
from digitalio import DigitalInOut,Pull
led = DigitalInOut(board.LED)
led.switch_to_output()
safe = DigitalInOut(board.GP14) # <----- choose your pin with a button on it
safe.switch_to_input(Pull.UP)
@todbot
todbot / wifi-preferred-network.py
Last active December 5, 2020 06:18
Given a list of preferred networks, connect to the one with the strongest signal, for CircuitPython ESP32S2
#
# wifi-preferred-network.py -- Given a list of preferred networks,
# connect to the one with the strongest signal
# for CircuitPython ESP32S2 Metro / MagTag
# 2020 @todbot / todbot.com/blog
import time
import wifi
from secrets import secrets