diff --git a/test.py b/test.py index 06531b3..ab89111 100644 --- a/test.py +++ b/test.py @@ -2,8 +2,11 @@ import epaper import microbmp import time import random +import os import gc +gc.enable() + epd_resolution = [600, 448] epd_colormap = [ [0x00, 0x00, 0x00], # black @@ -15,9 +18,7 @@ epd_colormap = [ [0xff, 0x77, 0x00], # orange ] -images = ["lambo.bmp", "fallout.bmp", "nasa.bmp"] - -gc.enable() +images = list(filter(lambda x : x.endswith(".bmp"), os.listdir())) def init_display(): #print("ePaper init ", str(time.localtime())) @@ -71,24 +72,29 @@ def draw_image(filename): #for i in range(len(colors)): # epd.pixel(offset_x + x + i, offset_y + y, color_to_index(colors[i])) - print(str(time.localtime()), " BMP ", filename, " loading") + #print(str(time.localtime()), " BMP ", filename, " loading") + time_start = time.ticks_ms() epd.fill(epd.White) microbmp.MicroBMP(header_callback=header_callback, data_callback=pixel_callback).load(filename) - print(str(time.localtime()), " BMP loaded") + time_loaded = time.ticks_ms() + print(" time to load: ", (time_loaded - time_start) / 1000, " s") + #print(str(time.localtime()), " BMP loaded") epd.EPD_5IN65F_Display(epd.buffer) - print(str(time.localtime()), " ePaper printed") + #print(str(time.localtime()), " ePaper printed") + time_finished = time.ticks_ms() + print(" time to render: ", (time_finished - time_loaded) / 1000, " s") # MAIN epd = init_display() -while True: - for filename in images: - epd.EPD_5IN65F_Init() - print("TV loading image ", filename) - draw_image(filename) - epd.Sleep() - print("TV showing ", filename) - gc.collect() - epd.delay_ms(10000) +while True: + epd.EPD_5IN65F_Init() + filename = random.choice(images) + print("TV loading image ", filename) + draw_image(filename) + print("TV showing ", filename) + epd.Sleep() + gc.collect() + epd.delay_ms(10000)