from iris_api import Timetable

from src.image import create_image

import fire

import cv2
import time

def main(eva=None):
    eva = 8002377 if eva is None else eva
    # eva = 8098263
    # eva = 8004158

    cv2.namedWindow("fs", cv2.WND_PROP_FULLSCREEN)
    cv2.setWindowProperty("fs", cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
    # cv2.moveWindow("fs", -1920, 0)

    tt = Timetable(eva=eva)

    while True:
        start = time.time()
        tt.get_stops()
        img = create_image(tt)
        cv2.imshow("fs", img)

        if cv2.waitKey(1) & 0xFF == ord("q"):
            break

        elapsed = time.time() - start
        time.sleep(max(0, 1.0 - elapsed))

    cv2.destroyAllWindows()


if __name__ == "__main__":
    fire.Fire(main)
