Initial backup of LTP-305G matrix clock setup on matrixpi

Captures everything needed to redeploy the two-display clock (hour on I2C
0x61, minute on I2C 0x63) on a fresh Pi:

- Both systemd units (matrix0x61.service, matrix0x63.service)
- Deployed Pimoroni script tree, including the local %I (12-hour) clock
  customization
- Vendored upstream sources (ltp305-python, breakout-garden) so restore is
  fully offline-capable
- Boot config snippet enabling I2C
- install.sh that wires it all back up idempotently
- Inventory doc cross-referencing every live-system path

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
dissimulo
2026-05-06 01:32:39 -07:00
commit 030172f523
99 changed files with 4445 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
# Heartbeat example
This example, the Pulse-O-Matic 6000, is a heartbeat plotter and BPM display.
## Important!
**This code should not be used for medical diagnosis, as the basis for a real smoke
or fire detector, or in life-critical situations. It's for fun/novelty use only,
so bear that in mind while using it.**
## Pre-requisites
This example requires:
- A Pimoroni [Breakout Garden HAT](https://shop.pimoroni.com/products/breakout-garden-hat-i2c-spi)
- A Pimoroni [MAX30105 Breakout - Heart Rate, Oximeter, Smoke Sensor](https://shop.pimoroni.com/products/max30105-breakout-heart-rate-oximeter-smoke-sensor)
- A Pimoroni [1.12" OLED Breakout (SPI)](https://shop.pimoroni.com/products/1-12-oled-breakout)
## Installation
Pop the breakouts into your Breakout Garden, and then run the `install.sh`
script in the root of this repository with `sudo ./install.sh` to automagically
install the libraries to run the I2C breakouts.
For this example you'll need to make sure some additional software is installed:
```
sudo apt install python3-pil
```
You'll need to clone and install the library for the 1.12" OLED Breakout (SPI)
as follows:
```
git clone https://github.com/pimoroni/sh1106-python
sudo ./install.sh
```
This example assumes that you have the OLED plugged into the front slot on the
Breakout Garden HAT, which should also work with the Breakout Garden Mini HAT.
To change it to the back slot, change `device=1` to `device=0` on the line
where the OLED is set up.
## Running this example
To run this example, type `./heartbeat.py` in the terminal.
It's best to hold the sensor against your fingertip (the fleshy side)
using a piece of wire or a rubber band looped through the mounting
holes on the breakout, as the sensor is very sensitive to small
movements and it's hard to hold your finger against the sensor with
even pressure.
If you're using your MAX30105 Breakout with Breakout Garden, then
we'd recommend using one of our
[Breakout Garden Extender Kits](https://shop.pimoroni.com/products/breakout-garden-extender-kit)
with some [female to female jumper jerky](https://shop.pimoroni.com/products/jumper-jerky?variant=348491271).

View File

@@ -0,0 +1,46 @@
Digitized data copyright (c) 2010 Google Corporation
with Reserved Font Arimo, Tinos and Cousine.
Copyright (c) 2012 Red Hat, Inc.
with Reserved Font Name Liberation.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@@ -0,0 +1,133 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# NOTE! This code should not be used for medical diagnosis. It's
# for fun/novelty use only, so bear that in mind while using it.
import sys
import time
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
from threading import Thread
from luma.core.interface.serial import spi
from luma.oled.device import sh1106
from max30105 import MAX30105, HeartRate
print("""
NOTE! This code should not be used for medical diagnosis. It's
for fun/novelty use only, so bear that in mind while using it.
This Pimoroni Breakout Garden example requires a
MAX30105 Breakout and a 1.12" OLED Breakout (SPI).
The Pulse-O-Matic 6000 is a heartbeat plotter and BPM display.
Press Ctrl+C a couple times to exit.
""")
# Set up OLED
oled = sh1106(spi(port=0, device=1, gpio_DC=9), rotate=2, height=128, width=128)
# Load fonts
lsb_18 = ImageFont.truetype("fonts/LiberationSans-Bold.ttf", 18)
lsr_12 = ImageFont.truetype("fonts/LiberationSans-Regular.ttf", 12)
# Set up MAX30105 Breakout
max30105 = MAX30105()
max30105.setup(leds_enable=2)
max30105.set_led_pulse_amplitude(1, 0.2)
max30105.set_led_pulse_amplitude(2, 12.5)
max30105.set_led_pulse_amplitude(3, 0)
max30105.set_slot_mode(1, 'red')
max30105.set_slot_mode(2, 'ir')
max30105.set_slot_mode(3, 'off')
max30105.set_slot_mode(4, 'off')
hr = HeartRate(max30105)
data = []
running = True
bpm = 0
bpm_avg = 0
beat_detected = False
beat_status = False
def sample():
"""Function to thread heartbeat values separately to
OLED drawing"""
global bpm, bpm_avg, beat_detected, beat_status
average_over = 5
bpm_vals = [0 for x in range(average_over)]
last_beat = time.time()
while running:
t = time.time()
samples = max30105.get_samples()
if samples is not None:
for i in range(0, len(samples), 2):
ir = samples[i + 1]
beat_detected = hr.check_for_beat(ir)
if beat_detected:
beat_status = True
delta = t - last_beat
last_beat = t
bpm = 60 / delta
bpm_vals = bpm_vals[1:] + [bpm]
bpm_avg = sum(bpm_vals) / average_over
d = hr.low_pass_fir(ir & 0xff)
data.append(d)
if len(data) > 128:
data.pop(0)
time.sleep(0.05)
# The thread to measure acclerometer values
t = Thread(target=sample)
t.start()
# The main loop that draws values to the OLED
while True:
try:
img = Image.open("images/heartbeat.png").convert(oled.mode)
draw = ImageDraw.Draw(img)
# Draw the heartbeat trace
vals = data
new_vals = [x / float((max(vals) - min(vals))) * 32 for x in vals]
for i in range(1, len(new_vals)):
draw.line([(i - 1, 80 - new_vals[i - 1]), (i, 80 - new_vals[i])],
fill="white")
# Draw the Pulse-O-Matic "branding"
draw.rectangle([(0, 0), (128, 20)], fill="black")
if bpm_avg > 40:
draw.text((0, 1), "BPM: {:.2f}".format(bpm_avg), fill="white",
font=lsb_18)
else:
draw.text((0, 1), "BPM: --.--", fill="white", font=lsb_18)
if beat_status:
draw.text((115, 1), u"\u2665", fill="white", font=lsb_18)
beat_status = False
draw.line([(0, 20), (128, 20)], fill="white")
draw.rectangle([(0, 108), (128, 128)], fill="black")
draw.text((0, 110), "Pulse-O-Matic 6000", fill="white", font=lsr_12)
draw.line([(0, 108), (128, 108)], fill="white")
# Display on the OLED
oled.display(img)
except ZeroDivisionError:
pass
except KeyboardInterrupt:
running = False
sys.exit(0)

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB