Skip to content

Instantly share code, notes, and snippets.

@catskull
catskull / flash.sh
Created November 27, 2020 17:25
Flash an AVR/Arduino from a backup
#!/bin/bash
while [ true ] ; do
avrdude -V -p m32u4 -c usbtiny -U flash:w:backup_flash.bin
# avrdude -p m32u4 -c usbtiny -U eeprom:w:backup_eeprom.bin
avrdude -p m32u4 -c usbtiny -U hfuse:w:backup_hfuse.bin
avrdude -p m32u4 -c usbtiny -U lfuse:w:backup_lfuse.bin
avrdude -p m32u4 -c usbtiny -U efuse:w:backup_efuse.bin
say "flashing complete"
echo "Press any key to continue"
while [ true ] ; do
@catskull
catskull / dump.sh
Created November 27, 2020 17:24
Completely dump an AVR/Arduino including eeprom and fuses
#!/bin/bash
echo "Dumping..."
avrdude -p m32u4 -c usbtiny -U flash:r:backup_flash.bin:r
avrdude -p m32u4 -c usbtiny -U eeprom:r:backup_eeprom.bin:r
avrdude -p m32u4 -c usbtiny -U hfuse:r:backup_hfuse.bin:r
avrdude -p m32u4 -c usbtiny -U lfuse:r:backup_lfuse.bin:r
avrdude -p m32u4 -c usbtiny -U efuse:r:backup_efuse.bin:r
echo "Dump complete."
# mostly taken from this stack overflow post: https://stackoverflow.com/a/39212997
class Array
def difference(other)
h = other.each_with_object(Hash.new(0)) { |e,h| h[e] += 1 }
reject { |e| h[e] > 0 && h[e] -= 1 }
end
end
def scrabble(letters)
f = File.open('/usr/share/dict/words')
SEGA MEGA DRIVE PORT 2 PIN 1 <--- ARDUINO ANALOG PIN 0 = teensy 0
SEGA MEGA DRIVE PORT 2 PIN 2 <--- ARDUINO ANALOG PIN 1 = teensy 1
SEGA MEGA DRIVE PORT 2 PIN 3 <--- ARDUINO ANALOG PIN 2 = teensy 2
SEGA MEGA DRIVE PORT 2 PIN 4 <--- ARDUINO ANALOG PIN 3 = teensy 3
SEGA MEGA DRIVE PORT 2 PIN 5 ---> ARDUINO 5V = teensy NA
SEGA MEGA DRIVE PORT 2 PIN 6 <--- ARDUINO DIGITAL PIN 4 = teensy 6 = nb
SEGA MEGA DRIVE PORT 2 PIN 7 <--- ARDUINO DIGITAL PIN 2 = teensy 5 = wr
SEGA MEGA DRIVE PORT 2 PIN 8 <--> ARDUINO 0V = teensy ground
SEGA MEGA DRIVE PORT 2 PIN 9 <--- ARDUINO DIGITAL PIN 3 = teensy 4 = ad
avrdude -p atmega328p -c usbtiny -U lock:w:0x2f:m -U hfuse:w:0xda:m -U lfuse:w:0xFf:m -U efuse:w:0x07:m
{
"atomKeymap.promptV3Features": true,
"editor.multiCursorModifier": "ctrlCmd",
"editor.formatOnPaste": true,
"window.zoomLevel": 2,
"editor.fontSize": 14,
"editor.fontLigatures": true,
"editor.fontFamily": "Fira Code, Menlo, Monaco, 'Courier New', monospace",
"editor.minimap.enabled": false,
"editor.tabSize": 2,
@catskull
catskull / init.lua
Last active August 3, 2021 19:02
Hammerspoon config
-- https://github.com/catskull/MusicMenuDisplay.spoon
hs.loadSpoon("MusicMenuDisplay")
-- https://github.com/catskull/CPUTempMenuDisplay.spoon
hs.loadSpoon("CPUTempMenuDisplay")
hs.window.animationDuration = 0
local workMonitor = "LG Ultra HD"
-- Super specific window layout for my 43" 4k display
#include <avr/pgmspace.h>
const unsigned char usa [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60,
0x60, 0xE0, 0xE0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xE0, 0xE0, 0x60, 0x60, 0x60,
0x60, 0x60, 0x60, 0xE0, 0xE0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80,
0x80, 0xE0, 0xE0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0xE0, 0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00,
0x00, 0xF8, 0xF8, 0xF8, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xE0, 0xF8, 0xF8, 0x18, 0x18, 0x18,
@catskull
catskull / Brewfile
Created November 7, 2018 03:56
Brewfile
tap "armmbed/formulae"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/core"
tap "osx-cross/avr"
tap "somaticlabs/gnu-arm-toolchain"
brew "bash-completion"
brew "git"
brew "libusb"
brew "python"
#include <Ultrasonic.h>
Ultrasonic ultrasonic(5, 4);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly: