Skip to content

Instantly share code, notes, and snippets.

Stephen Holdaway stecman

View GitHub Profile
@stecman
stecman / AutoCrop.lua
Last active Apr 9, 2019
Lightroom plugin to calculate image crops using OpenCV
View AutoCrop.lua
-- LR imports
local LrApplication = import("LrApplication")
local LrApplicationView = import("LrApplicationView")
local LrBinding = import("LrBinding")
local LrDevelopController = import("LrDevelopController")
local LrDialogs = import("LrDialogs")
local LrExportSession = import("LrExportSession")
local LrFileUtils = import("LrFileUtils")
local LrFunctionContext = import("LrFunctionContext")
local LrLogger = import("LrLogger")
@stecman
stecman / _NMEA GPS datetime for AVR.md
Last active Feb 16, 2019
NMEA GPRMC sentence parsing for low memory microcontrollers: read GPS date and time from UART
View _NMEA GPS datetime for AVR.md

Date/time from GPS without storing NMEA string

This is a first pass at reading the date and time from a serial GPS device on a tiny microcontroller. The target device is an ATTiny13A with only 64 bytes of RAM, which isn't enough to store the full 79 characters of a NMEA sentence, so something like minmea wouldn't work (their API passes around full sentence strings).

When compiled with avr-gcc -Os, this is around 500 bytes of program space. The size can be reduced by 100 bytes if the handling of checksums is removed.

@stecman
stecman / BaseModel.php
Created Oct 14, 2018
Phalcon PHP modifiable array assignment of relationships on new objects
View BaseModel.php
<?php
use Phalcon\Mvc\Model;
/**
* Configuration and behaviours for all models
*/
abstract class BaseModel extends Model
{
/**
@stecman
stecman / avr_eprom_dump_over_serial.c
Last active Jul 19, 2018
Dump EPROM over serial with AVR
View avr_eprom_dump_over_serial.c
/**
* Thrown together program to dump 512 kbit EPROMs from an AVR ATMega64A/128A
* More specifically, a bunch of ST M27C512 from the early 90's
*
* Connections:
*
* Port A 0-7: low address byte (output)
* Port B 0-7: high address byte (output)
* Port D 0-7: data (input)
*
@stecman
stecman / avr_serial_pin_pulse.c
Last active Mar 24, 2018
Hacked together serial-controlled pin power pulser (AVR)
View avr_serial_pin_pulse.c
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/wdt.h>
#include <stdlib.h>
#include <string.h>
void init_usart(void)
{
cli();
@stecman
stecman / .bash_profile
Created Feb 27, 2018
Fuzzy find (fzf) to show file from history in Git
View .bash_profile
# Show file from Git tree at a certain point in the history
function hist() {
local ref=$1
local query=$2
if [ -z $ref ]; then
echo "Please specify a ref";
return;
fi
@stecman
stecman / Makefile
Last active Jun 12, 2018
AVR basics
View Makefile
DEVICE = atmega328p
CLOCK = 16000000
PROGRAMMER = -c arduino -P /dev/ttyUSB0 -b57600
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
SOURCES = $(shell find . -name '*.c')
OBJECTS = $(SOURCES:.c=.o)
# Automatic dependency resolution
@stecman
stecman / SConscript
Last active Feb 25, 2018
STM8 WS2812 hacked together demo
View SConscript
import os
# Device definition for the stm8s.h header
# This enables available features of the device library.
STM8_DEVICE_DEFINE = "STM8S003"
# Programmer argument for stm8flash (stlink or stlinkv2)
STM8_PROGRAMMER = "stlinkv2"
# Target device argument for stm8flash
@stecman
stecman / _DS18B20-AVR-OneWire.md
Last active Feb 23, 2019
DS18B20 1-Wire implementation for Atmel AVR
View _DS18B20-AVR-OneWire.md

AVR C 1-Wire + DS18B20 temperature sensor

This implements Maxim's One Wire / 1-Wire protocol for AVR microcontrollers from the DS18B20 datasheet and Maxim's other application notes.

Usage

Single DS18B20 device on bus

With just one DS18B20 on the 1-Wire bus, you can ignore slave addresses:

@stecman
stecman / README.md
Last active Apr 6, 2018
SCons build script for STM8 / STM8S with SDCC
View README.md

SCons + SDCC for STM8S

Setting up SCons to build using SDCC was fairly time consuming for someone new to SCons, so here's a basic working config to get you started.

With some tweaking this should also work for other architectures that SDCC supports (z80, z180, mcs51, r2k, etc).

Required software

SCons (build tool)

You can’t perform that action at this time.