diff --git a/src/oled_monitor/rascsi_oled_monitor.py b/src/oled_monitor/rascsi_oled_monitor.py index 0d1dfaf0..32b290e3 100755 --- a/src/oled_monitor/rascsi_oled_monitor.py +++ b/src/oled_monitor/rascsi_oled_monitor.py @@ -31,8 +31,8 @@ THE SOFTWARE. """ import argparse +import sys from time import sleep -from sys import argv from collections import deque from board import I2C from adafruit_ssd1306 import SSD1306_I2C @@ -95,20 +95,22 @@ I2C = I2C() # 128x32 display with hardware I2C: OLED = SSD1306_I2C(WIDTH, HEIGHT, I2C, addr=0x3C, reset=OLED_RESET) +OLED.rotation = ROTATION print("Running with the following display:") print(OLED) print() print("Will update the OLED display every " + str(DELAY_TIME_MS) + "ms (approximately)") -# Clear display. -OLED.rotation = ROTATION -OLED.fill(0) +# Show a startup splash bitmap image before starting the main loop +# Convert the image to mode '1' for 1-bit color (monochrome) +# Make sure the splash bitmap image is in the same dir as this script +IMAGE = Image.open(f"splash_start_{HEIGHT}.bmp").convert("1") +OLED.image(IMAGE) OLED.show() -# Create blank image for drawing. -# Make sure to create image with mode '1' for 1-bit color. -IMAGE = Image.new("1", (OLED.width, OLED.height)) +# Keep the pretty splash on screen for a number of seconds +sleep(4) # Get drawing object to draw on image. DRAW = ImageDraw.Draw(IMAGE) @@ -138,11 +140,6 @@ LINE_SPACING = 8 # Some other nice fonts to try: http://www.dafont.com/bitmap.php FONT = ImageFont.truetype('type_writer.ttf', FONT_SIZE) -# Load a bitmap image for start and stop splash screens and convert to monocrome -# Make sure the splash bitmap image is in the same dir as this script -SPLASH_START = Image.open(f"splash_start_{HEIGHT}.bmp").convert("1") -SPLASH_STOP = Image.open(f"splash_stop_{HEIGHT}.bmp").convert("1") - IP_ADDR, HOSTNAME = get_ip_and_host() @@ -190,28 +187,7 @@ def formatted_output(): return output -def start_splash(): - """ - Displays a splash screen for the startup sequence - """ - OLED.image(SPLASH_START) - OLED.show() - sleep(4) - -def stop_splash(): - """ - Displays a splash screen for the shutdown sequence - """ - OLED.image(SPLASH_STOP) - OLED.show() - -# Show a startup splash bitmap image before starting the main loop -start_splash() - with GracefulInterruptHandler() as handler: - """ - The main loop of displaying attached device info, and other info - """ while True: # The reference snapshot of attached devices that will be compared against each cycle @@ -225,10 +201,10 @@ with GracefulInterruptHandler() as handler: while snapshot == ref_snapshot: # Draw a black filled box to clear the image. DRAW.rectangle((0, 0, WIDTH, HEIGHT), outline=0, fill=0) - y_pos = TOP + Y_POS = TOP for output_line in active_output: - DRAW.text((X_POS, y_pos), output_line, font=FONT, fill=255) - y_pos += LINE_SPACING + DRAW.text((X_POS, Y_POS), output_line, font=FONT, fill=255) + Y_POS += LINE_SPACING # Shift the index of the array by one to get a scrolling effect if len(active_output) > LINES: @@ -242,6 +218,8 @@ with GracefulInterruptHandler() as handler: snapshot = formatted_output() if handler.interrupted: - # Catch interrupt signals and show a shutdown splash bitmap image - stop_splash() - exit("Shutting down the OLED display...") + # Catch interrupt signals and blank out the screen + DRAW.rectangle((0, 0, WIDTH, HEIGHT), outline=0, fill=0) + OLED.image(IMAGE) + OLED.show() + sys.exit("Shutting down the OLED display...") diff --git a/src/oled_monitor/splash_stop_32.bmp b/src/oled_monitor/splash_stop_32.bmp deleted file mode 100644 index eac18956..00000000 Binary files a/src/oled_monitor/splash_stop_32.bmp and /dev/null differ diff --git a/src/oled_monitor/splash_stop_64.bmp b/src/oled_monitor/splash_stop_64.bmp deleted file mode 100644 index 511f8214..00000000 Binary files a/src/oled_monitor/splash_stop_64.bmp and /dev/null differ