Files
drunkendotfiles/vendor/ltp305-python/examples/eyes.py
dissimulo 030172f523 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>
2026-05-06 01:32:39 -07:00

50 lines
1009 B
Python

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)