reformatted files to be pep8 compliant
updated .gitignore
This commit is contained in:
parent
666a377e32
commit
ef148dbbb6
4 changed files with 285 additions and 270 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
.env
|
||||
.idea
|
18
images.py
18
images.py
|
@ -5,7 +5,7 @@ When running this file it will randomly select a transition and a frame to trans
|
|||
# requires: python-fluepdot, python-dotenv
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
from src.fluepdot.fluepdot import Fluepdot, Mode
|
||||
from fluepdot import Fluepdot, Mode
|
||||
from random import choice, sample
|
||||
from itertools import product
|
||||
from time import sleep
|
||||
|
@ -34,12 +34,10 @@ flipdot_logo = [
|
|||
]
|
||||
|
||||
|
||||
fd1 = Fluepdot(f"http://{ip1}")
|
||||
#fd2 = Fluepdot(f"http://{ip2}", flipped=True)
|
||||
|
||||
def checkerboard(len_x: int, len_y: int, invert: bool = False) -> List[List[bool]]:
|
||||
return [[(j + i + invert) % 2 == 0 for i in range(len_x)] for j in range(len_y)]
|
||||
|
||||
|
||||
def droplet(fd: Fluepdot):
|
||||
max_x, max_y = fd.get_size()
|
||||
fd.set_mode(Mode.DIFFERENTIAL)
|
||||
|
@ -71,6 +69,7 @@ def droplet(fd: Fluepdot):
|
|||
sleep(ANIMATION_DELAY)
|
||||
fd.post_frame(frame)
|
||||
|
||||
|
||||
def fd_logo(fd: Fluepdot) -> List[List[bool]]:
|
||||
fd.post_text("flipdot e.V.", x=7, y=0, font="fixed_7x14")
|
||||
original_frame = fd.get_frame()
|
||||
|
@ -80,6 +79,7 @@ def fd_logo(fd: Fluepdot) -> List[List[bool]]:
|
|||
frame.append(new_row)
|
||||
return [[c == "X" for c in row] for row in frame]
|
||||
|
||||
|
||||
def kurhacken(fd: Fluepdot) -> List[List[bool]]:
|
||||
fd.post_text("Kurhecken", x=14, y=-2, font="fixed_10x20")
|
||||
frame = [[c == "X" for c in row] for row in fd.get_frame()]
|
||||
|
@ -88,21 +88,25 @@ def kurhacken(fd: Fluepdot) -> List[List[bool]]:
|
|||
frame[y][x] = True
|
||||
return frame
|
||||
|
||||
|
||||
def event37c3(fd: Fluepdot) -> List[List[bool]]:
|
||||
fd.post_text("37c3Unlocked", x=-1, y=-1, font="DejaVuSerif16")
|
||||
frame = [[c == "X" for c in row] for row in fd.get_frame()]
|
||||
return frame
|
||||
|
||||
|
||||
def event38c3(fd: Fluepdot) -> List[List[bool]]:
|
||||
fd.post_text("38C3 Illegal Instructions", font="DejaVuSerif16")
|
||||
frame = [[c == "X" for c in row] for row in fd.get_frame()]
|
||||
return frame
|
||||
|
||||
|
||||
def hackumenta(fd: Fluepdot) -> List[List[bool]]:
|
||||
fd.post_text("Hackumenta", x=3, y=-1, font="DejaVuSerif16")
|
||||
frame = [[c == "X" for c in row] for row in fd.get_frame()]
|
||||
return frame
|
||||
|
||||
|
||||
def wipe_to(fd: Fluepdot, frame: List[List[bool]]):
|
||||
fd.set_mode(Mode.DIFFERENTIAL)
|
||||
current = [[c == "X" for c in row] for row in fd.get_frame()]
|
||||
|
@ -114,6 +118,7 @@ def wipe_to(fd: Fluepdot, frame: List[List[bool]]):
|
|||
sleep(ANIMATION_DELAY)
|
||||
fd.post_frame(current)
|
||||
|
||||
|
||||
def dither_to(fd: Fluepdot, frame: List[List[bool]]):
|
||||
fd.set_mode(Mode.DIFFERENTIAL)
|
||||
max_x, max_y = fd.get_size()
|
||||
|
@ -132,6 +137,7 @@ def dither_to(fd: Fluepdot, frame: List[List[bool]]):
|
|||
if r.status_code != 200:
|
||||
print(r.text)
|
||||
|
||||
|
||||
def push_to(fd: Fluepdot, frame: List[List[bool]]):
|
||||
fd.set_mode(Mode.DIFFERENTIAL)
|
||||
current = [[c == "X" for c in row] for row in fd.get_frame()]
|
||||
|
@ -150,6 +156,7 @@ def push_to(fd: Fluepdot, frame: List[List[bool]]):
|
|||
continue
|
||||
break
|
||||
|
||||
|
||||
def roll_to(fd: Fluepdot, frame: List[List[bool]]):
|
||||
fd.set_mode(Mode.DIFFERENTIAL)
|
||||
current = [[c == "X" for c in row] for row in fd.get_frame()]
|
||||
|
@ -159,11 +166,12 @@ def roll_to(fd: Fluepdot, frame: List[List[bool]]):
|
|||
current.pop()
|
||||
fd.post_frame(current)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
load_dotenv()
|
||||
hostname = os.getenv("DOTS_HOST")
|
||||
fd = Fluepdot(f"http://{hostname}")
|
||||
fd1.clear()
|
||||
fd.clear()
|
||||
animations = [
|
||||
droplet,
|
||||
]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""
|
||||
Script for the flipdot recharge party animation
|
||||
"""
|
||||
# requires: python-fluepdot, python_dotenv
|
||||
# requires: python-fluepdot, python_dotenv, pillow
|
||||
import os
|
||||
from time import sleep
|
||||
from dotenv import load_dotenv
|
||||
|
@ -26,16 +26,17 @@ logo = """
|
|||
|
||||
"""
|
||||
|
||||
|
||||
# convert text to framebuffer format
|
||||
def textToFramebuffer(text: str, x: int = 0, y: int = 0, fontname: str = "DejaVuSans.ttf", size: int = 14) -> str:
|
||||
from PIL import Image, ImageFont, ImageDraw
|
||||
font = ImageFont.truetype(fontname, size)
|
||||
tw, th = font.getsize(text)
|
||||
_, _, tw, th = font.getbbox(text)
|
||||
while th >= 16:
|
||||
print(th)
|
||||
size -= 1
|
||||
font = ImageFont.truetype(fontname, size)
|
||||
tw, th = font.getsize(text)
|
||||
_, _, tw, th = font.getbbox(text)
|
||||
img = Image.new("1", (tw, 16), 0)
|
||||
draw = ImageDraw.Draw(img)
|
||||
draw.text((0, 0), text=text, font=font, fill=1)
|
||||
|
@ -51,6 +52,7 @@ def textToFramebuffer(text: str, x:int=0, y:int=0, fontname:str="DejaVuSans.ttf"
|
|||
def scrl_frm(frame, loop: bool or int = False) -> None:
|
||||
def _extend_frame(line: str) -> str:
|
||||
return line + (" " * loop) + line[0:115]
|
||||
|
||||
def _pad_frame(line: str) -> str:
|
||||
pad = " " * 115
|
||||
return pad + line + pad
|
||||
|
@ -70,6 +72,7 @@ def scrl_frm(frame, loop: bool or int = False) -> None:
|
|||
print(".\n".join(l[i:i + 115] for l in frame))
|
||||
sleep(.1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
load_dotenv()
|
||||
hostname = os.getenv("DOTS_HOST")
|
||||
|
|
|
@ -26,6 +26,7 @@ lightning=[" X ",
|
|||
" XXXX ",
|
||||
"XXXXXXXX "]
|
||||
|
||||
|
||||
def get_lightning(level: int) -> str:
|
||||
if level < 0:
|
||||
level = 0
|
||||
|
@ -41,6 +42,7 @@ def get_lightning(level: int) -> str:
|
|||
rtn = "\n".rjust(19) + rtn
|
||||
return rtn
|
||||
|
||||
|
||||
def get_battery(level: int) -> str:
|
||||
lightning = get_lightning(level).split("\n")[:-1]
|
||||
|
||||
|
@ -60,6 +62,7 @@ def get_battery(level: int) -> str:
|
|||
|
||||
return rtn
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
load_dotenv()
|
||||
hostname = os.getenv("DOTS_HOST")
|
||||
|
@ -67,13 +70,13 @@ if __name__=="__main__":
|
|||
fd.set_mode(Mode.DIFFERENTIAL)
|
||||
l, h = fd.get_size()
|
||||
while True:
|
||||
for i in range(0, 12):
|
||||
for i in range(0, len(lightning) * 2):
|
||||
bat = get_battery(i).split("\n")[:-1]
|
||||
bat = list(map(lambda x: x.rjust(l), bat))
|
||||
bat = "\n".join(bat) + "\n"
|
||||
fd.post_frame_raw(frame=bat)
|
||||
sleep(.5)
|
||||
for i in range(12, 0, -1):
|
||||
for i in range(len(lightning) * 2, 0, -1):
|
||||
bat = get_battery(i).split("\n")[:-1]
|
||||
bat = list(map(lambda x: x.rjust(l), bat))
|
||||
bat = "\n".join(bat) + "\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue