Skip to content

Instantly share code, notes, and snippets.

@greed9
greed9 / sketch_cpx_light_control.ino
Created August 12, 2022 00:36
Drive motion-sensitive upcycled toll signs as yard art.
//
// Logic for light timing and on/off
//
// CPX hardware stuff
#include <Adafruit_CircuitPlayground.h>
// States for ON/OFF activity switching based on light level
#define OFF 0
#define INIT 1
@greed9
greed9 / generate_pings.sh
Created August 28, 2022 23:45
Programs to map values for ping times into color values and meter setting
#!/bin/bash
# pings specified host once, greps out latency
# usage:
# generate_pings.sh <host> <ping_time_limit>
host=$1
ping_scale_limit=$2
ping_time=$(ping -c1 $host | grep from | cut -d '=' -f 4 | cut -d " " -f 1)
printf "%3.0f 0 %3.0F 0 255\n" $ping_time $ping_scale_limit
@greed9
greed9 / buses.json
Created September 5, 2022 00:35
Loads and displays info for Lynx buses, stops and routes
[{"id":17706426,"name":"301-420","lat":28.495283833333,"lon":-81.312924666667,"heading":null,"route":418,"lastStop":500257,"fields":{},"lastUpdate":1661958696},{"id":17706100,"name":"36-310","lat":28.506027,"lon":-81.329664333333,"heading":null,"route":419,"lastStop":500168,"fields":{"type":"mentor"},"lastUpdate":1661958811},{"id":17706123,"name":"8-309","lat":28.57875,"lon":-81.338404,"heading":null,"route":420,"lastStop":500404,"fields":{"type":"mentor"},"lastUpdate":1661958821},{"id":17706076,"name":"14-309","lat":28.573302166667,"lon":-81.4139925,"heading":null,"route":420,"lastStop":500395,"fields":{"type":"mentor"},"lastUpdate":1661958813},{"id":17706205,"name":"194-415","lat":28.527498666667,"lon":-81.310533166667,"heading":null,"route":421,"lastStop":500459,"fields":{"type":"clever"},"lastUpdate":1661958812},{"id":17706150,"name":"147-414","lat":28.516101166667,"lon":-81.376460166667,"heading":null,"route":422,"lastStop":500487,"fields":{"type":"mentor"},"lastUpdate":1661958814},{"id":17706508,"name":
@greed9
greed9 / wx.json
Created October 1, 2022 02:01
Hurricane Ian wx data
This file has been truncated, but you can view the full file.
{"time" : "2022-09-28 23:50:41", "model" : "Acurite-Tower", "id" : 2628, "channel" : "A", "battery_ok" : 1, "temperature_C" : 20.800, "humidity" : 85, "mic" : "CHECKSUM"}
{"time" : "2022-09-28 23:50:43", "model" : "LaCrosse-TX141Bv3", "id" : 103, "channel" : 1, "battery_ok" : 1, "temperature_C" : 28.200, "test" : "No"}
{"time" : "2022-09-28 23:50:47", "model" : "Oregon-WGR800", "id" : 136, "channel" : 0, "battery_ok" : 1, "wind_max_m_s" : 0.700, "wind_avg_m_s" : 0.900, "wind_dir_deg" : 0.000}
{"time" : "2022-09-28 23:50:58", "model" : "Acurite-Tower", "id" : 2628, "channel" : "A", "battery_ok" : 1, "temperature_C" : 20.700, "humidity" : 85, "mic" : "CHECKSUM"}
{"time" : "2022-09-28 23:51:01", "model" : "Oregon-WGR800", "id" : 136, "channel" : 0, "battery_ok" : 1, "wind_max_m_s" : 0.000, "wind_avg_m_s" : 0.900, "wind_dir_deg" : 0.000}
{"time" : "2022-09-28 23:51:02", "model" : "Acurite-606TX", "id" : 30, "battery_ok" : 1, "temperature_C" : 3.300, "mic" : "CHECKSUM"}
{"time" : "2022-09-28 23:55:37", "model" : "
@greed9
greed9 / sketch_fft4.pde
Created October 4, 2022 04:13
FFT-based spectrum display from audio input
// scrolling spectral display ala SpectrumLab
import processing.sound.*;
FFT fft;
AudioIn in;
final int bands = 512;
float[] spectrum = new float[bands];
int leftEdge = 70 ;
int sampleRate = 44100 ;
@greed9
greed9 / fix_fft_main.c
Created October 8, 2022 20:13
Main Integer FFT code from: https://gist.github.com/Tomwi/3842231 modified in main() to read from and write to stdout for piping
#include <stdio.h>
#include <stdlib.h>
#include "fix_fft.h"
#include <errno.h>
#include <string.h>
// based on: https://gist.github.com/Tomwi/3842231
FILE*fp;
@greed9
greed9 / ascii_fft_disp_curses.c
Created October 8, 2022 20:17
Display integer fft results from stdin as ascii chars using ncurses. Ugly but fast
#include <stdio.h>
#include <errno.h>
#include <string.h>
// based in part on: https://www.linuxjournal.com/content/getting-started-ncurses
#include <curses.h>
#include <stdlib.h>
#define FFT_SIZE (256)
#define ABS(x) ( (x )< 0 ? -(x) : (x))
@greed9
greed9 / example_wav.c
Created February 5, 2023 17:32
Example of reading (and possibly modifying) a 16 or 32 bit WAV file.
/**
* Copyright (c) 2015-2022, Martin Roth ([email protected])
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
@greed9
greed9 / tinywav.h
Created February 5, 2023 17:35
Header file with WAV struct types
/**
* Copyright (c) 2015-2022, Martin Roth ([email protected])
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
@greed9
greed9 / tinywav.c
Created February 5, 2023 17:37
Implementation of simple WAV file read/write
/**
* Copyright (c) 2015-2022, Martin Roth ([email protected])
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,