예제 #1
0
def display_both_open():
    clear()
    set_pixel(1, 0, 255, 0)
    set_pixel(2, 0, 255, 0)
    set_pixel(5, 0, 255, 0)
    set_pixel(6, 0, 255, 0)
    show()
예제 #2
0
 def set_all(status):
     if BLINKT:
         blinkt.set_all(BlinktHelper.colors[status]["r"],
             BlinktHelper.colors[status]["g"],
             BlinktHelper.colors[status]["b"],
             brightness=BlinktHelper.colors[status]["brightness"])
         blinkt.show()
예제 #3
0
 def set_light(position, status):
     if BLINKT:
         blinkt.set_pixel(position % blinkt.NUM_PIXELS, 
             BlinktHelper.colors[status]["r"],
             BlinktHelper.colors[status]["g"],
             BlinktHelper.colors[status]["b"],
             brightness=BlinktHelper.colors[status]["brightness"])
         blinkt.show()
def blink():
    for i in range(5):
        set_pixel(7, 255, 0, 0)
        show()
        sleep(1)
        set_pixel(7, 0, 0, 0)
        show()
        sleep(1)
def FadeInOut(delay):
  for b in range(31):
    set_brightness(b/31.0)
    show()
    sleep(delay)
  for b in range(31):
    set_brightness((31-b)/31.0)
    show()
    sleep(delay)
예제 #6
0
 def flash_op(x, rgb):
     start = time.time()
     while time.time() < start + REFRESH_TIME:
         blinkt.set_pixel(x, *rgb, brightness=0.04)
         blinkt.show()
         time.sleep(1.5)
         blinkt.set_pixel(x, *rgb, brightness=0.0)
         blinkt.show()
         time.sleep(1.5)
예제 #7
0
def display_male_closed():
    clear()
    set_pixel(1, 0, 255, 0)
    set_pixel(2, 0, 255, 0)
    set_pixel(4, 255, 0, 0)
    set_pixel(5, 255, 0, 0)
    set_pixel(6, 255, 0, 0)
    set_pixel(7, 255, 0, 0)
    show()
예제 #8
0
def display_female_closed():
    print('RED/GREEN')
    clear()
    set_pixel(0, 255, 0, 0)
    set_pixel(1, 255, 0, 0)
    set_pixel(2, 255, 0, 0)
    set_pixel(3, 255, 0, 0)
    set_pixel(5, 0, 255, 0)
    set_pixel(6, 0, 255, 0)
    show()
예제 #9
0
def blink_blinkt():
    for i in range(3):
        for j in range(8):
            set_pixel(j, 255, 0, 0)
        show()
        time.sleep(0.1)
        for j in range(8):
            set_pixel(j, 0, 0, 0)
        show()
        time.sleep(0.2)
def blinking_count(n,r,g,b):
    for j in range (n):
        for i in range(8):
            set_pixel(i, r, g, b)
        show()
        sleep(0.5)
        for i in range(8):
            set_pixel(i, 0, 0, 0)
        show()
        sleep(0.5)
예제 #11
0
def display_unknown():
    clear()
    set_pixel(0, 0, 255, 255)
    set_pixel(1, 0, 255, 255)
    set_pixel(2, 0, 255, 255)
    set_pixel(3, 0, 255, 255)
    set_pixel(4, 0, 255, 255)
    set_pixel(5, 0, 255, 255)
    set_pixel(6, 0, 255, 255)
    set_pixel(7, 0, 255, 255)
    show()
예제 #12
0
def display_both_closed():
    clear()
    set_pixel(0, 255, 0, 0)
    set_pixel(1, 255, 0, 0)
    set_pixel(2, 255, 0, 0)
    set_pixel(3, 255, 0, 0)
    set_pixel(4, 255, 0, 0)
    set_pixel(5, 255, 0, 0)
    set_pixel(6, 255, 0, 0)
    set_pixel(7, 255, 0, 0)
    show()
예제 #13
0
파일: mem_load.py 프로젝트: RogueM/blinkt
def show_graph(v, r, g, b):
    v *= 8
    for x in range(8):
        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]]
        set_pixel(x, r, g, b)
        v -= 1

    show()
