|
|
@@ -15,6 +15,9 @@ import time |
|
|
|
from urllib.parse import urlparse |
|
|
|
from utils.web import handle_file_request, get_my_ip |
|
|
|
from mc_control.mc_statemachine import mc_state_machine, mc_event |
|
|
|
from gpiozero import LED |
|
|
|
from gpiozero.pins.pigpio import PiGPIOFactory |
|
|
|
|
|
|
|
|
|
|
|
HOST_NAME = '' #'localhost' |
|
|
|
PORT_NUMBER = 8000 |
|
|
@@ -117,13 +120,23 @@ class myhandler(BaseHTTPRequestHandler): |
|
|
|
class ThreadedHTTPServer(ThreadingMixIn, HTTPServer): |
|
|
|
''' ''' |
|
|
|
|
|
|
|
def StartStateMachines(): |
|
|
|
def StartStateMachines(factory): |
|
|
|
global sm |
|
|
|
sm = list() |
|
|
|
sm.append( mc_state_machine(0, 1)) |
|
|
|
sm.append( mc_state_machine(2, 3)) |
|
|
|
sm.append( mc_state_machine(4, 5)) |
|
|
|
sm.append( mc_state_machine(6, 7)) |
|
|
|
|
|
|
|
up_1 = LED(16, pin_factory=factory) |
|
|
|
down_1 = LED(12, pin_factory=factory) |
|
|
|
up_2 = LED(6, pin_factory=factory) |
|
|
|
down_2 = LED(20, pin_factory=factory) |
|
|
|
up_3 = LED(13, pin_factory=factory) |
|
|
|
down_3 = LED(21, pin_factory=factory) |
|
|
|
up_4 = LED(19, pin_factory=factory) |
|
|
|
down_4 = LED(26, pin_factory=factory) |
|
|
|
|
|
|
|
sm.append( mc_state_machine(up_1, down_1)) |
|
|
|
sm.append( mc_state_machine(up_2, down_2)) |
|
|
|
sm.append( mc_state_machine(up_3, down_3)) |
|
|
|
sm.append( mc_state_machine(up_4, down_4)) |
|
|
|
|
|
|
|
def CloseStateMachines(): |
|
|
|
global sm |
|
|
@@ -136,7 +149,9 @@ def CloseStateMachines(): |
|
|
|
if __name__ == '__main__': |
|
|
|
|
|
|
|
global sm |
|
|
|
StartStateMachines() |
|
|
|
|
|
|
|
factory = PiGPIOFactory(host='jalousiecontrol') |
|
|
|
StartStateMachines(factory) |
|
|
|
|
|
|
|
httpd = ThreadedHTTPServer((HOST_NAME,PORT_NUMBER),myhandler) |
|
|
|
|
|
|
|