Пример #1
0
def solid():
    global animateStop
    animateStop = False
    step = 0
    while not animateStop:
        if step == 0: ledshim.set_all(128, 0, 0)
        if step == 1: ledshim.set_all(0, 128, 0)
        if step == 2: ledshim.set_all(0, 0, 128)
        step += 1
        step %= 3
        ledshim.show()
        time.sleep(0.5)
Пример #2
0
filename = sys.argv[1]
r = png.Reader(filename)
r.asRGB8()  # Forced 8 bit RGB (fail if Alpha is present)
t = r.read()

ll = list(t[2])  # Pixels data in boxed row flat pixel format

line_number = 0

while (True):
    line = ll[line_number]  # Take one line
    i = 0
    pixel = 0
    if t[0] == 1:
        r, g, b = line
        ledshim.set_all(r, g, b)
    else:
        for value in line:
            if pixel < ledshim.NUM_PIXELS:
                if i % 3 == 0:
                    r = value
                if i % 3 == 1:
                    g = value
                if i % 3 == 2:
                    b = value
                    ledshim.set_pixel(pixel, r, g, b)
                    pixel = pixel + 1
            i = i + 1
    ledshim.show()
    time.sleep(0.001)
    line_number = line_number + 1
Пример #3
0
 def set_all(self, color):
     ledshim.set_all(*color)
Пример #4
0
#!/usr/bin/env python

import time

import ledshim

ledshim.set_clear_on_exit()

step = 0

while True:
    if step == 0:
        ledshim.set_all(128, 0, 0)

    if step == 1:
        ledshim.set_all(0, 128, 0)

    if step == 2:
        ledshim.set_all(0, 0, 128)

    step += 1
    step %= 3
    ledshim.show()
    time.sleep(0.5)
Пример #5
0
import requests
import msal
import ledshim

# Optional logging
logging.basicConfig(level=logging.INFO)
logging.info(time.ctime() + " Starting")

# set led colors:
green = (0, 255, 0, .5)
red = (255, 0, 0, .5)
blue = (0, 0, 255, .5)
none = (24, 255, 255, 255, .25)

# led blink so we know we've started
ledshim.set_all(255, 255, 255, .5)
ledshim.show()
time.sleep(0.5)
ledshim.clear()
ledshim.set_pixel(24, 255, 255, 255, .5)
ledshim.show()

logging.info(time.ctime() + " Loading config")
config = json.load(open(sys.argv[1]))

# Create a preferably long-lived app instance which maintains a token cache.
logging.info(time.ctime() + " Getting token")
app = msal.PublicClientApplication(
    config["client_id"],
    authority=config["authority"],
    # token_cache=...  # Default cache is in memory only.