예제 #14
0
def display( intensity = 0.5, threshold = 50, wait = 0.5 ) :
    pixels = 8 * [ 0.0, ]
    while True :
        load = max( [ psutil.cpu_percent(), psutil.virtual_memory().percent ] )
        pixels.append( load )
        pixels.pop( 0 )
        for index, percentage in enumerate( pixels ) :
            if percentage > threshold : red, green, blue = intensity * percentage, 0, 0
            else : red, green, blue = 0, intensity * percentage, 0
            blinkt.set_pixel( index, red, green, blue, percentage )
        blinkt.show()
        time.sleep( wait )
예제 #15
0
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()
예제 #16
0
def snake(r, g, b):
    "This creates a snake effect on the blinkt using the specified colour"
    clear()
    for count in range(1, 20):
        print(count)
        for i in range(8):
            clear()
            set_pixel(i, r, g, b)
            show()
            time.sleep(0.05)
    clear()
    return
예제 #17
0
def switchColor(col):
    #clear()
    if col == 0:
        for k in range(0,2):
            set_pixel(k,0,255,0)
    if col == 1:
        for k in range(0,2):
            set_pixel(k,255,0,0)
    if col == 2:
        for k in range(0,2):
            set_pixel(k,0,0,255)
    show()
예제 #18
0
    def __init__(self):
        blinkt.clear()
        blinkt.show()

        self.state = 'OFF'
        self.brightness = 1
        self.rgb_color = (255, 255, 255)
        self.effect = 'None'
        self.effect_speed = 50

        self.effect_thread = None
        self.publish_state()
예제 #19
0
def splash():
   set_brightness(0.3)
   for x in range(0, 8):
       set_pixel(x, 255, 0, 0)
       show()
       time.sleep(0.1)

   time.sleep(0.1)
   for y in range(0, 8):
       set_pixel(y, 0, 0, 0)
       show()
       time.sleep(0.1)
