From 070a233e22e932ee2f444053ae75b413d67e8ae9 Mon Sep 17 00:00:00 2001 From: gcohen Date: Tue, 6 Jan 2015 00:18:22 -0800 Subject: running waits on sep threads --- python/examples/futureHouse/futureHouse.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/python/examples/futureHouse/futureHouse.py b/python/examples/futureHouse/futureHouse.py index f7a368e..d2204cb 100644 --- a/python/examples/futureHouse/futureHouse.py +++ b/python/examples/futureHouse/futureHouse.py @@ -182,11 +182,17 @@ def moveDoor(direction): # Initialise the PWM device using the default address pwm = PWM(0x40, debug=False) pwm.setPWMFreq(60) # Set frequency to 60 Hz + + +def cycleLEDs(x): + pwm.setPWM(x, 0, leds[x]['minPulseLength']) + time.sleep(random.uniform(leds[x]['waitCeiling'], leds[x]['waitFloor'])) + pwm.setPWM(x, 0, leds[x]['maxPulseLength']) + time.sleep(random.uniform(leds[x]['waitCeiling'], leds[x]['waitFloor'])) + + 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 - pwm.setPWM(x, 0, leds[x]['minPulseLength']) - time.sleep(random.uniform(leds[x]['waitCeiling'],leds[x]['waitFloor'])) - pwm.setPWM(x, 0, leds[x]['maxPulseLength']) - time.sleep(random.uniform(leds[x]['waitCeiling'],leds[x]['waitFloor'])) + cycleLEDs(x) -- cgit v1.2.3