def animation_round(led: LEDObject, char: str, speed: int, hexcolor: str): if len(char) != 1: raise ValueError # Init led.off() if speed == None: speed = 1 if hexcolor == None: hexcolor = 'ffffff' for count, line in enumerate(led.round_painter[char]): for pixel in line: led.color(hexcolor, pixel) if count % speed == 0: led.show() time.sleep(0.001 / speed) led.show()
# TODO: 余裕があれば、実際にRaspberry Pi側から完了信号が届いてからnow_patternを更新 if led.running_pipe: runnning_pid = led.running_pipe.pid with open(CURRENT_DIRNAME + '/pid.log', mode='w') as logfile: logfile.write(str(runnning_pid)) return redirect('/') def main(): with open(CURRENT_DIRNAME + '/pid.log', 'r') as pid_log: running_pid = pid_log.read() if running_pid: print('KILL PROCESS') # debug subprocess.run(['sudo', 'kill', running_pid]) app.debug = True app.run(host='0.0.0.0', port=8080) if __name__ == '__main__': try: main() except Exception as e: print(e) led.off() if led.running_pipe: led.running_pipe.kill()