예제 #20
0
  def _running_light(self,stop_me,duration=5,rgb=[0,0,255],delay=0):
    """ running light of defined color (modified from blinkt-example larson.py) """
    
    duration = int(duration)

    self._settings.log.msg(
      "LedController: executing running_light-alarm for %s minutes" % duration)

    (r,g,b) = rgb
    values = [(0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0),
              (r//16,g//16,b//16),
              (r//4,g//4,b//4),
              (r,g,b),
              (r//4,g//4,b//4),
              (r//16,g//16,b//16),
              (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0)]

    start_time = time.time()
    end_time   = start_time + 60*duration
    now        = start_time

    # honor delay
    delay = int(delay)
    if delay > 0:
      self._settings.log.msg(
        "LedController: delaying alarm for %d minutes" % delay)
      if stop_me.wait(60*delay):
        return

    if simulate:
      stop_me.wait(60*duration)
      self._settings.log.msg("LedController: running_light-alarm finished")
    else:
      with self._lock:
        blinkt.set_brightness(1.0)
        while now <= end_time:

          delta  = (now - start_time) * 16
          offset = int(abs((delta % 16) - 8))

          for i in range(8):
            (rv,gv,bv) = values[offset + i]
            blinkt.set_pixel(i,rv,gv,bv)

          blinkt.show()
          if stop_me.wait(0.1):
            break
          now = time.time()

      # reset display to standard
      self._settings.log.msg("LedController: running_light-alarm finished")
      self._set_leds()
예제 #21
0
def set_colour(colour):
    r = '0x' + colour[0:2]
    g = '0x' + colour[2:4]
    b = '0x' + colour[4:6]

    r_value = int(r, 0)
    g_value = int(g, 0)
    b_value = int(b, 0)

    print('Updating color: r =', r_value, ', g =', g_value, ', b =', b_value)

    blinkt.set_all(r_value, g_value, b_value)
    blinkt.show()
예제 #22
0
def blink_blinkt():
    for i in range(3):
        for j in range(blinkt.NUM_PIXELS):
            blinkt.set_pixel(j, 255, 0, 0)

        blinkt.show()
        time.sleep(0.1)

        for j in range(blinkt.NUM_PIXELS):
            blinkt.set_pixel(j, 0, 0, 0)

        blinkt.show()
        time.sleep(0.2)
예제 #23
0
def flash(duration, intensity):
    """
    This flashes the lights for a certain duration then shuts them off.
    :param duration: in seconds, duration of the flash
    :param intensity:  intensity of the flash, bounded [0,1]
    """
    clear()
    set_brightness(intensity)
    set_all(R, G, B)
    show()
    time.sleep(duration)
    clear()
    show()
예제 #24
0
def trace(current_led, r, g, b, direction):
    clear()
    if direction == "forwards":
        #three lights on at once, front light is brighter than back light
        single_led(current_led, r, g, b, 1)
        single_led(current_led - 1, r, g, b, 0.5)
        single_led(current_led - 2, r, g, b, 0.1)
    else:
        #inverts the direction of the three lights
        single_led(current_led, r, g, b, 1)
        single_led(current_led + 1, r, g, b, 0.5)
        single_led(current_led + 2, r, g, b, 0.1)
    show()
예제 #25
0
def blink_blinkt(rgb_tuple):
    try:
        set_all(*rgb_tuple)
    except Exception as e:
        set_all(255, 255, 255)
        with open("log.txt", "a") as f:
            f.write(e + "\n")

    set_brightness(1)
    show()
    time.sleep(0.2)
    clear()
    show()
예제 #26
0
def rainbow(duration, brightness):
    spacing = 360.0 / 16.0
    set_brightness(brightness)
    start = time.time()
    while should_it_continue(start, duration):
        hue = int(time.time() * 100) % 360
        for x in range(8):
            offset = x * spacing
            h = ((hue + offset) % 360) / 360.0
            r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)]
            set_pixel(x, r, g, b)
        show()
        time.sleep(0.01)
예제 #27
0
def fog(r, g, b):
    import random
    for i in range(150):
        pixels = random.sample(range(blinkt.NUM_PIXELS), random.randint(1, 5))
        for i in range(blinkt.NUM_PIXELS):
            if i in pixels:
                blinkt.set_pixel(i, r, g, b) # change colour in the last 3 digits here
            else:
                blinkt.set_pixel(i, 0, 0, 0)
        blinkt.show()
        time.sleep(0.05)
        blinkt.clear()
        blinkt.show()
예제 #28
0
파일: lightshow.py 프로젝트: pokkrap/papy
def dance():
    for i in xrange(100):
        clear()
        l= [[0, 2, 4, 6], [1, 3, 5, 7]]
        poslist=l[i%2]
        for pos in poslist:
        #poslist is a set of positions of pixels
            r=0
            g=255-pos*32
            b=pos*32
            set_pixel(pos, r, g, b)
        show()
        time.sleep(0.1)
def show_n(n):
    for i in range(8):
        set_pixel(i, 0, 0, 0)
    show()
    sleep(1)
    for i in range(8):
        if n > i:
            set_pixel(i, 0, 0, 255)
        else:
            set_pixel(i, 0, 0, 0)
        show()
        sleep(1)
    sleep(1)
예제 #30
0
def zip_zip(flash_count, color):
    all_off()
    for index in range(flash_count):
        for y in range(4):
            lights.set_pixel(y, color[0], color[1], color[2])
            lights.set_pixel(7 - y, color[0], color[1], color[2])
            lights.show()
            time.sleep(.1)
        for y in range(4):
            lights.set_pixel(y, BLACK[0], BLACK[1], BLACK[2])
            lights.set_pixel(7 - y, BLACK[0], BLACK[1], BLACK[2])
            lights.show()
            time.sleep(.1)
예제 #31
0
def rainbow(lock, stop):
    spacing = 360.0 / 16.0
    with lock:
        while not stop.is_set():
            hue = int(time.time() * 100) % 360
            for x in range(blinkt.NUM_PIXELS):
                offset = x * spacing
                h = ((hue + offset) % 360) / 360.0
                r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)]
                blinkt.set_pixel(x, r, g, b)
            blinkt.show()
            time.sleep(0.001)
        blinkt.clear()
