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
@todbot
todbot / bitmapfilter_play3_code.py
Created April 3, 2024 15:00
bitmapfilter playing w/ channel ops and blur on random lines in CircuitPython
# 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
@todbot
todbot / bitmapfilter_play2_code.py
Last active April 2, 2024 00:01
spirograph fun w/ bitmapfilter in CircuitPython
# 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
@todbot
todbot / wifi_clock_code.py
Last active April 1, 2024 23:17
Make an internet clock with CircuitPython using WorldTimeAPI.org
# 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"
@todbot
todbot / lilygo_tdisplay_s3_handsetup.py
Created March 28, 2024 20:18
LilyGo T-Display S3 display hand-setup in CircuitPython
"""
LilyGo T-Display S3 display hand-setup. Not normally required if using https://circuitpython.org/board/lilygo_tdisplay_s3/
"""
import time
import board
import digitalio
import displayio
import paralleldisplaybus
import adafruit_st7789
@todbot
todbot / audiomixer_demo_i2s.py
Last active March 22, 2024 17:53
Using AudioMixer and I2S in CircuitPython to fade up and down loops
# audiomixer_demo_i2s.py -- show how to fade up and down playing loops
# Code based on that of https://github.com/todbot/circuitpython-tricks/blob/main/larger-tricks/audiomixer_demo.py
# where you can also find the WAV files used
# 30 Nov 2022 - @todbot / Tod Kurt
import time
import board
import audiocore
import audiomixer
import audiobusio
@todbot
todbot / code_color_palette_finder.py
Last active March 10, 2024 20:50
Color summarizer / color palette finder for CircuitPython
# code.py example for color_palette_finder.py
# 9 Mar 2024 - @todbot / Tod Kurt
# Needs 'color_palette_finder.py' library
# video demo: https://youtu.be/dSR6IVxeaTg
import time
import board
import displayio
import vectorio
import gc
@todbot
todbot / average_jpeg_color_code.py
Last active March 10, 2024 00:05
Compute average color of a JPEG image in CircuitPython
# Compute the average (median or mean) color of a JPEG using ulab.numpy
# 9 Mar 2024 - @todbot / Tod Kurt
# Note: test images are included as comment below, max tested resolution 256x192
import ulab.numpy as np
import displayio
import jpegio
def rgb565_to_rgb888(v, swapped=True):
"""Convert RGB565 (normal or swapped) to RGB888 tuple"""
if swapped:
@todbot
todbot / MPSelectMiniV2-PrusaSlicer_config_bundle.ini
Created April 2, 2020 04:10
My attempt at a PrusaSlicer config bundle for Monoprice Select Mini V2. Import with "File" -> "Import..." -> "Import Config Bundle"
# generated by PrusaSlicer 2.2.0+ on 2020-04-02 at 04:02:32 UTC
[print:0.175mm - Monoprice Mini Select v2]
avoid_crossing_perimeters = 0
bottom_fill_pattern = rectilinear
bottom_solid_layers = 3
bottom_solid_min_thickness = 0
bridge_acceleration = 0
bridge_angle = 0
bridge_flow_ratio = 1
@todbot
todbot / WiFiWebClient_todbot.ino
Created February 26, 2024 18:43
Arduino WiFiWebClient, verified to work on PicoW with arduino-pico core
// from:
// https://docs.arduino.cc/retired/library-examples/wifi-library/WiFiWebClient/
#include <WiFi.h>
// Enter your WiFi SSID and password
char ssid[] = "todbot"; // your network SSID (name)
char pass[] = "testtesttest"; // your network password (use for WPA, or use as key for WEP)
char server[] = "wifitest.adafruit.com"; // host name address for adafruit test
@todbot
todbot / synthio_midi_synth.py
Last active February 20, 2024 18:01
pretty usable MIDI-controlled synth using synthio in CircuitPython
# synthio_midi_synth.py - pretty usable MIDI-controlled synth using synthio in CircuitPython
# 11 May 2023 - @todbot / Tod Kurt
# Uses cheapie PCM5102 DAC on QTPY RP2040
# Video demo: https://www.youtube.com/watch?v=N-PbbWWDE6k
# Features:
# - midi velocity controls attack rate (gentle press = slow, hard press = fast)
# - notes have small random detune on all oscillators to reduce phase stacking
# - adjustable number of detuned oscillators per note 1-5 (midi controller 83)
# - five selectable waveforms: saw, squ, sin, noisy sin, noise (midi controller 82)
# - vibrato depth on mod wheel (midi controller 1)