Skip to content

Instantly share code, notes, and snippets.

@johnty
johnty / ttymidi-icubex.c
Last active August 24, 2025 19:24
modified ttymidi for passing sysex info; very hacky and can be cleaned up lots!!
/*
This file is part of ttymidi.
ttymidi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ttymidi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@johnty
johnty / arp.py
Created May 30, 2017 16:16
simple OSC-controlled MIDI arpeggiator that takes in tempo, direction, and key. uses mido and pyOSC
#!/usr/bin/env python
"""
Send random notes to the output port.
"""
from __future__ import print_function
import sys
import time
import random
import mido
import threading
#include <WiFi.h>
#include <WiFiUdp.h>
WiFiUDP udp;
const char * ssid = "SSID";
const char * password = "PASS";
boolean connected = false;
void setup()
{
// w for Fwd
//
// A simple Teensy based USB keyboard that associats some kind of
// physical motion event to a 'w' press. This can be used to advance Google StreetView
// for an interactive exercise experience (Example here: https://www.instagram.com/p/CF-xVWgJiFK/)
//
// Must select the "SERIAL+KEYBOARD..." mode under "USB TYPE" for the Teensy!
//
// This version uses a Sharp IR sensor (or equivalent), connected to A9 pin of a Teensy 3.2
//
@johnty
johnty / quickstart.py
Last active July 30, 2021 07:02
scratchpad for sheets
from __future__ import print_function
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from datetime import datetime
from random import randint
from time import sleep
from sds011 import SDS011
@johnty
johnty / Dual_SDS011_test.py
Created July 26, 2021 20:01
simple code to poll two SDS011 sensors connected via CH340G USB adapters
from sds011 import SDS011
from datetime import datetime
import time
#CH340G adapters seem to give port names
#based on which port you plug them into:
s1 = SDS011("/dev/tty.wchusbserial1410") #Left USB Port
s2 = SDS011("/dev/tty.wchusbserial1420") #Right USB Port
def read_sensor():
@johnty
johnty / bellow.scad
Last active May 6, 2021 22:01
parametric bellow, designed to be printed in TPU for single dosing espresso grinders
//Parametric Bellow designed for blowing out grinds in an espresso grinder
// Designed to be printed using TPU
// Tested on Ender 3 Pro (2019) with stock extruder and 91A TPU from filaments.ca
// 15mm all speeds 2mm retraction @ 15mm/s. 75C bed 230/227C extruder temps
// 3 shell perimeter
//
// johntywang@gmail.com
// May 2021, Released under CC BY-SA 2.0 (http://creativecommons.org/licenses/by-sa/2.0/)
echo(version=version());
@johnty
johnty / UDP-recorder.maxpat
Created March 18, 2021 08:16
Records UDP (OSC) messages with millisecond timestamps
{
"boxes" : [ {
"box" : {
"maxclass" : "comment",
"text" : "Autosave and query of current file size",
"linecount" : 2,
"numoutlets" : 0,
"id" : "obj-38",
"patching_rect" : [ 568.0, 191.5, 150.0, 34.0 ],
"style" : "",
@johnty
johnty / get_temp.py
Last active January 8, 2021 08:14
grabbing temperature (in F) from wifi thermocouple probe
import urllib.request #talks to an ESP32 running this code: https://github.com/johnty/BBQProbe/tree/main/thermocouple_esp32
contents = urllib.request.urlopen("http://192.168.1.65").read().decode() #find IP address and put it here...
f_string = contents.split("/")[2] #first / is for </head>, second / is between the C and F readings ;)
f_vals = f_string.split(); # split again based on spaces, result should be the F value string only.
print(f_vals[0])
@johnty
johnty / midiPacket.ino
Last active October 15, 2020 22:38
CC MIDI packet with running status
uint8_t midiPacket[15] = {
0b10000000,  // header
0b10000000,  // timestamp, not implemented
0b00000000,  // status byte
21,
midi.mapMIDI(abs(imu.getAccelX()), 0, 50));// CC 021 (0b00010101) (for X-axis accelerometer)
22,
midi.mapMIDI(abs(imu.getAccelY()), 0, 50));// CC 022 (0b00010110) (for Y-axis accelerometer)
23,
midi.mapMIDI(abs(imu.getAccelZ()), 0, 50));// CC 023 (0b00010111) (for Z-axis accelerometer)