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)
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";
View Makefile
DEVICE = atmega328p
CLOCK = 16000000
PROGRAMMER = -c arduino -P /dev/ttyUSB0 -b57600
SOURCES = $(shell find . -name '*.c')
# Automatic dependency resolution
View SConscript
import os
# Device definition for the stm8s.h header
# This enables available features of the device library.
# Programmer argument for stm8flash (stlink or stlinkv2)
STM8_PROGRAMMER = "stlinkv2"
# Target device argument for stm8flash

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.


Single DS18B20 device on bus

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


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)


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.


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.

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')
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
View Makefile
DEVICE = attiny13a
CLOCK = 1200000
PROGRAMMER = -c dragon_isp
SOURCES = $(shell find . -name '*.c' -or -name '*.cpp' -or -name '*.S')
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