add debugging on pngdec

main
Paco Hope 2023-12-01 08:58:53 -05:00
parent 4ff4f3f122
commit fa601bee56
1 changed files with 12 additions and 3 deletions

View File

@ -35,14 +35,23 @@ global graphics
def display_image(j):
# Open the PNG file
j.open_file(CONFIG.FILENAME)
graphics.set_pen(0)
graphics.set_font('sans')
# Decode the PNG
j.decode()
try:
j.decode()
except Exception as e:
# if that fails, try to recover enough to show
# an error. This seems to fail sometimes and I
# don't know why.
del j
gc.collect()
graphics.text( e, 10, 200, scale=1 )
# write the date/time at the top
tz_seconds = (CONFIG.TZ_OFFSET * 3600)
year, month, day, hour, minute, second, dow, _ = time.gmtime(time.time() + tz_seconds)
graphics.set_pen(0)
graphics.set_font('sans')
# display.text(text, x, y, wordwrap, scale, angle, spacing)
graphics.text(f"{hour:02}:{minute:02} {year}-{month}-{day}", 230, 10, scale=0.5)
gc.collect()