Skip to content

Instantly share code, notes, and snippets.

Stephen Holdaway stecman

Block or report user

Report or block stecman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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)

@stecman
stecman / _readme.md
Last active Aug 20, 2019
Brother P-Touch PT-P300BT bluetooth driver python
View _readme.md

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 Jul 16, 2017
Watch PS/2 keyboard signals to add extra keyboard noise with relays (AVR / Arduino)
View Makefile
# 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 May 24, 2017
Good Display epaper/eink screen testing code - image data from computer over USART
View GDEPaper.h
#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
@stecman
stecman / Makefile
Last active Dec 5, 2017
ATTiny13A Button Pusher - Remember how many times a button was pushed and push it electronically on startup
View Makefile
DEVICE = attiny13a
CLOCK = 1200000
PROGRAMMER = -c dragon_isp
SOURCES = $(shell find . -name '*.c' -or -name '*.cpp' -or -name '*.S')
OBJECTS = $(SOURCES:.c=.o)
AVRDUDE = avrdude $(PROGRAMMER) -p t13
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
COMPILE += -I -I. -I./lib/
COMPILE += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
@stecman
stecman / _readme.md
Last active Dec 26, 2017
List BTRFS subvolume and snapshot sizes like df
View _readme.md
View README.md

Requirements

Install https://pypi.python.org/pypi/libusb1

Allowing control without root privileges

# Create rule so the device can be controlled by any user
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="f055", ATTR{idProduct}=="05df", MODE="0666"' \
  | tee /etc/udev/rules.d/99-status-light.rules
@stecman
stecman / TimerModule.h
Created Aug 22, 2016
React Native get relative time
View TimerModule.h
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
@interface TimerModule : NSObject <RCTBridgeModule>
@end
@stecman
stecman / ir_remote.py
Last active Jul 6, 2016
Raspberry PI hardwired IR remote
View ir_remote.py
#!/usr/bin/env python3
# Experiment: Replacing the LED in an infrared remote with a wired connection
#
# Details of the hardware/software implementation:
#
# I've hard-wired the crappy IR remote that came with a DVB-T RTL-SDR
# dongle into a GPIO pin on the Raspberry Pi. The infrared LED in the
# remote has been removed and replaced with a wire going to GPIO 3.
#
You can’t perform that action at this time.