cat display fertig.
This commit is contained in:
24
local_code/app.py
Normal file
24
local_code/app.py
Normal file
@ -0,0 +1,24 @@
|
||||
from RPi import GPIO
|
||||
import time
|
||||
|
||||
# Set up GPIO pin (example using BCM pin 14)
|
||||
GPIO_PIN = 26
|
||||
|
||||
def setup():
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setup(GPIO_PIN, GPIO.IN)
|
||||
|
||||
def loop():
|
||||
Messwert = GPIO.input(GPIO_PIN) # Read analog value from the pin
|
||||
Spannung = ((Messwert * 250) / 1023) / 10 # Map and scale to desired range (0-2.5V)
|
||||
print(f"Spannung: {Spannung:.2f} V") # Print with two decimal places
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup()
|
||||
try:
|
||||
while True:
|
||||
loop()
|
||||
except KeyboardInterrupt:
|
||||
GPIO.cleanup() # Clean up when Ctrl+C is pressed
|
38
local_code/display.py
Normal file
38
local_code/display.py
Normal file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2017-2020 Richard Hull and contributors
|
||||
# See LICENSE.rst for details.
|
||||
# PYTHON_ARGCOMPLETE_OK
|
||||
|
||||
"""
|
||||
Displays an animated gif.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
from demo_opts import get_device
|
||||
from PIL import Image, ImageSequence
|
||||
from luma.core.sprite_system import framerate_regulator
|
||||
|
||||
|
||||
def main():
|
||||
regulator = framerate_regulator(fps=60)
|
||||
img_path = str(Path(__file__).resolve().parent.joinpath('images', 'cat.gif'))
|
||||
banana = Image.open(img_path)
|
||||
size = [min(*device.size)] * 2
|
||||
posn = ((device.width - size[0]) // 2, device.height - size[1])
|
||||
|
||||
while True:
|
||||
for frame in ImageSequence.Iterator(banana):
|
||||
with regulator:
|
||||
background = Image.new("RGB", device.size, "white")
|
||||
background.paste(frame.resize(size, resample=Image.LANCZOS), posn)
|
||||
device.display(background.convert(device.mode))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
device = get_device()
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
BIN
local_code/images/cat.gif
Normal file
BIN
local_code/images/cat.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 788 KiB |
Reference in New Issue
Block a user