def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Blinkt Light platform.""" import blinkt # ensure that the lights are off when exiting blinkt.set_clear_on_exit() name = config.get(CONF_NAME) add_devices([BlinktLight(blinkt, name)])
def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Blinkt Light platform.""" # pylint: disable=no-member import blinkt # ensure that the lights are off when exiting blinkt.set_clear_on_exit() name = config.get(CONF_NAME) add_devices([ BlinktLight(blinkt, name, index) for index in range(blinkt.NUM_PIXELS) ])
def ledstage( stage ): #Prevent the LED's clearing after script execution and reboot. set_clear_on_exit(False) #Colours! colours = [] colours.append([255,25,0]) colours.append([200,50,0]) colours.append([150,75,0]) colours.append([125,100,0]) colours.append([100,125,0]) colours.append([50,175,0]) colours.append([25,200,0]) colours.append([0,255,0]) #Loop var x = 0 #Clear LED's if 0 if stage == 0: set_all(0,0,0) show() elif stage == 8: #Party! counter = 50 while x < counter: for i in range(8): set_pixel(i, random.randint(0,255), random.randint(0,255), random.randint(0,255)) show() time.sleep(0.05) x += 1 else: while x < stage: set_pixel(x,colours[x][0],colours[x][1],colours[x][2],0.1) show() x += 1
import sys import time from blinkt import set_all, set_clear_on_exit, show def usage(): print("Usage: {} <r> <g> <b>".format(sys.argv[0])) sys.exit(1) if len(sys.argv) != 4: usage() # Exit if non integer value. int() will raise a ValueError try: r, g, b = [int(x) for x in sys.argv[1:]] except ValueError: usage() # Exit if any of r, g, b are greater than 255 if max(r,g,b) > 255: usage() print("Setting Blinkt to {r},{g},{b}".format(r=r,g=g,b=b)) set_clear_on_exit(False) set_all(r, g, b) show()
import time from blinkt import set_clear_on_exit, set_pixel, show, set_brightness set_clear_on_exit() set_brightness(0.1) while True: for i in range(8): if i == 0 or i == 1: set_pixel(i, 255, 0, 0) else: set_pixel(i, 255, 0, 0) set_pixel(i-2, 0, 0, 0) show() time.sleep(0.1) if i == 7: set_pixel(i-1, 0, 0, 0) show() time.sleep(0.1) set_pixel(i, 0, 0, 0) show() time.sleep(0.25) for i in range (7, -1, -1): if i == 7 or i == 6: set_pixel(i, 255, 0, 0) else: set_pixel(i, 255, 0, 0)
def __init__(self): self.logger = logging.getLogger(__name__) self.logger.info("Initialising blinktcontrol") blinkt.set_clear_on_exit()
#!/usr/bin/env python import signal import buttonshim import blinkt import os blinkt.set_clear_on_exit() @buttonshim.on_press(buttonshim.BUTTON_A) def button_a(button, pressed): buttonshim.set_pixel(128, 0, 0) blinkt.set_all(128, 0, 0) @buttonshim.on_press(buttonshim.BUTTON_B) def button_b(button, pressed): buttonshim.set_pixel(0, 128, 0) blinkt.set_all(0, 128, 0) @buttonshim.on_press(buttonshim.BUTTON_C) def button_c(button, pressed): buttonshim.set_pixel(0, 0, 128) blinkt.set_all(0, 0, 128) @buttonshim.on_press(buttonshim.BUTTON_D) def button_d(button, pressed): buttonshim.set_pixel(0xff, 0xff, 0x00) @buttonshim.on_press(buttonshim.BUTTON_E) def button_e(button, pressed): buttonshim.set_pixel(0xff, 0x00, 0x00)
#!/usr/bin/env python import time import blinkt blinkt.set_clear_on_exit() def get_cpu_temperature(): with open("/sys/devices/virtual/thermal/thermal_zone0/temp", "r") as file: temp_raw = file.read() temp = int(temp_raw) / 1000 return temp def show_graph(v, r, g, b): v *= blinkt.NUM_PIXELS for x in range(blinkt.NUM_PIXELS): if v < 0: r, g, b = 0, 0, 0 else: r, g, b = [int(min(v, 1.0) * c) for c in [r, g, b]] blinkt.set_pixel(x, r, g, b) v -= 1 blinkt.show()
#!/usr/bin/env python import math import time import colorsys from blinkt import set_clear_on_exit, set_pixel, show, set_brightness FALLOFF = 1.9 SCAN_SPEED = 4 set_clear_on_exit() start_time = time.time() while True: delta = (time.time() - start_time) # Offset is a sine wave derived from the time delta # we use this to animate both the hue and larson scan # so they are kept in sync with each other offset = (math.sin(delta * SCAN_SPEED) + 1) / 2 # Use offset to pick the right colour from the hue wheel hue = int(round(offset * 360)) # Now we generate a value from 0 to 7 offset = int(round(offset * 7)) for x in range(8): sat = 1.0
def set_clear_on_exit(self, value=False): if HAS_BLINKT: blinkt.set_clear_on_exit(value) else: print("""set_clear_on_exit({})""".format(value))
print('\n') print(HASHES) print(HASH, 'Pi Remind (Zero W & Blinkt) ', HASH) print(HASH, 'By John M. Wargo (www.johnwargo.com)', HASH) print(HASHES) # Initialize the Google Calendar API stuff credentials = get_credentials() http = credentials.authorize(httplib2.Http()) service = discovery.build('calendar', 'v3', http=http) print("Setting Blinkt settings") # set LED brightness to half lights.set_brightness(0.25) # clears the LEDs when the application closes lights.set_clear_on_exit() # flash some LEDs just for fun... # lets the user know the hardware is working zip_zip(1, RED) zip_zip(1, GREEN) zip_zip(1, BLUE) # The app flashes a GREEN light in the first row every time it connects to Google to check the calendar. # The LED increments every time until it gets to the other side then starts over at the beginning again. # The current_activity_light variable keeps track of which light lit last. At start it's at -1 and goes from there. current_activity_light = 8 set_activity_light(SUCCESS_COLOR, True) print('\nApplication initialized\n')
#!/usr/bin/env python import sys from sys import argv import blinkt if len(argv) < 4 or len(argv) > 5: sys.stderr.write("Syntax: {0} <red> <green> <blue> [brightness]\n".format( argv[0])) exit(1) red = int(argv[1]) green = int(argv[2]) blue = int(argv[3]) bright = float(argv[4]) if len(argv) > 4 else None blinkt.set_clear_on_exit(False) blinkt.set_all(red, green, blue, bright) blinkt.show()