예제 #32
0
def show_graph(v, r, g, b):
    v *= 8
    for x in range(8):
        hue = ((hue_start + ((x/8.0) * hue_range)) % 360) / 360.0
        r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(hue,1.0,1.0)]
        if v  < 0:
            brightness = 0
        else:
            brightness = min(v,1.0) * max_brightness
        set_pixel(x, r, g, b, brightness)
        v -= 1

    show()
예제 #33
0
def alarm():
    for o in range(10):
        set_brightness(1)
        for i in range(8):
            set_pixel(i, 255, 0, 0)
            show()
            #time.sleep(0.05)
        time.sleep(0.2)
        for i in range(8):
            set_pixel(i, 0, 0, 255)
            show()
        time.sleep(0.2)
    off()
예제 #34
0
def unknown():
    set_brightness(1)
    last = 0
    for i in range(8):
        if i % 3 == 0:
            set_pixel(last, 0, 0, 0)
            last = i
            set_pixel(i, 255, 0, 255)
            show()
            time.sleep(0.5)
    for i in range(8):
        set_pixel(i, 0, 0, 0)
        show()
예제 #35
0
def light_up():
    for pixel in range(8):
        r = randint(0, 255)
        g = randint(0, 255)
        b = randint(0, 255)
        set_pixel(pixel, r, g, b)
        show()
        sleep(0.1)

    sleep(1)
    clear()
    # must call this to turn lights off
    show()
예제 #36
0
 def show_graph(v, r, g, b):
     v *= blinkt.NUM_PIXELS
     for x in range(blinkt.NUM_PIXELS):
         hue = ((hue_start + (
             (x / float(blinkt.NUM_PIXELS)) * hue_range)) % 360) / 360.0
         r, g, b = color
         if v < 0:
             brightness = 0
         else:
             brightness = min(v, 1.0) * max_brightness
         blinkt.set_pixel(x, r, g, b, brightness)
         v -= 1
     blinkt.show()
예제 #37
0
def pulse():
    clear()
    set_brightness(0.05)
    set_pixel(3, 2, 103, 193)
    set_pixel(4, 2, 103, 193)
    show()
    time.sleep(0.05)
    set_pixel(3, 2, 103, 193)
    set_pixel(4, 2, 103, 193)
    set_pixel(2, 2, 103, 193)
    set_pixel(5, 2, 103, 193)
    show()
    time.sleep(0.05)
    set_pixel(3, 2, 103, 193)
    set_pixel(4, 2, 103, 193)
    set_pixel(2, 2, 103, 193)
    set_pixel(5, 2, 103, 193)
    set_pixel(1, 2, 103, 193)
    set_pixel(6, 2, 103, 193)
    show()
    time.sleep(0.05)
    set_pixel(3, 2, 103, 193)
    set_pixel(4, 2, 103, 193)
    set_pixel(2, 2, 103, 193)
    set_pixel(5, 2, 103, 193)
    set_pixel(1, 2, 103, 193)
    set_pixel(6, 2, 103, 193)
    set_pixel(0, 2, 103, 193)
    set_pixel(7, 2, 103, 193)
    show()
 async def scroll_leds_task(self):
     while True:
         if (self.scroll_leds):
             print("Scrolling leds")
             for i in range(8):
                 clear()
                 set_pixel(i, self.leds[i].r, self.leds[i].g,
                           self.leds[i].b)
                 show()
                 await asyncio.sleep(0.05)
             clear()
             show()
         else:
             await asyncio.sleep(.5)
예제 #39
0
def main():
    while True:
        cpu = cpu_percent()
        if cpu < 33:
            blinkt.set_all(0, 255, 0)
            print(str(cpu) + "%--green")
        elif cpu < 66:
            blinkt.set_all(210, 179, 27)
            print(str(cpu) + "%--yellow")
        else:
            blinkt.set_all(255, 0, 0)
            print(str(cpu) + "%--red")
        blinkt.show()
        sleep(5)
def light_up():
    '''random colors light up in a smooth linear fashion then stay lit for one second'''
    for pixel in range(8):
        r = randint(0, 255)
        g = randint(0, 255)
        b = randint(0, 255)
        set_pixel(pixel, r, g, b)
        show()
        sleep(0.1)

    sleep(1)
    clear()
    # must call this to turn lights off
    show()
