You need:
Step by step:
Program:
The printable parts are simple, if you want to use a different camera, light or display, you only need to modify two parts.
My program (night1.py)
import os
import sys
import time
import logging
import spidev as SPI
sys.path.append("/path_to_lib(use absolute path)/")
from lib import LCD_1inch28
from PIL import Image
from picamera2 import Picamera2
# Raspberry Pi pin configuration:
RST = 27
DC = 25
BL = 18
logging.basicConfig(level=logging.DEBUG)
try:
# Inicializace displeje
disp = LCD_1inch28.LCD_1inch28()
disp.Init()
disp.clear()
disp.bl_DutyCycle(50)
# Inicializace kamery
camera = Picamera2()
camera.configure(camera.create_preview_configuration({"size": (240, 240)}))
camera.start()
while True:
# Zachytávání obrazu
frame = camera.capture_array()
image = Image.fromarray(frame)
# Otočení obrazu pro správné zobrazení na displeji
im_r = image.rotate(90)
# Zobrazení obrazu na displeji
disp.ShowImage(im_r)
time.sleep(0.03) # Krátká pauza pro obnovu obrazu
except IOError as e:
logging.error(e)
except KeyboardInterrupt:
camera.stop()
disp.module_exit()
logging.info("quit:")
exit()
The author marked this model as their own original creation.