import time
import sys
import logging
from Adafruit_SSD1306 import SSD1306_128_64
from PIL import Image, ImageDraw, ImageFont
from time import sleep
display.clear()
display.display()
try:
# Load the bitmap image (ensure the path is correct)
bitmap_image = Image.open("intro_screen.bmp").convert("1") # Convert to 1-bit color
# Check the size of the image
if bitmap_image.size != (128, 64):
bitmap_image = bitmap_image.resize((128, 64)) # Resize if not the correct size
# Paste the bitmap image onto the OLED display buffer
image.paste(bitmap_image, (0, 0))
# Display the bitmap on the OLED
display.image(image)
display.display()
# Pause to show the intro screen
sleep(5)
except Exception as e:
print(f"Error displaying bitmap image: {e}")
# Fallback to text if the image fails to load
draw.rectangle((0, 0, width, height), outline=0, fill=0)
draw.text((20, 20), "Intro Screen", font=font, fill=255)
display.image(image)
display.display()
sleep(5)