def led_blink(led_id, r, g, b, sleep_time=1): if led_id == 0: bl.left_rgb(r, g, b) elif led_id == 1: bl.mid_rgb(r, g, b) elif led_id == 2: bl.right_rgb(r, g, b) time.sleep(sleep_time) if led_id == 0: bl.left_rgb(0, 0, 0) elif led_id == 1: bl.mid_rgb(0, 0, 0) elif led_id == 2: bl.right_rgb(0, 0, 0)
#!/usr/bin/env python print("""Testing DOT3K Interface...""") import dot3k.lcd as lcd import dot3k.backlight as backlight import time lcd.clear() lcd.write("=DOT3K========== ========loading=") backlight.left_rgb(255, 0, 0) time.sleep(0.3) backlight.mid_rgb(255, 0, 0) time.sleep(0.3) backlight.right_rgb(255, 0, 0) time.sleep(0.3) backlight.left_rgb(255, 255, 0) time.sleep(0.3) backlight.mid_rgb(255, 255, 0) time.sleep(0.3) backlight.right_rgb(255, 255, 0) time.sleep(0.3) backlight.left_rgb(255, 255, 255) time.sleep(0.3) backlight.mid_rgb(255, 255, 255) time.sleep(0.3) backlight.right_rgb(255, 255, 255) time.sleep(0.3) lcd.clear() lcd.write("=DOT3K========== ==========ready=") backlight.rgb(0, 0, 255) time.sleep(0.1) backlight.rgb(255, 255, 255)
#!/usr/bin/env python import time import dot3k.backlight as backlight import dot3k.lcd as lcd print(""" This example shows you a feature of the Dot HAT backlight. You should see the backlight go white, then multi-coloured. Press CTRL+C to exit. """) # Clear the LCD and display Hello World lcd.clear() lcd.write("Hello World") # Set all the backlights to white backlight.rgb(255, 255, 255) time.sleep(1) # Set the backlights independently backlight.left_rgb(255, 0, 0) backlight.mid_rgb(255, 0, 255) backlight.right_rgb(0, 0, 255) time.sleep(1)
backlight.use_rbg() 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 == '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.set_graph(0.0) elif command == 'setByPercentage': backlight.set_graph(float(parameters['percentage']) / 100) elif command == 'setBrightnessOfLed': backlight.set_bar(parameters['ledIndex'], parameters['brightness'])
def handle_up(pin): radio.up() @joystick.on(joystick.DOWN) def handle_down(pin): radio.down() @joystick.on(joystick.LEFT) def handle_left(pin): radio.left() @joystick.on(joystick.RIGHT) def handle_right(pin): radio.right() # @joystick.on(joystick.BUTTON) # def handle_button(pin): backlight.left_rgb(255, 0, 0) backlight.mid_rgb(255, 0, 255) backlight.right_rgb(0, 0, 255) while True: radio.redraw() time.sleep(0.2)
elif component == 'Backlight': if command == 'turnOff': backlight.off() elif command == 'useRBGMode': backlight.use_rbg() 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 == '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.set_graph(0.0) elif command == 'setByPercentage': backlight.set_graph(float(parameters['percentage']) / 100) elif command == 'setBrightnessOfLed': backlight.set_bar(parameters['ledIndex'], parameters['brightness'])