示例#1
0
文件: black.py 项目: jacoby/InkyTools
def cleaner():
    colours = (inkyphat.RED, inkyphat.BLACK, inkyphat.WHITE)
    for c in enumerate(colours):
        inkyphat.set_border(c)
        for x in range(inkyphat.WIDTH):
            for y in range(inkyphat.HEIGHT):
                inkyphat.putpixel((x, y), c)
    inkyphat.show()
示例#2
0
def clear_area(start_x, start_y, width, height):
    x = max(start_x, 0)
    y = max(start_y, 0)
    x_end = min(start_x + width, inkyphat.WIDTH - 1)
    y_end = min(start_y + height, inkyphat.HEIGHT - 1)

    for i in range(x, x_end):
        for j in range(y, y_end):
            inkyphat.putpixel((i, j), inkyphat.WHITE)
示例#3
0
def render(display):
    for x in range(inkyphat.WIDTH):
        for y in range(inkyphat.HEIGHT):
            inkyphat.putpixel((x, y), 0)

    for x in range(inkyphat.WIDTH):
        for y in range(inkyphat.HEIGHT):
            try:
                inkyphat.putpixel((x, y), display[y][x])
            except (IndexError):
                pass

    inkyphat.show()
示例#4
0
def iclearNow(col):  # claer inkyphat and refresh
    for x in range(212):
        for y in range(104):
            inkyphat.putpixel((x, y), col)
    inkyphat.show()
示例#5
0
def iclear(col):  # Clear inkyphat but don't refresh
    for x in range(212):
        for y in range(104):
            inkyphat.putpixel((x, y), col)
示例#6
0
if len(sys.argv) < 2:
    print("""Usage: {} <colour> <number of cycles>
       Valid colours: red, yellow, black
""".format(sys.argv[0]))
    sys.exit(0)

colour = sys.argv[1].lower()
inkyphat.set_colour(colour)

if len(sys.argv) > 2:
    cycles = int(sys.argv[2])
else:
    cycles = 3

colours = (inkyphat.RED, inkyphat.BLACK, inkyphat.WHITE)
colour_names = (colour, "black", "white")

for i in range(cycles):
    print("Cleaning cycle %i\n" % (i + 1))
    for j, c in enumerate(colours):
        print("- updating with %s" % colour_names[j])
        inkyphat.set_border(c)
        for x in range(inkyphat.WIDTH):
            for y in range(inkyphat.HEIGHT):
                inkyphat.putpixel((x, y), c)
        inkyphat.show()
        time.sleep(1)
    print("\n")

print("Cleaning complete!")