Skip to content

Instantly share code, notes, and snippets.

View stecman's full-sized avatar

Stephen Holdaway stecman

View GitHub Profile
@stecman
stecman / avr_eprom_dump_over_serial.c
Last active July 19, 2018 08:35
Dump EPROM over serial with AVR
/**
* 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 March 24, 2018 10:56
Hacked together serial-controlled pin power pulser (AVR)
#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 February 27, 2018 04:04
Fuzzy find (fzf) to show file from history in Git
# 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 June 5, 2019 04:25
AVR basics
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 September 29, 2023 09:57
STM8 WS2812 hacked together demo
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 / Makefile
Last active April 2, 2024 11:26
DS18B20 1-Wire implementation for Atmel AVR
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 / README.md
Last active January 2, 2023 18:33
SCons build script for STM8 / STM8S with SDCC

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)

@stecman
stecman / _readme.md
Last active April 25, 2024 00:10
Brother P-Touch PT-P300BT bluetooth driver python

Controlling the Brother P-Touch Cube label maker from a computer

The Brother PTP300BT label maker is intended to be controlled using the official Brother P-Touch Design & Print iOS/Android app. The app has arbitrary limits on what you can print (1 text object and up to 3 preset icons), so I thought it would be a fun challenge to reverse engineer the protocol to print whatever I wanted.

Python code at the bottom if you want to skip the fine details.

Process

Intitially I had a quick peek at the Android APK to see if there was any useful information inside. The code that handles the communication with the printer in Print&Design turned out to be a native library, but the app clearly prepares a bitmap image and passes it to this native library for printing. Bitmaps are definitely something we can work with.

@stecman
stecman / Makefile
Created July 16, 2017 19:20
Watch PS/2 keyboard signals to add extra keyboard noise with relays (AVR / Arduino)
# This makefile is set up to work with the Arduino bootloader
# Depending on your device, you may need to adjust the PROGRAMMER
# line to point to the right serial port.
#
# To use, just run "make flash" with an arduino connected
DEVICE = atmega328p
CLOCK = 8000000
PROGRAMMER = -c arduino -P /dev/ttyUSB0 -b57600
SOURCES = $(shell find -name '*.c' -or -name '*.cpp' -or -name '*.S')
@stecman
stecman / GDEPaper.h
Last active August 4, 2022 01:41
Good Display epaper/eink screen testing code - image data from computer over USART
#pragma once
// AVR
extern "C" {
#include <avr/io.h>
}
#define GD_PSR 0x00 // Panel settings
#define GD_PWR 0x01 // Power setting
#define GD_BTST 0x06 // Booster soft start