Subsistema de video
parent
af28113bf0
commit
2ae2b33d08
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Este script requiere permisos de root."
|
||||
exit
|
||||
fi
|
||||
|
||||
# set pwd to current directory
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
#limpia el contenido del directorio de trabajo
|
||||
rm -rf /srv/ledram/*
|
||||
rm -rf /srv/*
|
||||
|
||||
# Configura un directorio `/srv/ledram` como buffer de video
|
||||
sed -i -e '/srv/d' /etc/fstab
|
||||
sed -i -e '$a/tmpfs /srv/ledram tmpfs rw,nosuid,nodev,size=32m 0 0' /etc/fstab
|
||||
|
||||
# Crea directorio donde se almacena el buffer de video
|
||||
mkdir /srv/ledram
|
||||
|
||||
# Desocupa el tercer procesador para ser usado exclusivamente por el sub-proceso de renderizado
|
||||
sed -i -e 's/ isocpus=3//g' /boot/cmdline.txt
|
||||
sed -i -e 's/$/ isocpus=3/' /boot/cmdline.txt
|
||||
|
||||
#copia la biblioteca al directorio de trabajo
|
||||
cp -R rgbmatrix /srv/rgbmatrix
|
||||
|
||||
#copia el sub-sistema de renderizado
|
||||
mkdir /srv/subsystem
|
||||
cp -rf init.png /srv
|
||||
cp -rf led-driver.py /srv/subsystem
|
||||
|
||||
#Crea el servicio
|
||||
cp -rf led-driver.service /etc/systemd/system/led-driver.service
|
||||
|
||||
# Recarga e inicia automaticamente al prender.
|
||||
systemctl daemon-reload
|
||||
systemctl unmask led-driver.service
|
||||
systemctl enable led-driver.service
|
||||
|
||||
# Mensajes de salida
|
||||
echo "Debe reiniciar la Raspberry para que el servicio pueda iniciarse"
|
||||
echo "Luego para actualizar, solo debe modificar el el archivo '/srv/ledram/current.png' para actualizar la pantalla"
|
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env python
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from rgbmatrix import RGBMatrix, RGBMatrixOptions
|
||||
from PIL import Image
|
||||
|
||||
# Configuration for the matrix
|
||||
options = RGBMatrixOptions()
|
||||
options.rows = 40
|
||||
options.cols = 80
|
||||
options.chain_length = 2
|
||||
options.parallel = 1
|
||||
options.gpio_slowdown = 4
|
||||
#options.row_address_type = 0
|
||||
|
||||
options.hardware_mapping = 'regular' # If you have an Adafruit HAT: 'adafruit-hat'
|
||||
options.multiplexing = 1
|
||||
options.brightness = 100
|
||||
#options.pwm_lsb_nanoseconds = 300
|
||||
#options.pwm_bits = 11
|
||||
|
||||
matrix = RGBMatrix(options = options)
|
||||
|
||||
#Bufer que se copia en la pantalla led
|
||||
img_path='/srv/ledram/current.png'
|
||||
#imagen por defecto a mostrar al inicializarla
|
||||
init_file='/srv/init.png'
|
||||
|
||||
# Revisa si el bufer existe, si no existe lo crea
|
||||
# y si existe sale ya que hay otro proceso que lo
|
||||
if not os.path.isfile(img_path):
|
||||
shutil.copy(init_file, img_path)
|
||||
os.chmod(img_path, 0o666)
|
||||
else:
|
||||
print("El archivo de buffer ya existe!")
|
||||
exit(1)
|
||||
|
||||
#guarda el tiempo de modificación
|
||||
tstam = os.stat(img_path).st_mtime
|
||||
matrix.SetImage(Image.open(img_path).convert('RGB'))
|
||||
|
||||
while True:
|
||||
time.sleep(0.1)
|
||||
ntstam = os.stat(img_path).st_mtime
|
||||
#si el bufer fue modificado, lo carga en la pantalla led
|
||||
if ntstam > tstam:
|
||||
image=Image.open(img_path)
|
||||
matrix.SetImage(image.convert('RGB'))
|
||||
tstam = ntstam
|
|
@ -0,0 +1,14 @@
|
|||
[Unit]
|
||||
Description=LED Rendering Service
|
||||
After=local-fs.target
|
||||
|
||||
[Service]
|
||||
User=root
|
||||
CPUAffinity=3
|
||||
Nice=-20
|
||||
WorkingDirectory=/srv
|
||||
ExecStart=/usr/bin/python3 /srv/subsystem/led-driver.py
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in New Issue