Skip to content

Instantly share code, notes, and snippets.

View gallaugher's full-sized avatar

Gallaugher gallaugher

View GitHub Profile
@gallaugher
gallaugher / cap-touch-dj.py
Created October 8, 2025 18:40
cap-touch-dj.py
# Uses adafruit_mpr121, an Adalogger Cowbell, PCM5102 DAC, & PAM8302 AMP
import board, busio, sdcardio, storage, os, time, digitalio, adafruit_mpr121
import audiomixer, audiocore, audiobusio # use this instead of audiopwmio
from audiocore import WaveFile
touch_pad = adafruit_mpr121.MPR121(board.STEMMA_I2C())
# Create an I2S audio output w/our pins
audio = audiobusio.I2SOut(
bit_clock=board.GP10,
@gallaugher
gallaugher / matrix-mapper.epe
Created September 25, 2025 22:41
Improved Matrix Mapper Code
// Improved Matrix Mapper Code
function (pixelCount) {
width = 16 // width of LED panel
angle = 90 // rotation in degrees: 0, 90, 180, 270
flip = true // does the rendering need to be flipped?
height = width/pixelCount
map = []
for (i = 0; i < pixelCount; i++) {
@gallaugher
gallaugher / pixelblaze_advance_one_pixel_at_a_time.js
Last active September 14, 2025 01:23
Pixelblaze, Advance One Pixel at a Time
var holdMs = 120 // milliseconds each LED stays on (lower = faster)
var currentPixel = 0 // index of the currently lit pixel
var accumulatedMs = 0 // accumulated elapsed time (in milliseconds)
// A beforeRender fuction runs before each frame or refresh of all LEDs
export function beforeRender(delta) { // delta = ms since last frame (refresh of all LEDs)
accumulatedMs += delta // add this frame's time to the accumulator
// If we've held long enough, advance to the next pixel.
// NOTE: This advances at most one pixel per frame.
@gallaugher
gallaugher / label_v_bitmap_label.py
Created August 1, 2025 16:58
label_v_bitmap_label.py
```# text-and-displayio.py
import board, busio, time, displayio, pwmio, terminalio, fourwire
from adafruit_display_text.label import Label
from adafruit_display_text.bitmap_label import Label as BitmapLabel
from adafruit_bitmap_font import bitmap_font
import adafruit_ili9341
# --- Display Setup ---
displayio.release_displays()
@gallaugher
gallaugher / roy-g-biv-pico-flash-with-each-color-off.py
Created July 16, 2025 01:41
roy-g-biv-pico-flash-with-each-color-off.py
# roy-g-biv-pico-flash-with-each-color-off.py
import board, time, neopixel
# define colors:
RED = (255, 0, 0)
ORANGE = (255, 40, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
INDIGO = (75, 0, 130) # no official INDIGO from CircuitPython
@gallaugher
gallaugher / playSound.swift
Last active June 26, 2025 14:09
playSound Function in SwiftUI
func playSound(soundName: String) {
guard let soundFile = NSDataAsset(name: soundName) else {
print("😡 ERROR: Could not read file named \(soundName).")
return
}
do {
audioPlayer = try AVAudioPlayer(data: soundFile.data)
audioPlayer.play()
} catch {
print("😡 ERROR: \(error.localizedDescription) when trying to create audioPlayer.")
@gallaugher
gallaugher / code.py
Created June 2, 2025 14:33
EYE SPI, ssd1681 eInk, and Pico
# EYESPI & ssd1681 connected to a Pico
import time, board, displayio, adafruit_ssd1681
from displayio import FourWire # ← FIXED: Changed from "fourwire import FourWire"
displayio.release_displays()
# This pinout works on a Feather M4 and may need to be altered for other boards.
spi = board.SPI() # Uses SCK and MOSI
epd_cs = board.GP17
epd_dc = board.GP21
@gallaugher
gallaugher / Test-128x128-stemma-qt-grayscale.py
Created May 21, 2025 17:56
Test-128x128-stemma-qt-grayscale.py
# Creates a pusing set of rings under text.
import time
import math
import board
import displayio
import busdisplay
import i2cdisplaybus
import terminalio
from adafruit_display_text import label
import adafruit_ssd1327
@gallaugher
gallaugher / display_and_sd_card.py
Last active May 16, 2025 15:51
display_and_sd_card.py
# If you comment out either the audio block or display block, code runs fine.
# But if you try to run both, as is shown below, the error is:
# File "code.py", line 57, in <module>
# ValueError: SPI peripheral in use
import board, busio, sdcardio, storage, os, time, digitalio
import displayio, pwmio, terminalio, adafruit_st7735r
from adafruit_display_text import label
from audiomp3 import MP3Decoder
# st7735r_display_160x128.py
import board
import displayio
import busio
import pwmio
import terminalio
from adafruit_display_text import label
import adafruit_st7735r
displayio.release_displays()