sleep longer and run in pi
This commit is contained in:
parent
a980c70bde
commit
f1b38b9bce
@ -3,16 +3,26 @@
|
|||||||
# WS server example that synchronizes state across clients
|
# WS server example that synchronizes state across clients
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
# import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import websockets
|
import websockets
|
||||||
# import redis
|
import redis
|
||||||
import time
|
import time
|
||||||
import serial
|
import serial
|
||||||
import numpy as np
|
import numpy as np
|
||||||
#import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
import threading
|
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
|
# Colordefinition for console print
|
||||||
class pcol:
|
class pcol:
|
||||||
@ -46,7 +56,7 @@ DMXRST = 88.0 # typical 88µs
|
|||||||
DMXBRK = 8.0 # 8µs (min) to 1s (max)
|
DMXBRK = 8.0 # 8µs (min) to 1s (max)
|
||||||
|
|
||||||
# DMX Sequence sleep [ms]/float
|
# 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
|
# Buffer for RDM
|
||||||
DMXRDM = 0
|
DMXRDM = 0
|
||||||
@ -95,7 +105,7 @@ def sendDMX(data):
|
|||||||
DMXSER.cancel_read()
|
DMXSER.cancel_read()
|
||||||
|
|
||||||
# GPIO_18 to switch RS-485 driver (IC1) to TX-mode
|
# GPIO_18 to switch RS-485 driver (IC1) to TX-mode
|
||||||
#GPIO.output(18, GPIO.HIGH)
|
GPIO.output(18, GPIO.HIGH)
|
||||||
|
|
||||||
# send reset
|
# send reset
|
||||||
DMXSER.send_break(DMXRST / 1000000.0)
|
DMXSER.send_break(DMXRST / 1000000.0)
|
||||||
@ -108,7 +118,7 @@ def sendDMX(data):
|
|||||||
|
|
||||||
# GPIO_18 to switch RS-485 driver (IC1) to RX-mode
|
# GPIO_18 to switch RS-485 driver (IC1) to RX-mode
|
||||||
DMXSER.reset_input_buffer()
|
DMXSER.reset_input_buffer()
|
||||||
#GPIO.output(18, GPIO.LOW)
|
GPIO.output(18, GPIO.LOW)
|
||||||
|
|
||||||
# Sleep between TX packages, use time to get RDM packages
|
# Sleep between TX packages, use time to get RDM packages
|
||||||
DMXRDM = ""
|
DMXRDM = ""
|
||||||
@ -297,19 +307,20 @@ async def websworker(websocket, path):
|
|||||||
#
|
#
|
||||||
###########################
|
###########################
|
||||||
# We have to set GPIO
|
# We have to set GPIO
|
||||||
#GPIO.setmode(GPIO.BCM)
|
GPIO.setmode(GPIO.BCM)
|
||||||
#GPIO.setwarnings(False)
|
GPIO.setwarnings(False)
|
||||||
|
|
||||||
#GPIO.setup(18, GPIO.OUT)
|
GPIO.setup(18, GPIO.OUT)
|
||||||
#GPIO.setup(4, GPIO.OUT)
|
GPIO.setup(4, GPIO.OUT)
|
||||||
|
|
||||||
# GPIO_18 to switch RS-485 driver (IC1) to RX-mode
|
# GPIO_18 to switch RS-485 driver (IC1) to RX-mode
|
||||||
#GPIO.output(18, GPIO.LOW)
|
#GPIO.output(18, GPIO.LOW)
|
||||||
|
# V2: will be done in send-loop for rdm
|
||||||
|
|
||||||
# Powercycle 3V3 on HAT to ensure a cleaned up buffer
|
# Powercycle 3V3 on HAT to ensure a cleaned up buffer
|
||||||
#GPIO.output(4, GPIO.HIGH)
|
GPIO.output(4, GPIO.HIGH)
|
||||||
#time.sleep(0.25)
|
time.sleep(0.25)
|
||||||
#GPIO.output(4, GPIO.LOW)
|
GPIO.output(4, GPIO.LOW)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user