def handle_button(ch,evt):
    print("Button pressed!")
    l.clear()
    b.rgb(0,0,0)
    l.set_cursor_position(0,0)
    l.write("Linux Voice")
    for i in range(256):
      b.left_rgb(i,0,0)
      time.sleep(0.01)
      b.mid_rgb(i,0,0)
      time.sleep(0.01)
      b.right_rgb(i,0,0)
      time.sleep(0.01)
Beispiel #2
0
def backlight(data):
    if data["command"] == "off":
        backlight.off()
        return True
    
    if data["command"] == "sweep":
        backlight.sweep(data["hue"],data["range"])
        return True

    if data["command"] == "hue":
        backlight.hue(data["hue"])
        return True
    if data["command"] == "rgb":
        backlight.rgb(data["r"],data["g"],data["b"])
        return True

    if data["command"] == "left_hue":
        backlight.left_hue(data["hue"])
        return True
    if data["command"] == "left_rgb":
        backlight.left_rgb(data["r"],data["g"],data["b"])
        return True

    if data["command"] == "mid_hue":
        backlight.mid_hue(data["hue"])
        return True
    if data["command"] == "mid_rgb":
        backlight.mid_rgb(data["r"],data["g"],data["b"])
        return True

    if data["command"] == "right_hue":
        backlight.right_hue(data["hue"])
        return True
    if data["command"] == "right_rgb":
        backlight.right_rgb(data["r"],data["g"],data["b"])
        return True

    if data["command"] == "set":
        backlight.set(data["index"],data["value"])
        return True

    if data["command"] == "set_bar":
        backlight.set_bar(data["index"],data["value"])
        return True
    if data["command"] == "set_graph":
        backlight.set(data["value"])
        return True

    if data["command"] == "update":
        backlight.update()
        return True
Beispiel #3
0
                print("left: " + str(power_left) + " right: " + str(power_right))

                PBR.SetMotor1((-power_right * maxPower))
                PBR.SetMotor2 (power_left * maxPower)


                print("#### Manual ####")

# line following

            if options_module['Line Following']:
                if lcd_flag:
                    LCD_update("line Following", "left  mid  right", "", 255, 255, 0)
                    lcd_flag = False

                backlight.left_rgb(255,0,0)
                backlight.mid_rgb(0,0,255)
                backlight.right_rgb(255,0,0)

                speed = 0.6

                # define motor variables and assign zero to them
                drive_left = 0
                drive_right = 0
                old_drive_left = 0
                old_drive_right = 0

                while button_flag:

                        values = line.read()
                        time.sleep(0.01)
import dothat.lcd as lcd
import time
import math

lcd.set_cursor_position(0,0)
lcd.write("Raspberry")
lcd.set_cursor_position(0,1)
lcd.write("Christmas")
lcd.set_cursor_position(0,2)


stage = 0
while True:
    if stage == 0:
        #Red,0,Green
        backlight.left_rgb(255,0,0)
        backlight.mid_rgb(0,0,0)
        backlight.right_rgb(0,255,0)
    elif stage == 1:
        #Green,Red,Green
        backlight.left_rgb(0,255,0)
        backlight.mid_rgb(255,0,0)
        backlight.right_rgb(0,255,0)
    elif stage == 2:
        #0,Green,Red
        backlight.left_rgb(0,0,0)
        backlight.mid_rgb(0,255,0)
        backlight.right_rgb(255,0,0)

    stage = (stage + 1) % 3
     elif command == 'setToHue':
         backlight.hue(parameters['hue'])
     elif command == 'setLeftToHue':
         backlight.left_hue(parameters['hue'])
     elif command == 'setMiddleToHue':
         backlight.mid_hue(parameters['hue'])
     elif command == 'setRightToHue':
         backlight.right_hue(parameters['hue'])
     elif command == 'setToRGB':
         backlight.rgb(parameters['red'], parameters['green'],
                       parameters['blue'])
     elif command == 'setZoneToRGB':
         backlight.single_rgb(parameters['zoneIndex'], parameters['red'],
                              parameters['green'], parameters['blue'])
     elif command == 'setLeftToRGB':
         backlight.left_rgb(parameters['red'], parameters['green'],
                            parameters['blue'])
     elif command == 'setMiddleToRGB':
         backlight.mid_rgb(parameters['red'], parameters['green'],
                           parameters['blue'])
     elif command == 'setRightToRGB':
         backlight.right_rgb(parameters['red'], parameters['green'],
                             parameters['blue'])
 elif component == 'BarGraph':
     if command == 'turnOff':
         backlight.graph_off()
     elif command == 'setByPercentage':
         backlight.set_graph(float(parameters['percentage']) / 100)
     elif command == 'setBrightness':
         backlight.graph_set_led_duty(parameters['minimumBrightness'],
                                      parameters['maximumBrightness'])
     elif command == 'setEnabledStateOfLed':
def set_entire_backlight(r, g, b):
    backlight.left_rgb(r, g, b)
    backlight.mid_rgb(r, g, b)
    backlight.right_rgb(r, g, b)
     elif command == 'setBrightnessOfLed':
         backlight.set(parameters['ledIndex'], parameters['brightness'])
     elif command == 'setToHue':
         backlight.hue(parameters['hue'])
     elif command == 'setLeftToHue':
         backlight.left_hue(parameters['hue'])
     elif command == 'setMiddleToHue':
         backlight.mid_hue(parameters['hue'])
     elif command == 'setRightToHue':
         backlight.right_hue(parameters['hue'])
     elif command == 'setToRGB':
         backlight.rgb(parameters['red'], parameters['green'], parameters['blue'])
     elif command == 'setZoneToRGB':
         backlight.single_rgb(parameters['zoneIndex'], parameters['red'], parameters['green'], parameters['blue'])
     elif command == 'setLeftToRGB':
         backlight.left_rgb(parameters['red'], parameters['green'], parameters['blue'])
     elif command == 'setMiddleToRGB':
         backlight.mid_rgb(parameters['red'], parameters['green'], parameters['blue'])
     elif command == 'setRightToRGB':
         backlight.right_rgb(parameters['red'], parameters['green'], parameters['blue'])
 elif component == 'BarGraph':
     if command == 'turnOff':
         backlight.graph_off()
     elif command == 'setByPercentage':
         backlight.set_graph(float(parameters['percentage']) / 100)
     elif command == 'setBrightness':
         backlight.graph_set_led_duty(parameters['minimumBrightness'], parameters['maximumBrightness'])
     elif command == 'setEnabledStateOfLed':
         backlight.graph_set_led_polarity(parameters['ledIndex'], 0b00000000)
         backlight.graph_set_led_state(parameters['ledIndex'], 1 if parameters['enabledState'] else 0)
 elif component == 'Touch':