Skip to content

Instantly share code, notes, and snippets.

@kevinmehall
kevinmehall / device.js
Last active August 17, 2016 09:32
Using Tessel CLI as a Node library for USB message passing
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/
process.on('message', function(msg) {
console.log('reply');
process.send(msg);
});
process.ref();
@kevinmehall
kevinmehall / test_extctxt.rs
Last active November 2, 2019 18:59
Rust: Creating a ExtCtxt for quasiquote outside of a syntax extension
#![feature(quote)]
extern crate syntax;
use syntax::print::pprust;
use syntax::codemap::DUMMY_SP;
fn main() {
with_fake_extctxt(|cx| {
let x = quote_expr!(cx, (a+b));
@kevinmehall
kevinmehall / README.md
Created April 25, 2014 16:29
USB Power Monitoring with CEE

Connect CEE chA to the 5V output pin of the USB breakout. GND, D+ and D- are passed through by the breakout by default.

pinout

Use ConnectClientPython and the following script:

@kevinmehall
kevinmehall / instructions.md
Created October 20, 2012 23:42
Compiling the Atmel-patched AVR toolchain
@kevinmehall
kevinmehall / async_replace.coffee
Created September 14, 2012 22:27
Async find/replace in CoffeeScript
# Replace parts of `string` matching regex `pattern` with the callback value of an
# async function `fn`, which receives the regex match object and callback. Calls `cb` with
# final string when complete.
asyncReplace = (string, pattern, fn, cb)->
console.assert(pattern.global, "asyncReplace pattern must be global (g flag)")
outChunks = []
lastIndex = 0
pendingCb = 0
@kevinmehall
kevinmehall / packetbuf.c
Created May 11, 2012 22:11
FIFO ring buffer for USB packets on xmega
// Bufferred BULK streaming
// http://nonolithlabs.com
// (C) 2011 Kevin Mehall (Nonolith Labs) <[email protected]>
//
// Licensed under the terms of the GNU GPLv3+
#include "packetbuffer.h"
// CEE to PC buffer
Ringbuf in_ring;
@kevinmehall
kevinmehall / gist:1338529
Created November 4, 2011 02:30
Quadrature Encoder with the Xmega event system
#include "usb.h"
// PORT C
#define QDEC1 (1<<2)
#define QDEC2 (1<<3)
int main(void){
sei();
@kevinmehall
kevinmehall / gist:1335347
Created November 2, 2011 23:57
PWM on Xmega
#include "usb.h"
// PORT C
#define PWM1 (1<<0)
#define PWM2 (1<<1)
int main(void){
sei();
@kevinmehall
kevinmehall / gist:1224653
Created September 18, 2011 02:47
AlJazeera English Live with rtmpdump and mplayer (17 September 2011)
rtmpdump -v -r rtmp://livestfslivefs.fplive.net/aljazeeraflashlive-live -y "aljazeera_eng_high?videoId=883816736001&lineUpId=&pubId=6650033.03001&playerId=751182905001&affiliateId=" -W "http://admin.brightcove.com/viewer/us20110916.1045/BrightcoveBootloader.swf" -p "http://english.aljazeera.net/watch_now/" -a "aljazeeraflashlive-live?videoId=883816736001&lineUpId=&pubId=6650033.03001&playerId=751182905001&affiliateId=" | mplayer -
@kevinmehall
kevinmehall / gist:1223343
Created September 16, 2011 22:45
Buttons / LEDs
void setup(){
pinMode(6,INPUT); // Button
digitalWrite(6, HIGH); // Enable pull-up on pin 6
pinMode(8,OUTPUT); // LED
}
int counter = 0;
int state = 0;
void loop(){
int button = digitalRead(6);