Skip to content

Instantly share code, notes, and snippets.

@stonehippo
stonehippo / README.md
Last active December 3, 2025 00:33
RTC setup in CircuitPython

Setting up an Adafruit hardware realtime clock module and rtc in Circuitpython

The rtc module in CircuitPython is a standardized interface for realtime clock (RTC) devices. While it is possible to use an RTC directly from the instance of an RTC hardware driver, wrapping it with rtc has a couple of advantages:

  • time.time() and time.localtime() are backed by rtc, all clock source will be synchronized
  • rtc correctly handled the tm_yday (yearday) parameter, which may not be done by the hardware driver libary

Of course, you may not care about either of these, in which case rtc might be overkill and leaving it out can save you a little RAM.

RTC hardware from Adafruit

@stonehippo
stonehippo / timing_helpers.py
Last active November 30, 2025 03:59
Simple non-blocking timing in CircuitPython
'''
This is an implementation of some simple, non-blocking timers for CircuitPython.
The 'timer' is just a time value and some methods to return state based on
whatever intervals seem appropriated. It's based on adafruit_ticks and will overflow
in the same way as the underlying methods (https://docs.circuitpython.org/projects/ticks/en/latest/index.html)
Where possible, you should probably consider using asyncio. This implementation
is lightweight, but it may not produce precise results or consistent timing.
This is a re-write of some code that I originally wrote to make non-blocking
@stonehippo
stonehippo / mock_sensor.py
Last active November 30, 2025 00:28
Mock sensor data for CircuitPython
'''
This is a little helper for creating mock data values for a simple sensor
in CircuitPython (analogous to reading from an ADC).
It's not meant to be particulary accurate, just to create ranges of data
that might be useful when developing.
'''
from random import randint
MAX_1_BIT = 2 ** 1
@stonehippo
stonehippo / README.md
Last active November 22, 2025 17:58
Solo play oracles from the STORYTELLERS RPG, implemented in Python.

Storytellers RPG Solo Play Oracles

This is a Python implementation of the solo play oracles from the STORYTELLERS RPG by Candlenaut. See the solo play info, pp. 59-60, for details.

Basic Oracle

The basic oracle answers yes/no questions. The oracle rolls two d6 dice, the first designated the Yes die, and the second the No die. If the Yes die is higher than the No die, the oracle has answered "yes". It's lower, the oracle has answered "no". A tie indicates that the oracle is uncertain. The difference between Yes and No how true the response is

@stonehippo
stonehippo / terminal_zsh_extra.md
Created October 25, 2025 14:25
Adding some more flare to my prompt

Things I've done to pretty up my terminal

  • installed bat
  • added $ZSH_CUSTOM/cat-alias.zsh cat="/PATH/TO/bat"
  • set omz theme to bureau
@stonehippo
stonehippo / rust_cross_compiling_on_rpi.md
Last active December 3, 2025 20:53
Notes on cross-compiling Rust on Raspberry Pi

Some Rust cross-compiling resources for Raspberry Pi

As I work on setting up a Pi Zero W as a portable system for some lightweight dev, I'm running into the challenge of compiling certain binaries on-system. To say that the Pi Zero W's resources are limited is an understatement; it can take days to compile something that might take minutes on a more robust system.

What I wanted was to cross-compile Microsoft Edit. I got it working by installing rust on my Raspberry Pi 400 with the 64-bit OS, then adding the appropriate target:

rustup target add arm-unknown-linux-gnueabihf
@stonehippo
stonehippo / settings.toml
Last active June 6, 2025 03:26
A little robotic surprise for the quarterly, written in CircuitPython
CIRCUITPY_BLE_NAME="WhatsInTheBox?"
@stonehippo
stonehippo / static_site_generators.md
Created June 2, 2025 17:57
Some static site generators that I am considering for a project or two

Static Site Generators

I have a couple of projects that I am working on that I think will be ideal for a static site generator (SSG). As I evaluate my options, I'll capture some notes here.

There's a whole list of SSGs on the Jamstack site.

Standslone SSGs

@stonehippo
stonehippo / circuitpython_blinka_guides.md
Created March 1, 2025 15:36
Collecting various guides about CircuitPython Blinka for future reference

CircuitPython Blinka Guides

Blinka is a compatibility layer for CircuitPython that provides the CircuitPython APIs for other flavors of Python, including CPython and MicroPython.

There are several Blinka compatible boards out there. Plus, with the right hardware—such as an FT232H or MCP2221 breakout, or even a Raspberry Pi Pico or another RP2040 dev board—Blinka works with PCs running Linux, MacOS, or Windows.

Blinka Documentation & Source

Blinka is maintained on Github: