sleep longer and run in pi

This commit is contained in:
Jens Ullmert 2022-07-27 11:57:34 +02:00
parent a980c70bde
commit f1b38b9bce

View File

@ -3,16 +3,26 @@
# WS server example that synchronizes state across clients
import asyncio
# import json
import json
import logging
import websockets
# import redis
import redis
import time
import serial
import numpy as np
#import RPi.GPIO as GPIO
import RPi.GPIO as GPIO
import threading
import os
def is_raspberrypi():
try:
with io.open('/sys/firmware/devicetree/base/model', 'r') as m:
if 'raspberry pi' in m.read().lower(): return True
except Exception: pass
return False
print(is_raspberrypi)
# Colordefinition for console print
class pcol:
@ -46,7 +56,7 @@ DMXRST = 88.0 # typical 88µs
DMXBRK = 8.0 # 8µs (min) to 1s (max)
# DMX Sequence sleep [ms]/float
DMXSLP = 250.0 # 0µs (min) to 1s (max)
DMXSLP = 5000.0 #250.0 # 0µs (min) to 1s (max)
# Buffer for RDM
DMXRDM = 0
@ -95,7 +105,7 @@ def sendDMX(data):
DMXSER.cancel_read()
# GPIO_18 to switch RS-485 driver (IC1) to TX-mode
#GPIO.output(18, GPIO.HIGH)
GPIO.output(18, GPIO.HIGH)
# send reset
DMXSER.send_break(DMXRST / 1000000.0)
@ -108,7 +118,7 @@ def sendDMX(data):
# GPIO_18 to switch RS-485 driver (IC1) to RX-mode
DMXSER.reset_input_buffer()
#GPIO.output(18, GPIO.LOW)
GPIO.output(18, GPIO.LOW)
# Sleep between TX packages, use time to get RDM packages
DMXRDM = ""
@ -297,19 +307,20 @@ async def websworker(websocket, path):
#
###########################
# We have to set GPIO
#GPIO.setmode(GPIO.BCM)
#GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
#GPIO.setup(18, GPIO.OUT)
#GPIO.setup(4, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(4, GPIO.OUT)
# GPIO_18 to switch RS-485 driver (IC1) to RX-mode
#GPIO.output(18, GPIO.LOW)
# V2: will be done in send-loop for rdm
# Powercycle 3V3 on HAT to ensure a cleaned up buffer
#GPIO.output(4, GPIO.HIGH)
#time.sleep(0.25)
#GPIO.output(4, GPIO.LOW)
GPIO.output(4, GPIO.HIGH)
time.sleep(0.25)
GPIO.output(4, GPIO.LOW)