예제 #41
0
 def throbbing(self):
     brightness = 1
     blinkt.set_brightness(bright_math(brightness))
     pixels = [*range(0, blinkt.NUM_PIXELS)
               ][-2:] + [*range(0, blinkt.NUM_PIXELS)][0:6]
     for pixel in pixels:
         blinkt.set_all(255, 0, 0)
         blinkt.set_pixel(pixel, 0, 0, 0)
         if pixel == blinkt.NUM_PIXELS - 1:
             blinkt.set_pixel(0, 0, 0, 0)
         else:
             blinkt.set_pixel(pixel + 1, 0, 0, 0)
         blinkt.show()
         time.sleep(0.5)
예제 #42
0
def led_line(interval, brightness, led, r, g, b, current_status):
    """Cause the lights to travel in a line
	and have brightness close to the normal distribution."""
    if led == 0 or led == 7:
        clear()
        set_pixel(led, r, g, b, (brightness / 20.0))
        show()
        custom_sleep(interval, current_status)

    elif led == 1 or led == 6:
        clear()
        set_pixel(led, r, g, b, (brightness / 10.0))
        show()
        custom_sleep(interval, current_status)

    elif led == 2 or led == 5:
        clear()
        set_pixel(led, r, g, b, (brightness / 5.0))
        show()
        custom_sleep(interval, current_status)

    elif led == 3 or led == 4:
        clear()
        set_pixel(led, r, g, b, brightness)
        show()
        custom_sleep(interval, current_status)
예제 #43
0
    def on_event(self, event, payload):

        self._logger.info("Received event " + event)

        if event == "CaptureStart":
            clear()
            set_all(255, 255, 255, 0.1)
            show()

        if event == "CaptureDone":
            clear()
            # Restore the progress
            self._set_progress(self._blinkt_progress)
            show()

        if event == "PrintDone":
            clear()
            for x in range(120):
                for n in range(8):
                    if x % 2 == 0:
                        set_pixel(n,0,0,0)
                    if x % 2 == 1:
                        set_pixel(n,0,255,0)
                show()
                time.sleep(0.05)
            clear()
            show()
예제 #44
0
    def show(self, latency=0):

        r, g, b = self.makeColor(latency)
        set_pixel(self.bit, r, g, b, config.light)
        show()
        # try and correct the pause to make ping test have a
        # frequency of once per configured pause moment
        time.sleep(float(config.pause) - (float(latency) / 1000.0))
        set_pixel(self.bit, r, g, b, config.dim)
        show()
        if config.LR:
            self.bit = self.bit + 1 if self.bit < 7 else 0
        else:
            self.bit = self.bit - 1 if self.bit > 0 else 7
예제 #45
0
def rainbowit():
	spacing = 360.0 / 16.0
	hue = 0
	blinkt.set_brightness(0.1)
	
	for i in range(500):	
		hue = int(time.time() * 100) % 360
		for x in range(8):
			offset = x * spacing
			h = ((hue + offset) % 360) / 360.0
			r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)]
			blinkt.set_pixel(x, r, g, b)
		blinkt.show()
		time.sleep(0.001)
def fade_count(n, r, g, b, fast=None, bright=1.0):
  if fast is None:
    delay=0.125
  else: 
    delay=0.0625

  for j in range (n):
    for i in range(8):
      set_pixel(i, r, g, b, bright)
      show()
      sleep(delay)
    for i in range(8):
      set_pixel(i, 0, 0, 0, bright)
      show()
      sleep(delay)
예제 #47
0
def kit_chase(colour, iterations=100, fade=6, delay=0.1, background=(0,0,0)):
    current_pixel = 0
    decrement = 100.0** (1 / float(fade))
    level = [0.0 for x in range(8)]
    step = -1
    for _ in range(iterations):
        if current_pixel % 7 == 0:
            step = 0 - step  
        level = [max(x / decrement, 0) for x in level]
        level[current_pixel] = 1.0
        for pixel in range(8):
           set_pixel(pixel, *colour, brightness=level[pixel])
        show()
        print("{0:d} :  {1:1.2f} {2:1.2f} {3:1.2f} {4:1.2f} {5:1.2f} {6:1.2f} {7:1.2f} {8:1.2f}".format(current_pixel, *level))
        current_pixel += step
        sleep(delay)
