示例#1
0
def healthcheck():
    blink1_serials = Blink1.list()
    print(blink1_serials)
    if blink1_serials:
        return Response(f"Healthy; device connected: {blink1_serials[0]}",
                        status=200)
    else:
        return Response("Not Ready", status=503)
示例#2
0
#!/usr/bin/env python
"""
demo2 -- demo of blink1 library, accessing multiple blink(1) devices

"""

import time, sys
from blink1.blink1 import Blink1

blink1_serials = Blink1.list()
if blink1_serials:
    print("blink(1) devices found: " + ','.join(blink1_serials))
else:
    print("no blink1 found")
    sys.exit()

# To open a particular blink(1), do:
# blink1 = Blink1(serial_number=u'20006487')
print("opening first blink(1)")
blink1 = Blink1(serial_number=blink1_serials[0])  # first blink1
print("  serial number: " + blink1.get_serial_number())
print("  firmware version: " + blink1.get_version())

print("  playing green, purple, off...")
blink1.fade_to_rgb(500, 0, 255, 0)
time.sleep(0.5)
blink1.fade_to_rgb(500, 255, 0, 255)
time.sleep(0.5)
blink1.fade_to_rgb(500, 0, 0, 0)
time.sleep(0.5)
示例#3
0
 def __init__(self):
     blink1_serials = Blink1.list()
     self.serial = blink1_serials[0]
     self.blink1 = Blink1(serial_number=self.serial)