import board
import busio
import adafruit_ssd1306
from PIL import Image, ImageDraw, ImageFont
# Initialize I2C bus and SSD1306 display
i2c = busio.I2C(board.SCL, board.SDA)
display = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c)
# Load the Tamagotchi character image
character_image = Image.open('character.bmp').convert('1')
# Create a status bar background
status_bar_width = 30 # Adjust the width of the status bar as needed
status_bar = Image.new('1', (status_bar_width, 64), 0)
# Draw the status levels (placeholders)
draw = ImageDraw.Draw(status_bar)
font = ImageFont.load_default()
# Example status values (replace with actual values)
health = 80
hunger = 60
happiness = 90
# Draw status levels on the status bar
draw.text((2, 10), f"Health: {health}", font=font, fill=1)
draw.text((2, 30), f"Hunger: {hunger}", font=font, fill=1)
draw.text((2, 50), f"Happiness: {happiness}", font=font, fill=1)
# Display the character image on the OLED
display.image(character_image)
# Add the status bar on the side
display.image(status_bar, (0, 0))
# Show the display
display.show()