def doSomething(sizex, sizey, udpHostsAndPorts=[], console_out=True, api_defaults=False, update_interval=0, clean_all=False): if len(udpHostsAndPorts) != 0: flipdot_matrix = FlipdotMatrix(udpHostsAndPorts, (sizex, sizey)) flipdot_out = True elif api_defaults: flipdot_matrix = FlipdotMatrix(imageSize=(sizex, sizey)) flipdot_out = True else: flipdot_matrix = None flipdot_out = False if clean_all == True: clean_flipdot(sizex, sizey, flipdot_matrix, flipdot_out, console_out) return pixel_matrix = generateEmptyMatrix(sizex, sizey) # Your code here for x in range(sizex): pixel_matrix[x][sizey - 1] = 1 show(pixel_matrix, flipdot_matrix, flipdot_out, console_out, sizex, sizey)
def __init__(self, sizex=144, sizey=120, radius=50, udpHostsAndPorts=[], hour_hand=True, minute_hand=True, second_hand=True, console_out=False, run_once=False, update_interval=0, api_defaults=False): if len(udpHostsAndPorts) != 0: self.matrix = FlipdotMatrix(udpHostsAndPorts, (sizex, sizey)) self.flipdot_out = True elif api_defaults: self.matrix = FlipdotMatrix(imageSize=(sizex, sizey)) self.flipdot_out = True else: self.matrix = None self.flipdot_out = False self.sizex = sizex self.sizey = sizey self.radius = radius self.center = (int(self.sizex / 2), int(self.sizey / 2)) self.hour_hand = hour_hand self.minute_hand = minute_hand self.second_hand = second_hand self.console_out = console_out self.update_interval = update_interval if update_interval != 0 else ( 1 if self.second_hand else 30) self.run_once = run_once
def main_loop(sizex, sizey, udpHostsAndPorts=[], console_out=False, api_defaults=False, update_interval=0): if len(udpHostsAndPorts) != 0: flipdot_matrix = FlipdotMatrix(udpHostsAndPorts, (sizex, sizey)) flipdot_out = True elif api_defaults: flipdot_matrix = FlipdotMatrix(imageSize=(sizex, sizey)) flipdot_out = True else: flipdot_matrix = None flipdot_out = False pixel_matrix = generateEmptyMatrix(sizex, sizey) try: while True: pixel_matrix = step(pixel_matrix, sizex, sizey) if console_out: printToConsole(pixel_matrix, sizex, sizey) if flipdot_out: flipImage = FlipdotImage( prepareMatrixForAPI(pixel_matrix, sizex, sizey)) matrix.show(flipImage, sizex, sizey) sleep(update_interval) except KeyboardInterrupt: return
def run_once(old_html=""): html = getHtml()[0:1000] if (html != old_html): matrix = FlipdotMatrix() # html = "wiki.muc.ccc.de/flipdot:32c3\n"+html matrix.showText("wiki.muc.ccc.de/flipdot:33c3\n" + html) return html
def __init__(self, sizex=144, sizey=120, speed=30, udpHostsAndPorts=[], console_out=False, invert=False): Thread.__init__(self) self.flipmatrix = FlipdotMatrix( udpHostsAndPorts, (sizex, sizey)) if len(udpHostsAndPorts) != 0 else None self.sizex = sizex self.sizey = sizey self.sizez = 100 self.speed = speed self.flipdot_out = len(udpHostsAndPorts) != 0 self.console_out = console_out self.invert = invert self.camera = (0, int(self.sizey / 3), -int(self.sizez / 2)) self.plain_offset = (-int(self.sizex / 2), -int(self.sizey / 2)) self.obstacles = [] self.car = Car(0, 0, int(self.sizez / 4), int(self.sizex / 7), int(self.sizey / 7)) self.direction = 0 self.lost = False self.stop = False self.pause = False
def __init__(self, size, speed, udpHostsAndPorts=[], console_out=False, invert=False, panel_defaults=False, ball_speed=6, player_speed=3, scores_file="scores"): self.size = size self.speed = speed bar_size = (round(self.size[0] / 18), round(self.size[1] / 5)) ball_size = (round(self.size[0] / 18), round(self.size[0] / 18)) self.scores_file = scores_file total_scores = self.loadScores() self.players = (Player( bar_size, (round(self.size[0] / 18), round(self.size[1] / 2)), speed=player_speed, total_score=total_scores[0]), Player(bar_size, (self.size[0] - round(self.size[0] / 18), round(self.size[1] / 2)), speed=player_speed, total_score=total_scores[1])) self.inputHandler = InputHandler(self.players) self.ball = Ball(ball_size, self.get_center(), speed=ball_speed) self.stop = False self.flipmatrix = FlipdotMatrix( imageSize=size) if panel_defaults else ( FlipdotMatrix(udpHostsAndPorts, size) if len(udpHostsAndPorts) != 0 else None) self.flipdot_out = True if self.flipmatrix else False self.console_out = console_out self.invert = invert
# seconds per frame TICK_TIME = 0.7 # round time. put this game in an outside while loop and just restart it ROUND_TIME = 600 # reserved pixels at the top TOP = 20 WIDTH = 80 HEIGHT = 16 matrix = FlipdotMatrix( udpHostsAndPorts=[ ("flipdot.openlab.lan", 2323), ], imageSize=(WIDTH, HEIGHT), transposed=True, ) class Player(object): def __init__(self, game, player_id): self.game = game self.player_id = player_id self.reset() def reset(self): self.x = random.randint(20, self.game.width - 1 - 20) self.y = random.randint(TOP + 20, self.game.height - 1 - 20) self.dir = random.randint(0, 3)
PORT = 8080 # seconds per frame TICK_TIME = 0.7 # round time. put this game in an outside while loop and just restart it ROUND_TIME = 600 # reserved pixels at the top TOP = 20 WIDTH = 144 HEIGHT = 120 matrix = FlipdotMatrix( imageSize=(WIDTH, HEIGHT), transposed=False, ) class Player(object): def __init__(self, game, player_id): self.game = game self.player_id = player_id self.reset() def reset(self): self.x = random.randint(20, self.game.width - 1 - 20) self.y = random.randint(TOP + 20, self.game.height - 1 - 20) self.dir = random.randint(0, 3) self.path = []
#!/usr/bin/env python3 import base64 from io import BytesIO from flask import Flask from flask import redirect, render_template, request from FlipdotAPI.FlipdotMatrix import FlipdotMatrix, FlipdotImage wandwidth = 144 wandheight = 120 app = Flask(__name__) matrix = FlipdotMatrix(imageSize=(wandwidth, wandheight), ) def minipage(msg): return "<html><head><title>FlipdotDebugPage</title></head><body <body style='font-size:6vh; line-height:2em;'><h3>" + msg + "</h3><ul><li><a href='/reset'>reset all</a></li><li><a href='/white'>white</a></li><li><a href='/black'>black</a></li><li><a href='/chess'>chess</a></li><li><a href='/static/flipdot-web-editor/index.html'>Image App</a></li></ul></body></html>" @app.route("/") def hello(): return minipage("") @app.route("/reset") def reset(): matrix.resetAll() return minipage("reseted all") @app.route("/black")
def __init__(self, text): self.matrix = FlipdotMatrix(imageSize=(144,120)) self.text = text
TICK_TIME = 0.7 # round time. put this game in an outside while loop and just restart it ROUND_TIME = 600 # reserved pixels at the top TOP = 20 WIDTH = 144 HEIGHT = 120 matrix = FlipdotMatrix( udpHostsAndPorts = [ ("2001:67c:20a1:1063:ba27:ebff:fe86:8697", 5555), ("2001:67c:20a1:1063:ba27:ebff:fe23:60d7", 5555), ("2001:67c:20a1:1063:ba27:ebff:fe71:dd32", 5555), ], imageSize = (WIDTH, HEIGHT), transposed = True, ) class Player(object): def __init__(self, game, player_id): self.game = game self.player_id = player_id self.reset() def reset(self): self.x = random.randint(20, self.game.width-1-20) self.y = random.randint(TOP + 20, self.game.height-1-20) self.dir = random.randint(0, 3)
def __init__(self, flipdotMatrix=FlipdotMatrix(), uberbusHostAndPort=("uberbus.club.muc.ccc.de", 8080)): self.__flipdotMatrix = flipdotMatrix self.__uberbusHostAndPort = uberbusHostAndPort self.__oldHqStatus = ""