예제 #48
0
	def setleds(self, state):
#		blinkt.set_all(state,state,state)	# params are r,g,b
		blinkt.set_pixel(0,state,state,state)	# params are r,g,b
		if state > 10:
			blinkt.set_pixel(1,state,state,state)	# params are r,g,b
		else:
			blinkt.set_pixel(1,0,0,0)		
		if state > 20:
			blinkt.set_pixel(2,state,state,state)	# params are r,g,b
		else:
			blinkt.set_pixel(2,0,0,0)		
		if state > 30:
			blinkt.set_pixel(3,state,state,state)	# params are r,g,b
		else:
			blinkt.set_pixel(3,0,0,0)		
		blinkt.show()
		return(0)
예제 #49
0
    def on_ble_write(self, *args, **kwargs):
        try:
            # bytes=[0x07, 0x02, 0x00, 0x01, 0x00, 0x0FF, 0x00]
            bytes = args[1]["Value"]
            if len(bytes) > 2:
                cmd = (bytes[0] << 8) + (bytes[1] & 0xff)

                if cmd == 0x0702:
                    if len(bytes) >= 7:
                        set_pixel(bytes[3] - 1, bytes[4], bytes[5], bytes[6])
                elif cmd == 0x0601:
                    if len(bytes) >= 5:
                        set_all(bytes[2], bytes[3], bytes[4])
                show()
        except Exception as inst:
            print(type(inst))
            print(inst.args)
            print(inst)
        return 0
def main(brightness, update_interval, blink_rate=0.1):
    tfl_status_obj = tubestatus.Status()
    should_blink = True

    while True:
        update_line_statuses(tfl_status_obj)

        # update LEDS
        for x in range(0, int(update_interval/blink_rate), 1):
            set_brightness(brightness)
            for line, line_desc in CONFIG.iteritems():
                if line_desc["open"]:
                    if line_desc["status"] != GOOD_SERVICE:
                        set_led_status(line_desc, should_blink)
                    else:
                        set_led_status(line_desc, True)

            show()
            sleep(blink_rate)
            should_blink = not should_blink
예제 #51
0
파일: mqtt.py 프로젝트: RogueM/blinkt
def on_message(client, userdata, msg):

    data = msg.payload.split(',')
    command = data.pop(0)

    if command == "clr" and len(data) == 0:
        clear()
        show()
        return

    if command == "rgb" and len(data) == 4:
        try:
            pixel = data.pop(0)

            if pixel == "*":
                pixel = None
            else:
                pixel = int(pixel)
                if pixel > 7:
                    print("Pixel out of range: " + str(pixel))
                    return

            r, g, b = [int(x) & 0xff for x in data]

            print(command, pixel, r, g, b)

        except ValueError:
            print("Malformed command: " + str(msg.payload))
            return

        if pixel is None:
            for x in range(8):
                set_pixel(x, r, g, b)
        else:
            set_pixel(pixel, r, g, b)

        show()
        return
예제 #52
0
def random_pulse(r,g,b):
  px = random.randint(0,7)
  for pct in range(0, 100, 10):
    set_pixel(px, lum(r,pct), lum(g,pct), lum(b,pct))
    show()
    time.sleep(0.02)
  set_pixel(px, lum(r,90), lum(g,90), lum(b,90))
  show()
  time.sleep(0.02)
  set_pixel(px, lum(r,80), lum(g,80), lum(b,80))
  show()
  time.sleep(0.02)
