Skip to content

Instantly share code, notes, and snippets.

@johnty
johnty / AndroidTimer
Created November 13, 2014 17:20
android snippet for triggering periodic events
private Handler handler = new Handler();
//trigger next event.
handler.postDelayed(runnable, SAMPLE_INTERVAL_MS);
private Runnable runnable = new Runnable() {
//this class deals with generating periodic events,
// to emulate the incoming "midi messages" from device
// at a given rate
@johnty
johnty / mapper.c
Created November 15, 2014 05:25
max/pd bindings for libmapper with fixed _set_property calls
//
// mapper.c
// a maxmsp and puredata external encapsulating the functionality of libmapper
// http://www.idmil.org/software/libmapper
// Joseph Malloch, IDMIL 2010
//
// This software was written in the Input Devices and Music Interaction
// Laboratory at McGill University in Montreal, and is copyright those
// found in the AUTHORS file. It is licensed under the GNU Lesser Public
// General License version 2.1 or later. Please see COPYING for details.
@johnty
johnty / ttymidi-icubex.c
Last active May 4, 2021 17: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 / midiNameMatch
Last active August 29, 2015 14:12
midi port name search/connect
int portInIndex = -1;
int portOutIndex = -1;
// print input ports to console
midiIn.listPorts(); // via instance
//ofxMidiIn::listPorts(); // via static as well
if (midiIn.getNumPorts()) {
for (int i=0; i<midiIn.getNumPorts(); i++) {
string pname = midiIn.getPortName(i);
if (ofStringTimesInString(pname, "ICubeX")) {
gpio load spi
while true;
do
gpio -x mcp3004:200:0 aread 200; #reads first channel of ADC; aread 201 reads 2nd channel, etc.
done
@johnty
johnty / ESP8266-hue-sensor.ino
Created April 2, 2016 03:28
Arduino ESP8266 sketch for updating the status of a generic CLIP status sensor. hardcoded AP/password and Hue IP/API strings.
/**
Custom ESP8266 CLIP sensor for Philips Hue system
GPIO2's high/low state will emit two different status values
which can then be used to trigger Hue bridge events
You will need:
0.) Wifi network and Philips Hue bridge connected to it and set up, with an API key
1.) A custome IP sensor (CLIP) created in the Hue bridge
2.) A rule hooking up the status of the IP sensor and events we want
@johnty
johnty / memstats.sh
Created May 4, 2016 15:41
print out memory stats
while true; do
echo -n memfree: "`free -m | head -2 | tail -1 | awk '{print $4}'` ";
echo -ne swap used: "`cat /proc/swaps | tail -1 | awk '{print $4}'` \r";
sleep 1;
done
@johnty
johnty / sys_mon_lcd.py
Last active October 24, 2017 11:21
python system monitor on 1602 lcd
#!/usr/bin/python
#--------------------------------------
# ___ ___ _ ____
# / _ \/ _ \(_) __/__ __ __
# / , _/ ___/ /\ \/ _ \/ // /
# /_/|_/_/ /_/___/ .__/\_, /
# /_/ /___/
#
# lcd_i2c.py
# LCD test script using I2C backpack.
@johnty
johnty / sliders.json
Last active July 7, 2016 21:51
node-red flow for sliders example
[{"id":"8bc3934b.dec0c","type":"mcp3008","z":"bc7ea069.67a99","name":"","device":"/dev/spidev0.0","mode":"0x80","interval":"25","x":319,"y":156,"wires":[["941e2650.e518a8","178087e.871bf78"]]},{"id":"da077c2f.9bf43","type":"inject","z":"bc7ea069.67a99","name":"","topic":"","payload":"start","payloadType":"str","repeat":"","crontab":"","once":true,"x":93,"y":72,"wires":[["8916983b.311a48"]]},{"id":"d1ea8f0e.568af","type":"inject","z":"bc7ea069.67a99","name":"","topic":"","payload":"stop","payloadType":"str","repeat":"","crontab":"","once":false,"x":93.5,"y":37,"wires":[["8916983b.311a48"]]},{"id":"941e2650.e518a8","type":"debug","z":"bc7ea069.67a99","name":"","active":false,"console":"false","complete":"false","x":541,"y":156,"wires":[]},{"id":"178087e.871bf78","type":"ui_slider","z":"bc7ea069.67a99","tab":"e3257868.dcaa18","name":"Push","topic":"","group":"","order":1,"min":0,"max":"1023","x":527,"y":212,"wires":[["f2ec0099.fbb4c"]]},{"id":"b618b17a.ef5bb","type":"ui_gauge","z":"bc7ea069.67a99","tab":"e325786
@johnty
johnty / midi.json
Created July 7, 2016 21:50
simple node-red flow for displaying MIDI messages. requires node-red-contrib-ui and node-red-contrib-midi
[{"id":"c2c6477f.a696e8","type":"midi","z":"29801501.b12f9a","name":"MIDI In","filtermessage":"","port":"1","x":72,"y":42,"wires":[["a8489adb.12f6c8"]]},{"id":"a8489adb.12f6c8","type":"template","z":"29801501.b12f9a","name":"grab midi msg","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.message}}","x":139,"y":90,"wires":[["6a918548.45b34c"]]},{"id":"6a918548.45b34c","type":"csv","z":"29801501.b12f9a","name":"","sep":",","hdrin":"","hdrout":"","multi":"one","ret":"\\n","temp":"","x":217,"y":41,"wires":[["cc1b3fe4.be9cc","7a9da23f.8e6a2c","fbdad48.cbcff28"]]},{"id":"cc1b3fe4.be9cc","type":"template","z":"29801501.b12f9a","name":"col1","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.col1}}","x":319,"y":83,"wires":[["b7bcfdb6.33e0f"]]},{"id":"7a9da23f.8e6a2c","type":"template","z":"29801501.b12f9a","name":"col2","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.