Skip to content

Instantly share code, notes, and snippets.

View adamgreig's full-sized avatar

Adam Greig adamgreig

View GitHub Profile
#!/usr/bin/env python
# Modules from the Python standard library.
import datetime, math, sys, os, logging, calendar, optparse, json, subprocess
# We use Pydap from http://pydap.org/.
import pydap.exceptions, pydap.client, pydap.lib
# Output logger format
log = logging.getLogger('main')
// MODIFIED BY JON SOWMAN
// DELAYMICROSECONDS() DOES NOT DISABLE
// INTERRUPTS ANY MORE, SO DO IT
// MANUALLY
#include <WString.h>
#include <ctype.h>
#include <string.h>
#include <util/crc16.h>
/*
* NewSerialServo
* --------------
* Servo control from the Serial port
*
* ####
* Modified by Adam Greig, Jun 2010, to just move the servo
* to one position or the other on '.' or ',' input.
* ####
*
import cherrypy
from pygooglechart import GoogleOMeterChart
import urllib, urllib2
def getdata():
page = urllib2.urlopen("http://robertharrison.org/listen/view.php?reg=/APEX/")
lastdata = []
lines = page.read().split("\n")
for line in lines:
data = "".join(line.split(" : ")[1:]).split(",")
import serial
import urllib2
import time
ser = serial.Serial("/dev/ttyUSB0", 4800)
lasttime = time.time()
while 1:
line = ser.readline()
if time.time() - lasttime < 10.0:
continue
@adamgreig
adamgreig / fldigi_autotuner.py
Created November 12, 2010 17:22
connect to fldigi via xml-rpc, get the current dial and log frequency, use it to retune the radio to keep the audio frequency at a set point
"""
fldigi autotuner script
Released into the public domain by Adam Greig in 2010
"""
import xmlrpclib
import math
import time
# Desired audio frequency (Hz)
@adamgreig
adamgreig / hist.py
Created April 30, 2011 00:43
python histogram generator
# Output a colour histogram PNG from a supplied image
import sys
import matplotlib
from matplotlib.backends.backend_agg import FigureCanvasAgg
from matplotlib.figure import Figure
import numpy
import Image
if len(sys.argv) != 3:
print "usage:", sys.argv[0], "<image filename>", "<output filename>"
@adamgreig
adamgreig / firefly.c
Created May 1, 2011 00:10
ATtiny code to sense touch and flash an LED a few times
// Firefly
// An ATtiny13 connected to a bit of metal to detect touch
// and an LED which it can PWM.
//
// Sleep most of the time, wake up occasionally, if we're being touched
// then light up a bit.
//
// Adam Greig, July 2010
#include <avr/io.h>
/*
* A basic ChibiOS app.
* Copyright Adam Greig 2011.
* Released under the GNU GPL v3. Insert GPL boilerplate here.
*/
#include "ch.h"
#include "hal.h"
#include "test.h"
@adamgreig
adamgreig / __init__.py
Created July 24, 2011 17:00
exaile plugin to allow play/pause over http for remote control
# support for stop, prev, next by Paul Martrenchar
from xl import event
from xl import player
import threading
import socket
socket_thread = None