From 3ddeac61806ce5e7e8c4831cf26e6d91387f97ba Mon Sep 17 00:00:00 2001 From: thewesker Date: Fri, 16 Oct 2020 21:48:16 -0400 Subject: [PATCH] Fix nothing displayed with no images mounted. (#45) * Fix nothing displayed with no images mounted. This fixes the issue where nothing would show on the display unless an image is mounted. * Fixed the indent * Fixes not working when image attached issue Original commit caused the display not to work when an image was attached. This has now been fixed. * Fixed multiple images attached not working Forgot to remove testing code that caused multiple image displays to break. --- src/oled_monitor/rascsi_oled_monitor.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/oled_monitor/rascsi_oled_monitor.py b/src/oled_monitor/rascsi_oled_monitor.py index 38f478b4..b2e3a639 100755 --- a/src/oled_monitor/rascsi_oled_monitor.py +++ b/src/oled_monitor/rascsi_oled_monitor.py @@ -146,11 +146,15 @@ while True: for line in rascsi_list.split('\n'): # Skip empty strings, divider lines and the header line... if (len(line) == 0) or line.startswith("+---") or line.startswith("| ID | UN"): - continue - fields = line.split('|') - output = str.strip(fields[1]) + " " + str.strip(fields[3]) + " " + os.path.basename(str.strip(fields[4])) - draw.text((x, y_pos), output, font=font, fill=255) - y_pos = y_pos + 8 + continue + else: + if line.startswith("| "): + fields = line.split('|') + output = str.strip(fields[1]) + " " + str.strip(fields[3]) + " " + os.path.basename(str.strip(fields[4])) + else: + output = "No image mounted!" + draw.text((x, y_pos), output, font=font, fill=255) + y_pos = y_pos + 8 # If there is still room on the screen, we'll display the time. If there's not room it will just be clipped draw.text((x, y_pos), datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"), font=font, fill=255)