Example #1
0
def main_light_tests():
    main_light = RGB(**MAIN_LIGHT_PINS)
    log.debug('main_light Successfully Setup')

    log.debug('Turning Red Light on for main_light')
    main_light.red()
    sleep(2)

    log.debug('Turning Blue Light on for main_light')
    main_light.blue()
    sleep(2)

    log.debug('Turning Green Light on for main_light')
    main_light.green()
    sleep(2)
Example #2
0
def cross_light_tests():
    cross_light = RGB(**CROSS_LIGHT_PINS)
    log.debug('cross_light Successfully Setup')

    log.debug('Turning Red Light on for cross_light')
    cross_light.red()
    sleep(2)

    log.debug('Turning Blue Light on for cross_light')
    cross_light.blue()
    sleep(2)

    log.debug('Turning Green Light on for cross_light')
    cross_light.green()
    sleep(2)
Example #3
0
class FSM:
    def __init__(self):
        GPIO.setmode(GPIO.BCM)
        self.main_light = RGB(**MAIN_LIGHT_PINS)
        self.cross_light = RGB(**CROSS_LIGHT_PINS)
        self.display = DigitDisplay(DISPLAY_PINS)
        self.button = Button(BUTTON_PIN, BOUNCE_TIME, self.handled_press)

        self.S1()

    def start(self):
        log.debug('FSM process starting')
        while True:
            pass

    def S1(self):
        log.info('FSM State: S1')
        self.main_light.green()
        self.cross_light.red()

    def S2(self):
        log.info('FSM State: S2')
        self.main_light.flash_blue(10)
        self.S3()

    def S3(self):
        log.info('FSM State: S3')
        self.main_light.red()
        self.cross_light.green()
        self.display.count_down(9, 5)
        self.S4()

    def S4(self):
        log.info('FSM State: S4')

        def blue_flash():
            self.cross_light.flash_blue(1)

        self.display.count_down_with_cb(4, 0, blue_flash)
        self.S1()

    def handled_press(self):
        self.S2()
Example #4
0
import time
import board
from rgb import RGB  # import the RGB class from the rgb module

r1 = board.D3  #sets all pins up
g1 = board.D4
b1 = board.D5
r2 = board.D1
g2 = board.D2
b2 = board.D7

myRGB1 = RGB(r1, g1, b1)  # create a new RGB object, using pins 3, 4, and 5
myRGB2 = RGB(r2, g2, b2)  # create a new RGB object, using pins 8, 9, and 10

myRGB1.red()  # Glow red
myRGB2.green()  # Glow green
time.sleep(1)
myRGB1.blue()  # Glow blue
myRGB2.cyan()  # Glow... you get it...
time.sleep(1)
myRGB1.magenta()  # Did you know magenta isn't in the rainbow?
myRGB2.yellow()  # Like you learned in first grade, red and green make... huh?
time.sleep(1)
myRGB1.rainbow1(
)  # Nicely fade through all the colors of the rainbow at the given rate.  Oooooh, pretty!
myRGB2.rainbow2(
)  # Nicely fade through all the colors of the rainbow at the given rate.  Oooooh, pretty!
time.sleep(1)
Example #5
0
import board  #pylint: disable-msg=import-error
import time
from rgb import RGB

#pin numbers for each color
r1 = board.D2
g1 = board.D3
b1 = board.D4
r2 = board.D5
g2 = board.D6
b2 = board.D7

#declare objects
LED1 = RGB(r1, g1, b1)
LED2 = RGB(r2, g2, b2)

#call methods from class
LED1.red()
LED2.green()
time.sleep(1)
LED1.blue()
LED2.cyan()
time.sleep(1)
LED1.magenta()
LED2.yellow()
time.sleep(1)
import time
import board  #pylint: disable-msg=import-error
from rgb import RGB

pins1 = [board.D1, board.D2, board.D3]
pins2 = [board.D4, board.D5, board.D7]
delay = 1

myRGB1 = RGB(pins1)
myRGB2 = RGB(pins2)

print("go")

while True:
    myRGB1.red()
    myRGB2.green()
    time.sleep(delay)
    myRGB1.green()
    myRGB2.red()
    time.sleep(delay)
    myRGB1.blue()
    myRGB2.cyan()
    time.sleep(delay)
    myRGB1.cyan()
    myRGB2.blue()
    time.sleep(delay)
    myRGB1.magenta()
    myRGB2.yellow()
    time.sleep(delay)
    myRGB1.yellow()
    myRGB2.magenta()
Example #7
0
import time
import board  #pylint: disable-msg=import-error
from rgb import RGB

r = board.D2
g = board.D3
b = board.D4

myRGB = RGB(r, g, b)

print("go")

while True:
    myRGB.red()
    time.sleep(0.1)
    myRGB.green()
    time.sleep(0.1)
    myRGB.blue()
    time.sleep(0.1)
    myRGB.cyan()
    time.sleep(0.1)
    myRGB.magenta()
    time.sleep(0.1)
    myRGB.yellow()
    time.sleep(0.1)
    myRGB.white()
    time.sleep(0.1)
    myRGB.black()
    time.sleep(0.1)
    myRGB.rainbow()
Example #8
0
r2 = board.D1
g2 = board.D2
b2 = board.D7

rate1 = 0.005
rate2 = 0.001

myRGB1 = RGB(r1, g1, b1)  # create a new RGB object, using pins 2, 3, and 4
myRGB2 = RGB(r2, g2, b2)  # create a new RGB object, using pins 5, 6, and 7

#print(myRGB1.kind)
#print(myRGB2.kind)
myRGB1.change_name("rex")

myRGB1.red()  # first RGB LED glow red

myRGB2.green()  # second RGB LED glow green

time.sleep(1)

myRGB1.blue()  # first RGB LED glow blue

myRGB2.cyan()  # second RGB LED glow cyan

time.sleep(1)

myRGB1.magenta()  # first RGB LED glow magenta

myRGB2.yellow()  # second RGB LED glow yellow