Exemple #1
0
 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)
Exemple #2
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)
Exemple #3
0
#!/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'])
Exemple #5
0
    lcd.clear()
    backlight.off()
    exit(0)


signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGQUIT, signal_handler)
signal.signal(signal.SIGHUP, signal_handler)

lcd.set_contrast(45)

#red
backlight.left_rgb(255, 0, 0)
#blue
backlight.mid_rgb(0, 255, 0)
#green
backlight.right_rgb(0, 0, 255)

pos = 0

black = [
    0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111
]

m = [[0b00000, 0b00000, 0b00000, 0b11010, 0b10101, 0b10101, 0b10001, 0b10001],
     [0b00000, 0b00000, 0b11010, 0b10101, 0b10101, 0b10001, 0b10001, 0b00000],
     [0b00000, 0b11010, 0b10101, 0b10101, 0b10001, 0b10001, 0b00000, 0b00000],
     [0b11010, 0b10101, 0b10101, 0b10001, 0b10001, 0b00000, 0b00000, 0b00000],
     [0b00000, 0b11010, 0b10101, 0b10101, 0b10001, 0b10001, 0b00000, 0b00000],
     [0b00000, 0b00000, 0b11010, 0b10101, 0b10101, 0b10001, 0b10001, 0b00000]]
    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'])