From fa601bee56cd57930ffa4d96421012bd9b8d358d Mon Sep 17 00:00:00 2001 From: Paco Hope Date: Fri, 1 Dec 2023 08:58:53 -0500 Subject: [PATCH] add debugging on pngdec --- inky-lovelace.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/inky-lovelace.py b/inky-lovelace.py index fca90af..35d63c9 100644 --- a/inky-lovelace.py +++ b/inky-lovelace.py @@ -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()