Skip to content

Instantly share code, notes, and snippets.

@theterg
theterg / code.py
Created March 17, 2021 23:10
Open Hardware Summit Badge 2020 - Enhanced Hello World Example
import board
import busio
import microcontroller as m
import time
from analogio import AnalogIn
from digitalio import DigitalInOut, Direction, Pull
import adafruit_imageload
import adafruit_bme680
import adafruit_lsm9ds1
@theterg
theterg / Code.gs
Created February 3, 2021 18:04
Autofilling Google Slides from Google Sheets
function myFunction() {
var sheeturl = "https://docs.google.com/spreadsheets/d/11_gwfesnphiI6uy4HmnCNpzL-pX1572SPKDiiiROnKs/edit";
var ss = SpreadsheetApp.openByUrl(sheeturl);
var deck = SlidesApp.getActivePresentation();
var sheet = ss.getSheetByName("test");
var values = sheet.getRange('A2:B18').getValues();
var slides = deck.getSlides();
var template = slides[0];
values.forEach(function(page) {
@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
@theterg
theterg / RL78_serial_remote.py
Last active December 29, 2018 12:29
Reverse-engineered pyusb code to read from a renesas RL78G13 promotion board. It uses some random MCU as a debug/programmer tool and a USB->serial device. Windows drivers only. All of the ctrl_transfers were sniffed using wireshark inbetween a windows VM.
import usb.core
import usb.util
import sys
from commands import getstatusoutput
import json
# find our device
dev = usb.core.find(idVendor=0x045b, idProduct=0x0212)
# was it found?
if dev is None:
@theterg
theterg / init.vim
Created January 2, 2018 22:31
My new nvim init script (rememner, vim-plug needs to be installed first, then the rest with :PlugInstall)
syntax on
call plug#begin('~/.local/share/nvim/plugged')
" Think of sensible.vim as one step above 'nocompatible' mode: a
" universal set of defaults that (hopefully) everyone can agree on.
Plug 'tpope/vim-sensible'
" Far.vim makes it easier to find and replace text through multiple files.
" It's inspired by fancy IDEs, like IntelliJ and Eclipse, that provide cozy
" tools for such tasks.
Plug 'brooth/far.vim'
@theterg
theterg / WickedLightRope.ino
Last active January 31, 2016 02:05
Wicked motor shield -> light rope
#include <Wicked_DCMotor.h>
int num_motors = 5;
Wicked_DCMotor motor1(M1);
Wicked_DCMotor motor2(M2);
Wicked_DCMotor motor3(M3);
Wicked_DCMotor motor4(M4);
Wicked_DCMotor motor5(M5);
Wicked_DCMotor *m[] = {&motor1, &motor2, &motor3, &motor4, &motor5};
@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 / 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 / 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 / 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()