Created
May 20, 2019 20:06
-
-
Save brbcoding/79c4cacfc5ebc7334690c05b9ea67ac5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import datetime | |
import threading | |
from calendar import Calendar, Event, make_time | |
from threading import Thread | |
from flask import Flask | |
app = Flask(__name__) | |
# CONFIGS | |
RENDER_FPS = 60 | |
UPDATE_SEC = 1 | |
prev_event = Event(make_time(-60), make_time(-30)) | |
curr_event = Event(make_time(-10), make_time(0.1)) | |
next_event = Event(make_time(2), make_time(2.5)) | |
cal = Calendar([prev_event, curr_event, next_event]) | |
new_next_event = Event(make_time(1), make_time(1.5)) | |
cal.add_event(new_next_event) | |
# update lights and anything that needs to be rendered at a set FPS | |
class render(Thread): | |
def run(self): | |
while True: | |
time.sleep(1 / RENDER_FPS) | |
# update states if meeting window changes | |
class poll_updates(Thread): | |
def run(self): | |
while True: | |
time.sleep(UPDATE_SEC) | |
cal.update() | |
@app.route("/") | |
def index(): | |
return "Hello, World!" | |
if __name__ == '__main__': | |
render().start() | |
poll_updates().start() | |
app.run(debug=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment