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:
43
vendor/ltp305-python/examples/bargraph.py
vendored
Normal file
43
vendor/ltp305-python/examples/bargraph.py
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import time
|
||||
import math
|
||||
import random
|
||||
from ltp305 import LTP305
|
||||
|
||||
|
||||
print("""bargraph.py - A basic graph example
|
||||
|
||||
Displays an animated rising/falling bar on the left matrix,
|
||||
and a scrolling bar graph on the right.
|
||||
|
||||
Press Ctrl+C to exit!
|
||||
|
||||
""")
|
||||
|
||||
display = LTP305()
|
||||
width, height = display.get_shape()
|
||||
|
||||
values = [0, 0, 0, 0, 0]
|
||||
|
||||
|
||||
while True:
|
||||
# Add a new random value to our list and prune the list to visible values
|
||||
values.insert(0, random.randint(0, height))
|
||||
values = values[:width]
|
||||
|
||||
# Animate a value from 0 to height + 1
|
||||
value = (math.sin(time.time() * math.pi) + 1) / 2.0
|
||||
value *= height + 1
|
||||
value = math.floor(value)
|
||||
|
||||
for y in range(height):
|
||||
y = height - 1 - y
|
||||
|
||||
for x in range(width // 2):
|
||||
# Left
|
||||
display.set_pixel(x, y, value <= y)
|
||||
|
||||
# Right
|
||||
display.set_pixel(x + (width // 2), y, values[x] <= y)
|
||||
|
||||
time.sleep(1.0 / height)
|
||||
display.show()
|
||||
50
vendor/ltp305-python/examples/clock.py
vendored
Normal file
50
vendor/ltp305-python/examples/clock.py
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import sys
|
||||
import time
|
||||
from ltp305 import LTP305
|
||||
|
||||
|
||||
print("""clock.py - clock segment example.
|
||||
|
||||
Usage: python3 clock.py <hour/minute/second> <i2c-address>
|
||||
|
||||
This simple clock example will display the hour, minute or second on a single matrix display breakout.
|
||||
|
||||
Press Ctrl+C to exit.
|
||||
|
||||
""")
|
||||
|
||||
fmt = "%M"
|
||||
address = 0x61
|
||||
available = {
|
||||
"hour": "%H",
|
||||
"minute": "%M",
|
||||
"second": "%S"
|
||||
}
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
try:
|
||||
fmt = available[sys.argv[1]]
|
||||
except KeyError:
|
||||
raise ValueError("{} is not supported!".format(sys.argv[1]))
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
address = int(sys.argv[2], 16)
|
||||
if address not in [0x61, 0x62, 0x63]:
|
||||
raise ValueError("Invalid i2c address: 0x{:02x}. Run `i2c-detect -y 1` to discover breakouts.".format(address))
|
||||
|
||||
|
||||
try:
|
||||
display = LTP305(address=address)
|
||||
display.clear()
|
||||
display.show()
|
||||
except OSError:
|
||||
raise OSError("Unable to find LTP305 on i2c address: 0x{:02x}. Run `i2c-detect -y 1` to discover breakouts".format(address))
|
||||
|
||||
|
||||
while True:
|
||||
minute = time.strftime(fmt)
|
||||
left, right = minute
|
||||
display.set_character(0, left)
|
||||
display.set_character(5, right)
|
||||
display.show()
|
||||
time.sleep(1.0 / 60)
|
||||
49
vendor/ltp305-python/examples/eyes.py
vendored
Normal file
49
vendor/ltp305-python/examples/eyes.py
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import math
|
||||
import time
|
||||
import random
|
||||
|
||||
|
||||
print("""eyes.py - They're watching you!
|
||||
|
||||
Press Ctrl+C to exit!
|
||||
|
||||
""")
|
||||
|
||||
|
||||
from ltp305 import LTP305
|
||||
|
||||
display = LTP305()
|
||||
|
||||
|
||||
def eye(x, y):
|
||||
display.set_pixel(x, y, True)
|
||||
display.set_pixel(x, y + 1, True)
|
||||
display.set_pixel(x + 1, y, True)
|
||||
display.set_pixel(x + 1, y + 1, True)
|
||||
|
||||
|
||||
while True:
|
||||
t = time.time() * math.pi
|
||||
|
||||
# Get eye x and y positions in the range 0.0 to 1.0
|
||||
# You can plug in your own 0.0 to 1.0 values here
|
||||
x = (math.sin(t / 2) + 1) / 2
|
||||
y = (math.sin(t / 4) + 1) / 2
|
||||
|
||||
# Multiply them up to display coords and convert to itn
|
||||
x = math.floor(x * 4)
|
||||
y = math.floor(y * 6)
|
||||
|
||||
# Clear the display
|
||||
display.clear()
|
||||
|
||||
# Blink occasionally
|
||||
if not random.randint(0, 20) == 2:
|
||||
# Draw the eyes if not blinking
|
||||
eye(x, y)
|
||||
eye(x + 5, y)
|
||||
|
||||
# Update the display at 10FPS
|
||||
# This gives our crude blink code time to not look like a random flicker
|
||||
display.show()
|
||||
time.sleep(1.0 / 10)
|
||||
Reference in New Issue
Block a user