Choose random image from flash

This commit is contained in:
Dejvino 2023-04-20 06:12:41 +02:00
parent a5cc0634f6
commit 47f3038174

34
test.py
View File

@ -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,12 +72,17 @@ 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
@ -84,11 +90,11 @@ def draw_image(filename):
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)
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)