예제 #53
0
def BlinktManager():
  #time.sleep(20)
  localBrightness=globalBrightness
  while not globalShutdown:  
    spacing = 360.0 / 16.0
    hue = 0
    if localBrightness!=globalBrightness:
      blinkt.set_brightness(globalBrightness)
      localBrightness=globalBrightness
    if globalResponse=='pulse':
      for z in list(range(1, 10)[::-1]) + list(range(1, 10)):
        fwhm = 5.0/z
        gauss = make_gaussian(fwhm)
        start = time.time()
        y = 4
        for x in range(blinkt.NUM_PIXELS):
          h = 0.5
          s = 1.0
          v = gauss[x, y]
          rgb = colorsys.hsv_to_rgb(h, s, v)
          r, g, b = [int(255.0 * i) for i in rgb]
          blinkt.set_pixel(x, r, g, b)
	blinkt.show()
        end = time.time()
        t = end - start
        if t < 0.04:
          time.sleep(0.04 - t)
	time.sleep(0.15)
    elif globalResponse=='rainbow':
      hue = int(time.time() * 100) % 360
      for x in range(blinkt.NUM_PIXELS):
        offset = x * spacing
        h = ((hue + offset) % 360) / 360.0
        r, g, b = [int(c*255) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)]
        blinkt.set_pixel(x,r,g,b)
      blinkt.show()
      time.sleep(0.15)
    elif globalResponse=='solid':
      blinkt.set_all(255, 255, 255)
      print "solid"
      time.sleep(3)
    elif globalResponse=='off':
      blinkt.set_all(0, 0, 0)
      time.sleep(3)
    blinkt.show()
예제 #54
0
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
예제 #55
0
파일: rgb.py 프로젝트: RogueM/blinkt
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()
예제 #56
0
def process_event(event, device_id):
    """Pretty prints events.
    Prints all events that occur with two spaces between each new
    conversation and a single space between turns of a conversation.
    Args:
        event(event.Event): The current event to process.
    """
    if event.type == EventType.ON_CONVERSATION_TURN_STARTED:
        subprocess.Popen(["aplay", "/home/pi/GassistPi/sample-audio-files/Fb.wav"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        #Uncomment the following after starting the Kodi
        #status=mutevolstatus()
        #vollevel=status[1]
        #with open('/home/pi/.volume.json', 'w') as f:
               #json.dump(vollevel, f)
        #kodi.Application.SetVolume({"volume": 0})
        GPIO.output(5,GPIO.HIGH)
        led.ChangeDutyCycle(100)
        print()
    print(event)

    if (event.type == EventType.ON_RESPONDING_STARTED and event.args and not event.args['is_error_response']):
       GPIO.output(5,GPIO.LOW)
       GPIO.output(6,GPIO.HIGH)
       led.ChangeDutyCycle(50)

    if event.type == EventType.ON_RESPONDING_FINISHED:
       GPIO.output(6,GPIO.LOW)
       GPIO.output(5,GPIO.HIGH)
       led.ChangeDutyCycle(100)

    print(event)

    if (event.type == EventType.ON_CONVERSATION_TURN_FINISHED and
            event.args and not event.args['with_follow_on_turn']):
        GPIO.output(5,GPIO.LOW)
        led.ChangeDutyCycle(0)
        #Uncomment the following after starting the Kodi
        #with open('/home/pi/.volume.json', 'r') as f:
               #vollevel = json.load(f)
               #kodi.Application.SetVolume({"volume": vollevel})
        print()

    if event.type == EventType.ON_DEVICE_ACTION:
        for command, params in process_device_actions(event, device_id):
            print('Do command', command, 'with params', str(params))
            if command=='action.devices.commands.OnOff':
                if params['on']:
                    blinkt.set_all(255, 255, 255,brightness=0.05)
                    blinkt.show()
                else:
                    blinkt.clear()
                    blinkt.show()
            if command=='action.devices.commands.ColorAbsolute':
                r,g,b=colourconv(params['color']['spectrumRGB'])
                print(r,g,b)
                blinkt.set_all(r,g,b)
                blinkt.show()
            if command=='action.devices.commands.BrightnessAbsolute':
                bright=(params['brightness'])/100
                blinkt.set_brightness(bright)
                blinkt.show()
def blinkt_all(r,g,b):
    for i in range (8):
        set_pixel(i, r, g, b)
    show()
예제 #58
0
def display_blank():
    clear()
    show()
def clear(*args):
    for line, line_desc in CONFIG.iteritems():
        turn_led_off_for(line)
    show()
    sys.exit(0)