From b0e68515b4c08a76b331ad37231cd8dd28b9ea0e Mon Sep 17 00:00:00 2001 From: gcohen Date: Tue, 6 Jan 2015 00:37:00 -0800 Subject: thread test --- python/examples/futureHouse/futureHouse.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'python') diff --git a/python/examples/futureHouse/futureHouse.py b/python/examples/futureHouse/futureHouse.py index 92ff974..395b035 100644 --- a/python/examples/futureHouse/futureHouse.py +++ b/python/examples/futureHouse/futureHouse.py @@ -103,6 +103,7 @@ def error(message): def connect(message): print("CONNECTED") + startCycling() def reconnect(message): @@ -191,16 +192,16 @@ def cycleLEDs(x): pwm.setPWM(x, 0, leds[x]['maxPulseLength']) time.sleep(random.uniform(leds[x]['waitCeiling'], leds[x]['waitFloor'])) +def startCycling(): + while (True): -while (True): + for x in range(0,7) : + # print str(x) + ": " + str(leds[x]['minPulseLength']) + " " + str(leds[x]['maxPulseLength']) + " " + str(leds[x]['waitFloor']) + " " + str(leds[x]['waitCeiling']) + # Change speed of continuous servo on channel O + try: + thread.start_new_thread( cycleLEDs, (x,) ) + except: + print "Error: unable to start thread" - for x in range(0,7) : - # print str(x) + ": " + str(leds[x]['minPulseLength']) + " " + str(leds[x]['maxPulseLength']) + " " + str(leds[x]['waitFloor']) + " " + str(leds[x]['waitCeiling']) - # Change speed of continuous servo on channel O - try: - thread.start_new_thread( cycleLEDs, (x,) ) - except: - print "Error: unable to start thread" - - #cycleLEDs(x) + #cycleLEDs(x) -- cgit v1.2.3