import epaper import microbmp import time import random import os import storage import display import gc gc.enable() epd = display.init_display() disk = storage.Storage() while True: disk.mount() images = list(filter(lambda x : x.endswith(".bmp"), os.listdir(disk.get_root_path()))) epd.EPD_5IN65F_Init() epd.fill(epd.White) filename = random.choice(images) print("TV drawing image ", filename) free_space = [0,0,0,0] try: free_space = display.draw_image(epd, disk.get_root_path() + "/" + filename) except Exception as e: print("Failed drawing image from disk: ", e) try: free_space = display.draw_image(epd, "tiny.bmp") except Exception as e: print("Failed drawing fallback image: ", e) free_space = display.draw_pattern(epd) caption = None try: caption = storage.load_joke(disk.get_root_path()) except Exception as e: print("Failed loading a joke: ", e) try: display.draw_extra(epd, free_space, caption) except Exception as e: print("Failed drawing extra: ", e) time_render_start = time.ticks_ms() epd.EPD_5IN65F_Display(epd.buffer) time_render_stop = time.ticks_ms() print(" time to render: ", (time_render_stop - time_render_start) / 1000, " s") print("TV showing ", filename) epd.Sleep() disk.umount() print("") gc.collect() epd.delay_ms(60000 * 10)