Skip to content

Instantly share code, notes, and snippets.

View joefutrelle's full-sized avatar

Joe Futrelle joefutrelle

  • Falmouth, MA
View GitHub Profile
@joefutrelle
joefutrelle / attiny85_synth.c
Last active March 13, 2025 19:57
Direct digital synthesis (Karplus-Strong plucked string algorithm) on the Atmel ATtiny85 AVR microcontroller using the MCP4725 12-bit DAC over I2C using USI-based TWI as described in Application Note AVR310
/**
* Author: Joe Futrelle
* License: CC0 - Free as in freedom
*/
/**
* ATtiny85 direct digital synthesis
* using MCP4725 12-bit I2C DAC
* TWI is handled using Atmel's USI TWI implementation
* which is provided as part of Application Note AVR310
* http://www.atmel.com/Images/Atmel-2561-Using-the-USI-Module-as-a-I2C-Master_AP-Note_AVR310.pdf
@joefutrelle
joefutrelle / attiny_wdt_blink.c
Created October 9, 2014 13:27
ATtiny85 blinker using watchdog timer interrupt
@joefutrelle
joefutrelle / attiny_alpha4.c
Last active June 11, 2021 16:24
attiny85 driving an Adafruit HT16K33 4-digit alphanumeric LED display
/* Name: main.c
* Author: Joe Futrelle
* License: CC0 - Free as in freedom
*/
/* Adafruit 4-digit alphanumeric backpack, I2C
* Via USI_TWI_master from application note AVR310
* http://www.atmel.com/Images/Atmel-2561-Using-the-USI-Module-as-a-I2C-Master_AP-Note_AVR310.pdf
*/
/* Datasheet for HT16K33
* http://www.adafruit.com/datasheets/ht16K33v110.pdf
@joefutrelle
joefutrelle / IFCB scatter.ipynb
Created October 23, 2014 17:16
IFCB scatterplot
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@joefutrelle
joefutrelle / product_reorg.xml
Created October 23, 2014 18:49
IFCB product reorg
<namespace name="ifcb.utils">
<rule name="reorg_products" include="src dest">
<invoke rule="ifcb.files.find_data_dirs"/>
<!-- directory=product root dir, product=product type -->
<any>
<test var="product" eq="blobs">
<path var="src" match="${directory}/[0-9]*/[0-9]*/*_blobs_v2.zip"/>
<match var="src" pattern=".*/((.*_blobs).*)" groups="product_filename pid"/>
<invoke rule="ifcb.pid"/>
</test>
import os
import re
import time
from urllib2 import urlopen
import json
FEED_URL='http://ifcb-data.whoi.edu/mvco/feed.json'
DATA_DIR='/data'
FORMATS=('hdr','adc','roi')
@joefutrelle
joefutrelle / read_eeprom.ino
Created November 7, 2014 15:42
read tinycube eeprom
#include <Wire.h>
#define EEP_ADDR 0x50
void dump();
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
@joefutrelle
joefutrelle / remus_interp_alt.py
Created December 21, 2014 19:21
Interpolate altitudes in REMUS exported bathy data
#!/env/python
import sys
import os
import numpy as np
import pandas as pd
from pandas.io.parsers import read_csv
BASE_PATH='/media/F_DRIVE/FSM 2014'
@joefutrelle
joefutrelle / extract_desc.py
Created December 22, 2014 18:11
Extract description from #TIFF files using python-tifffile
#!/env/python
import os
from glob import glob
from tifffile import TiffFile
BASE_DIR='{whatever}'
for tfpath in sorted(glob(os.path.join(BASE_DIR,'*.tif'))):
tf = TiffFile(tfpath)
tfn = os.path.basename(tfpath)
@joefutrelle
joefutrelle / count_bright.py
Created December 26, 2014 14:41
Quick 'n dirty method for counting bright objects on a dark background (or vice versa by inverting the image)
from skimage.feature import peak_local_max
from skimage.filter import threshold_otsu
import scipy.ndimage as ndi
def count_bright(Y):
t = threshold_otsu(Y)
D = ndi.distance_transform_edt(Y > t)
Pl = peak_local_max(D,indices=False)
_, count = ndi.label(Pl)
return count