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:
49
vendor/breakout-garden/examples/seismograph/README.md
vendored
Normal file
49
vendor/breakout-garden/examples/seismograph/README.md
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
# Seismograph example
|
||||
|
||||
The Dino-Detect v1.2 beta is a dino stomp detector. It's a
|
||||
UNIX system, I know this.
|
||||
|
||||
## Pre-requisites
|
||||
|
||||
This example requires:
|
||||
|
||||
- A Pimoroni [Breakout Garden](https://shop.pimoroni.com/products/breakout-garden-hat-i2c-spi)
|
||||
- A Pimoroni [LSM303D 6DoF Sensor Breakout](https://shop.pimoroni.com/products/lsm303d-6dof-motion-sensor-breakout)
|
||||
- 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 `./seismograph.py` in the terminal.
|
||||
|
||||
Note that it takes a baseline reading initially to zero out the axes,
|
||||
and then calculates subsequent readings against the baseline, so make
|
||||
sure that your Breakout Garden is sitting still when you start the
|
||||
program.
|
||||
|
||||
The `sensitivity` variable can be changed to make the seismograph more or
|
||||
less sensitive to dino stomps.
|
||||
BIN
vendor/breakout-garden/examples/seismograph/fonts/Roboto-Black.ttf
vendored
Normal file
BIN
vendor/breakout-garden/examples/seismograph/fonts/Roboto-Black.ttf
vendored
Normal file
Binary file not shown.
BIN
vendor/breakout-garden/examples/seismograph/fonts/Roboto-Regular.ttf
vendored
Normal file
BIN
vendor/breakout-garden/examples/seismograph/fonts/Roboto-Regular.ttf
vendored
Normal file
Binary file not shown.
BIN
vendor/breakout-garden/examples/seismograph/images/seismograph.png
vendored
Normal file
BIN
vendor/breakout-garden/examples/seismograph/images/seismograph.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
122
vendor/breakout-garden/examples/seismograph/seismograph.py
vendored
Executable file
122
vendor/breakout-garden/examples/seismograph/seismograph.py
vendored
Executable file
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import time
|
||||
import sys
|
||||
|
||||
try:
|
||||
from PIL import Image
|
||||
from PIL import ImageFont
|
||||
from PIL import ImageDraw
|
||||
except ImportError:
|
||||
print("""This example requires PIL.
|
||||
Install with: sudo apt install python{v}-pil
|
||||
""".format(v="" if sys.version_info.major == 2 else sys.version_info.major))
|
||||
sys.exit(1)
|
||||
|
||||
from lsm303d import LSM303D
|
||||
from threading import Thread
|
||||
from luma.core.interface.serial import spi
|
||||
from luma.core.render import canvas
|
||||
from luma.oled.device import sh1106
|
||||
|
||||
print("""This Pimoroni Breakout Garden example requires an
|
||||
LSM303D 6DoF Breakout and a 1.12" OLED Breakout (SPI).
|
||||
|
||||
The Dino-Detect v1.2 beta is a dino stomp detector. It's a
|
||||
UNIX system, I know this.
|
||||
|
||||
Press Ctrl+C to exit.
|
||||
""")
|
||||
|
||||
# Set up OLED
|
||||
|
||||
oled = sh1106(spi(port=0, device=1, gpio_DC=9), rotate=2, height=128, width=128)
|
||||
|
||||
# Load fonts
|
||||
|
||||
rr_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'fonts', 'Roboto-Regular.ttf'))
|
||||
print(rr_path)
|
||||
rb_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'fonts', 'Roboto-Black.ttf'))
|
||||
rr_24 = ImageFont.truetype(rr_path, 24)
|
||||
rb_20 = ImageFont.truetype(rb_path, 20)
|
||||
rr_12 = ImageFont.truetype(rr_path, 12)
|
||||
|
||||
# Set up LSM303D motion sensor
|
||||
|
||||
lsm = LSM303D(0x1d)
|
||||
|
||||
samples = []
|
||||
points = []
|
||||
|
||||
sx, sy, sz = lsm.accelerometer() # Starting values to zero out accelerometer
|
||||
|
||||
sensitivity = 5 # Value from 1 to 10. Determines twitchiness of needle
|
||||
|
||||
# Function to thread accelerometer values separately to OLED drawing
|
||||
|
||||
def sample():
|
||||
while True:
|
||||
x, y, z = lsm.accelerometer()
|
||||
|
||||
x -= sx
|
||||
y -= sy
|
||||
z -= sz
|
||||
|
||||
v = y # Change this axis depending on orientation of breakout
|
||||
|
||||
# Scale up or down depending on sensitivity required
|
||||
|
||||
if v < 0:
|
||||
v *= (100 * sensitivity)
|
||||
else:
|
||||
v *= (40 * sensitivity)
|
||||
|
||||
|
||||
# Only keep 96 most recent values in list
|
||||
|
||||
points.append(v)
|
||||
if len(points) > 96:
|
||||
points.pop(0)
|
||||
|
||||
time.sleep(0.05)
|
||||
|
||||
# The thread to measure acclerometer values
|
||||
|
||||
t = Thread(target=sample)
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
# Wait for at least one data oint
|
||||
|
||||
while len(points) == 0:
|
||||
pass
|
||||
|
||||
# The main loop that draws values to the OLED
|
||||
|
||||
while True:
|
||||
background = Image.open("images/seismograph.png").convert(oled.mode)
|
||||
draw = ImageDraw.ImageDraw(background)
|
||||
|
||||
draw.line([(128, 64), (96, 64 + points[-1])], fill="white")
|
||||
draw.line([(128, 63), (96, 64 + points[-1])], fill="white")
|
||||
draw.line([(128, 65), (96, 64 + points[-1])], fill="white")
|
||||
|
||||
# Draw the seismograph trace
|
||||
|
||||
for i in range(1, len(points)):
|
||||
draw.line([(i - 1, 64 + points[i - 1]), (i, 64 + points[i])], fill="white")
|
||||
|
||||
# Draw the Dino-Detect "branding"
|
||||
|
||||
draw.rectangle([(0, 0), (128, 20)], fill="black")
|
||||
draw.text((0, 1), "AUS (A UNIX System)", fill="white", font=rr_12)
|
||||
draw.line([(0, 20), (128, 20)], fill="white")
|
||||
|
||||
draw.rectangle([(0, 108), (128, 128)], fill="black")
|
||||
draw.text((0, 110), "Dino-Detect v1.2 BETA", fill="white", font=rr_12)
|
||||
draw.line([(0, 108), (128, 108)], fill="white")
|
||||
|
||||
# Display on the OLED
|
||||
|
||||
oled.display(background)
|
||||
Reference in New Issue
Block a user