Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
doing the blink1

Tod Kurt todbot

💭
doing the blink1
View GitHub Profile
@todbot
todbot / cptr_funtimes.c
Last active March 20, 2023 17:45
Some fun with C pointers
View cptr_funtimes.c
// some fun with C pointers
// 20 Mar 2023
// compile with: gcc -o cptr_funtimes cptr_funtimes.c
#include <stdlib.h>
#include <stdio.h>
#define NUM_COLORS 5
uint32_t global_colors[NUM_COLORS] =
{
@todbot
todbot / touchpio.py
Created February 26, 2023 19:23
Capacitive Touch Sensing using Pico / RP2040 PIO using similar API to CircuitPython's "touchio"
View touchpio.py
# touchpio.py -- Capacitive Touch Sensing using Pico / RP2040 PIO using similar API to CircuitPython's "touchio"
# 24 Feb 2023 - @todbot / Tod Kurt
# # Uses ideas from "# PIO Capsense experiment / -scottiebabe 2022" from
# https://community.element14.com/products/raspberry-pi/f/forum/51242/want-to-create-a-capacitance-proximity-touch-sensor-with-a-rp2040-pico-board-using-pio/198662
#
import time, array
import board
import rp2pio
import adafruit_pioasm
from supervisor import ticks_ms
@todbot
todbot / simple_sse_server.js
Created February 21, 2023 02:37
Simple SSE (Server Sent Events) server in NodeJs
View simple_sse_server.js
// 20 Feb 2023 - @todbot / Tod Kurt, for carlynorama
//
// orig from: https://web.dev/eventsource-basics/
var http = require('http');
var fs = require('fs');
var http_port = 8000
console.log("starting server on port"+http_port)
@todbot
todbot / audio_plus_http_post.py
Last active February 16, 2023 23:41
Play audio while also POSTing to a URL on PicoW (or any CircuitPython device with native WiFi)
View audio_plus_http_post.py
# audio_plus_http_post.py -- Play audio while also POSTing to a URL on PicoW
# (or any CircuitPython device with native WiFi)
# 16 Feb 2023 - @todbot / Tod Kurt, from @studioStephe(she/they) post on Adafruit Discord
#
# Notes:
# - Glitches on first POST, but subsequent POSTs are glitch free.
# - Could get around this by muting mixer.voice[0].volume on first POST
# - Or could get around by doing throw-away POST before starting audio
# - The glitching appears to be related to DNS lookups?
#
@todbot
todbot / masto-media-up.swift
Created February 13, 2023 17:31
Hacky media upload to mastodon in Swift, does not post
View masto-media-up.swift
// Hacky media upload to mastodon, does not post
// A condensation of things I learned about Swift and Mastodon API w/ @carlynorama
// 12 Feb 2023 - @todbot / Tod Kurt
//
// Compile with:
// swiftc masto-media-up.swift -o masto-media-up
//
// Requires:
// - existing Mastodon account on a given server ("--url")
// - authorization token from a created app in Mastodon ("--auth")
@todbot
todbot / noise_square_code.py
Created February 9, 2023 20:36
Play with simplex noise in CircuitPython
View noise_square_code.py
# noise_square_code.py -- playing with simplex noise in CircuitPython
# 9 Feb 2023 - @todbot / Tod Kurt
# https://github.com/todbot/CircuitPython_Noise
# Uses Lolin ESP32-S2 Mini and 8x8 LED shield
# https://circuitpython.org/board/lolin_s2_mini/
#
import time
import board
import neopixel
import rainbowio
@todbot
todbot / vectorio_balls.py
Last active January 19, 2023 19:38
showing vectorio use
View vectorio_balls.py
# vectorio_balls.py -- show using vectorio.Circle
# 19 Jan 2023 - @todbot / Tod Kurt
import board, time, math, random
import displayio, vectorio, rainbowio
display = board.DISPLAY
disp_width,disp_height = display.width, display.height
screen = displayio.Group() # group that holds everything
display.show(screen) # add main group to display
@todbot
todbot / pwm_encoder_fade.py
Last active January 15, 2023 00:54
Demonstrate one way to do smooth LED/PWM fading if input is rotary encoder
View pwm_encoder_fade.py
#
# demonstrate one way to do smooth LED/PWM fading if input is rotary encoder
# by having a separate "fader" that runs independent of encoder setting
# (but that smoothly catches up to it)
# 14 Jan 2023 - @todbot / Tod Kurt
#
import time
import board
import rotaryio
@todbot
todbot / ds4_fakey_boot.py
Last active January 9, 2023 03:27
pretend to be a Playstation DS4 controller
View ds4_fakey_boot.py
# ds4_fakey_boot.py -- pretend to be a Playstation DS4 controller, using MacroPad RP2040
# doesn't quite seem to work yet
# 8 Jan 2023 - @todbot / Tod Kurt
import usb_hid
import usb_midi
import supervisor
ds4_vid = 0x054C
ds4_pid = 0x05C4
@todbot
todbot / blinkm_simple_demo.py
Last active January 4, 2023 23:52
BlinkMs working in CircuitPython
View blinkm_simple_demo.py
# blinkm_simple_demo.py -- very simply demonstrate low-level BlinkM control
# 4 Jan 2023 - @todbot / Tod Kurt
#
# Note: BlinkMs are designed to be 5V devices, they may not work on 3.3V systems.
# You should really use a I2C level shifter like: https://www.adafruit.com/product/5637
# If you're powering many BlinkMs or a BlinkM MaxM, you *definitely* need a level shifter,
# since you cannot risk sending 5V back to the 3.3V inputs of a CircuitPython board.
#
# Details of BlinkM protocol at http://thingm.com/s/BlinkM_datasheet.pdf
#