Skip to content

Instantly share code, notes, and snippets.

View eparadis's full-sized avatar
💭
getting things done

Ed Paradis eparadis

💭
getting things done
View GitHub Profile
@eparadis
eparadis / lcd.py
Created November 11, 2022 15:08
micropython to write to a Hitachi-compatible character LCD via an attached MCP23008 IO Expander (Adafruit I2C/SPI LCD Backpack)
import mcp
import time
m = mcp.MCP23008(0x21, 0, 2)
m.output(7, True) # turn on backlight
def pulse_enable():
enable = 2
m.output(enable, False)
time.sleep_us(1)
m.output(enable, True)
@eparadis
eparadis / display_climate.py
Created November 11, 2022 15:04
micropython to update the LCD w/ climate data from the climate monitor
from lcd import initialize, puts, clear, set_pos
initialize()
puts('Ready...')
def get_climate_json():
import socket
url = 'http://192.168.0.111/data.json'
_, _, host, path = url.split('/', 3)
addr = socket.getaddrinfo(host, 80)[0][-1]
@eparadis
eparadis / set_mute_led.py
Last active January 25, 2022 02:05
quick hack to set the LED on my prototype desktop mute button
import subprocess
def send(cmd):
subprocess.run(['bash', '-c', "echo %s > /dev/cu.usbmodem142303" % cmd ])
process = subprocess.run(['osascript', 'getZoomStatus.applescript'], stdout=subprocess.PIPE)
status = process.stdout.decode().split(',')
print(status)
state = {y[0]: y[1] for y in [x.split(':') for x in status]}
@eparadis
eparadis / getZoomStatus.applescript
Created January 19, 2022 00:24
Applescript to determine the state of a Zoom meeting `smitmartijn/stream-deck-zoom-plugin`
# https://github.com/smitmartijn/streamdeck-zoom-plugin/blob/33892febdc188b2124b2a32c55b84ba3d2b5c949/Sources/MacOS.cpp#L66
# run with `osascript`
set zoomStatus to "closed"
set muteStatus to "disabled"
set videoStatus to "disabled"
set shareStatus to "disabled"
set recordStatus to "disabled"
tell application "System Events"
if exists (window 1 of process "zoom.us") then
@eparadis
eparadis / headphone_clip.scad
Created January 14, 2022 06:11
a place to rest my headphones that clips onto my cheap microphone boom arm
// headphone mount that clips on my mic arm
//difference() {
//square(20, center=true);
//square(10, center=true);
//}
@eparadis
eparadis / desktop_buttons.scad
Created January 13, 2022 22:03
desktop enclosure for five LAZ16-11 push buttons
module front_panel() {
translate([0,0,0])
cube([25*5, 30, 3]);
}
module button_hole() {
cylinder(80, d=12, center=true);
rear_clearance_depth = 10;
@eparadis
eparadis / mandel.fth
Last active February 5, 2022 03:14
classic terminal mandelbrot in FORTH
\ from proposal http://www.forth200x.org/fvalue.html
variable %var
: to 1 %var ! ;
: fvalue create f, does> %var @ if f! else f@ then 0 %var ! ;
0e0 fvalue i3
0e0 fvalue r3
59 value x1
21 value y1
@eparadis
eparadis / boot.py
Created January 6, 2022 22:05
ESP8266 MicroPython to work with a common-anode TM1638
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
import gc
import webrepl
webrepl.start()
gc.collect()
@eparadis
eparadis / gol_eurorack.py
Created January 5, 2022 02:36
my Game of Life eurorack module. CircuitPython on an Adafruit QT Py
import random
import time
import board
import simpleio
from adafruit_ht16k33.matrix import Matrix8x8
import pwmio
import analogio
i2c = board.I2C()
matrix = Matrix8x8(i2c, auto_write=False)
@eparadis
eparadis / state_machine.c
Created December 12, 2021 08:26
another frustrating dead end in C where I need fancier language features
struct state {
int some_info;
void (*next)(struct state *s);
};
void end(struct state *s) {
// do some clean up
s->some_info = 0;
s->next = halt;
}
void bar(struct state *s) {