예제 #1
0
def report_status():
    pixel_status = []
    for i in range(NUM_PIXELS):
        pixel_status.append(
            dict(Pixel=i,
                 Status=dict(
                     zip(["Red", "Green", "Blue", "Brightness"],
                         get_pixel(i)))))
    data = {"status": 200, "message": pixel_status}

    return jsonify(
        data
    )  # This ruins the order of keys for humans. JSON doesn't care, and neither do we.
def set_pixel_if_blank(led_index, red_on, green_on, blue_on, brightness_on):
    [red_current, green_current, blue_current, _] = get_pixel(led_index)
    if red_current == 0 and green_current == 0 and blue_current == 0:
        set_pixel(led_index, red_on, green_on, blue_on, brightness_on)
예제 #3
0
def ledGet(p):
    return blinkt.get_pixel(p)
예제 #4
0
def getColor() :
	status = blinkt.get_pixel(0)
	return status
예제 #5
0
파일: kitt.py 프로젝트: druck13/blinkt
TIME_SLEEP = 0.04    # seconds (0.04 works well)

PIXELS = blinkt.NUM_PIXELS  # usually 8, can use fewer if you like!

blinkt.clear         # make all pixels blank / black
blinkt.set_brightness(BRIGHTNESS)

brightpixel = -1
direction = 1

print('Hello Michael.\nHow are you today?')

while True:
    # decay all pixels
    for x in range(PIXELS):
        pixel = blinkt.get_pixel(x)  # format is [ r, g, b, brightness? ]
        blinkt.set_pixel(x, pixel[0] / DECAY_FACTOR, 0, 0)

    # brightpixel should move back and forth all the pixels,
    # in a ping-pong, triangle wave. Not (co)sine.
    brightpixel += direction

    if brightpixel >= PIXELS - 1:
        brightpixel = PIXELS - 1
        direction = - abs(direction)
    if brightpixel <= 0:
        brightpixel = 0
        direction = abs(direction)

    blinkt.set_pixel(brightpixel, MAX_COLOUR, 0, 0)
예제 #6
0
 def getBrightness(self):
     r, g, b, brightness = blinkt.get_pixel(0)
     return brightness
예제 #7
0
 def getColor(self):
     r, g, b, brightness = blinkt.get_pixel(0)
     return r, g, b
예제 #8
0
 def HandleFlash(self, led, color, time_ms):
     previous = blinkt.get_pixel(led)
     self.HandleOn(led, color)
     time.sleep(time_ms / 1000)
     self.HandleOn(led, previous[:3]) # first 3 items are the color values