Skip to content

Instantly share code, notes, and snippets.

@theterg
theterg / Plottest.py
Created November 13, 2013 14:07
Matplotlib live plot animation without blitting
import pylab as plt
import numpy as np
import pandas as pd
import random
import time
start = time.time()
frames = pd.DataFrame([0], [0.0], ['data'])
plt.ion()
@theterg
theterg / metadata.json
Created November 15, 2013 23:09
Sample prototype metadata
{
"gitref": "refs/heads/add_sd",
"gitsha": "5b5fba031cee12ffc9fa97977692062310f86ea7",
"devid": "533231003153344c3330373038343038",
"board": 201,
"tick_rate_hz": 1000,
"data_format": "0.1",
"sample_ticks": {
"accelerometer": 10,
"gyroscope": 33,
@theterg
theterg / example.py
Created November 19, 2013 16:21
Example of reading in json configuration
import json
f = open('devinfo.json','r')
lines = f.readlines()
config = json.loads(lines[0])
print config['data_format']
print config['sensor_settings']['accelerometer']['scale']
@theterg
theterg / MioDecode.py
Created December 18, 2013 20:31
Found some data on a UART channel connecting the sensor board to the bluetooth/main MCU on a Mio Alpha watch. Wrote a quick script to assist in viewing the data on this bus.
'''
MioDecode.py
Reads data from the internal serial bus of a Mio Alpha and prints the BPM to screen.
Dependences:
-pyserial
Usage:
python.exe MioDecode.py --port='<serial port>' --baud=<baud rate>
@theterg
theterg / pwmtest.py
Created February 10, 2014 13:38
Raspberry pi wiringpi2 pwm test
import wiringpi2 as wiringpi
import sys
import argparse
import time
parser = argparse.ArgumentParser()
# parser.add_argument('--clock', type=int, default=32)
parser.add_argument('--period', type=int, default=200)
parser.add_argument('--pulsewidth', type=int, default=15)
args = parser.parse_args()
@theterg
theterg / scope_get_data.py
Created February 26, 2014 21:23
Continually retrieve a single datapoint from any VISA device such as an oscilloscope or benchtop multimeter.
import visa
import sys
import pandas as pd
import numpy as np
import datetime
import time
import argparse
parser = argparse.ArgumentParser(description='Continuously retrieve data from scope as quickly as possible')
parser.add_argument('command', type=str, help='The command to execute. EG: MEAS:PWIDTH? CHANNEL3')
@theterg
theterg / serial_port_logger.py
Created March 18, 2014 23:05
A simple python 3.0 script to log data from two different serial ports at one time
import serial
import sys
import time
import argparse
parser = argparse.ArgumentParser(description='Dump serial data from basis')
parser.add_argument('portA', type=str, help='Serial port A')
parser.add_argument('portB', type=str, help='Serial port B')
parser.add_argument('--baud', type=int, default=1000000, help='The baud rate of both devices')
parser.add_argument('--labelA', type=str, default='A')
@theterg
theterg / jsssdk.unminified.js
Created March 31, 2014 14:33
Nike Plus Javascript SDK unminified
/*! Nike+ Javascript SDK - v2.0.0 - Build 67 - 2014-03-24 */
var NIKEPLUS = NIKEPLUS || {};
! function (a) {
"use strict";
var b = {};
b.config = {};
var c;
/**
* @license
* Q - v1.0
@theterg
theterg / new_format_RR.csv
Last active August 29, 2015 13:58
IOS HRV Data Logger file format
timestamp relative_time rr_sincestart rr
1391491315566 0 800 800
1391491316569 1003 1612 812
1391491317557 1991 2424 812
1391491317557 1991 3220 796
1391491319202 3636 4012 792
1391491320550 4984 4788 776
1391491323544 7978 5540 752
1391491324546 8980 6264 724
1391491324546 8980 6960 696
@theterg
theterg / auto_measure.py
Created September 9, 2014 14:09
AFE4300 EVM automation tool
import sys
import time
import math
sys.path.append("./Scripts")
GUI_Module=__import__('Device_GUI')
def FWR_read(input_mask, frequency=32, delay=0.5):
set_frequency(frequency)
GUI.write_register("AFE4300", "IQ_MODE_ENABLE", 0x00) #Select FWR Mode
GUI.write_register("AFE4300", "ADC_CONTROL_REGISTER2", 0x63) #ADCREF to VREF / ADC connected to BCM