Beispiel #1
0
 def __init__(self):
     WuClass.__init__(self)
     self.loadClass('LED_Pattern')
     self.mystripe = pyupm_lpd8806.LPD8806(nLED, 7)
     self.led_case = 0
     self.led_two_hz = False
     self.led_step_count = 0
     print "LED stripe init success"
Beispiel #2
0
 def __init__(self):
     WuClass.__init__(self)
     self.loadClass('Strip_LED')
     self.mystrip = pyupm_lpd8806.LPD8806(4, 7)
     self.mystrip.show()
     self.mystrip.setPixelColor(0, 0, 0, 0)
     self.mystrip.setPixelColor(1, 0, 0, 0)
     self.mystrip.setPixelColor(2, 0, 0, 0)
     self.mystrip.setPixelColor(3, 0, 0, 0)
     self.mystrip.show()
     print "Light Actuator init success"
Beispiel #3
0
    def __init__(self):
        WuClass.__init__(self)
        self.loadClass('Pattern')
        save = [[7], [1, 9], [2, 10], [4], [7], [1, 9], [2, 10], [4], [7],
                [1, 9], [2, 10], [4], [7], [1, 9], [2, 10], [4], [7], [1, 9],
                [2, 10], [4], [7], [1, 9], [2, 10], [4]]
        turn_right = [[], [], [], [], [7], [], [], [], [0, 8], [6], [], [], [],
                      [1, 9], [5], [], [], [], [2, 10], [4], [], [], [],
                      [3, 11]]
        turn_left = [[], [], [], [], [], [], [], [4], [], [], [5], [3, 11], [],
                     [6], [2, 10], [], [7], [1, 9], [], [], [0, 8], [], [], []]
        stay = [[0, 8], [6], [5], [3, 11], [0, 8], [6], [5], [3, 11], [0, 8],
                [6], [5], [3, 11], [0, 8], [6], [5], [3, 11], [0, 8], [6], [5],
                [3, 11], [0, 8], [6], [5], [3, 11]]
        clean = [[0, 7, 8], [1, 6, 9], [2, 5, 10], [3, 4, 11]]
        self.pattern = [save, turn_right, turn_left, stay, clean]
        self.count = 0
        init_pattern = [7, 1, 9, 2, 10, 4]

        if device_type == DEVICE_TYPE_MRAA:
            self.ledNUM = 12
            self.mystrip = pyupm_lpd8806.LPD8806(self.ledNUM, 7)
            #turn off all led with edison's API
            for i in range(self.ledNUM):
                self.mystrip.setPixelColor(i, 0, 0, 0)
            self.mystrip.show()
            #turn on init pattern with edison's API
            for i in range(len(init_pattern)):
                self.mystrip.setPixelColor(init_pattern[i], 0, 127, 0)
            self.mystrip.show()
        elif device_type == DEVICE_TYPE_RPI:
            led.all_off()
            #turn on init pattern with Pi's API
            for i in range(len(init_pattern)):
                led.set(init_pattern[i], Color(0, 255, 0, 0.5))
            led.update()
        print "Init: Pattern 0 start"
Beispiel #4
0
import mraa
import pyupm_lpd8806
import time
nLED = 4
mystrip = pyupm_lpd8806.LPD8806(nLED, 7)

fogSensor=mraa.Gpio(2)
fogSensor.dir(mraa.DIR_IN)

touchpad=mraa.Gpio(4)
touchpad.dir(mraa.DIR_IN)

def redlight():
mystrip.setPixelColor(0, 10, 0, 0) #setPixelColor(id, r, g, b)
mystrip.setPixelColor(1, 10, 0, 0) #setPixelColor(id, r, g, b)
mystrip.setPixelColor(2, 10, 0, 0) #setPixelColor(id, r, g, b)
mystrip.setPixelColor(3, 10, 0, 0) #setPixelColor(id, r, g, b)
return

def greenlight():
mystrip.setPixelColor(0, 0, 10, 0) #setPixelColor(id, r, g, b)
mystrip.setPixelColor(1, 0, 10, 0) #setPixelColor(id, r, g, b)
mystrip.setPixelColor(2, 0, 10, 0) #setPixelColor(id, r, g, b)
mystrip.setPixelColor(3, 0, 10, 0) #setPixelColor(id, r, g, b)
return

while True:
mystrip.show()
#reset for some issue
touchValue=touchpad.read()
fogValue=fogSensor.read()