from machine import Pin, I2C
import time
class MockSSD1306:
def __init__(self, width, height, i2c):
self.width = width
self.height = height
self.i2c = i2c
self.buffer = [[' ' for _ in range(width)] for _ in range(height)]
def fill(self, color):
self.buffer = [[' ' for _ in range(self.width)] for _ in range(self.height)]
def show_image(self, bitmap):
index = 0
for y in range(self.height):
for x in range(self.width):
if bitmap[index] == 0: # Assuming 0 is black
self.buffer[y][x] = '#'
else:
self.buffer[y][x] = ' '
index += 1
self.show()
def show(self):
for row in self.buffer:
print(''.join(row))
print()
# Initialize I2C (Mock)
i2c = None
# Create a mock display
oled = MockSSD1306(128, 64, i2c)
# Bitmap data for two images
bitmap1 = [
0, 0, 254, 254, 254, 128, 128, 128, 128, 128, 128, 254, 254, 254, 254, 0,
0, 0, 127, 127, 127, 1, 1, 1, 1, 1, 1, 127, 127, 127, 127, 0]*16*16 # Replace with actual bitmap data
bitmap2 = [
255, 127, 17, 77, 175, 141, 173, 33, 33, 173, 141, 175, 77, 17, 127, 255,
255, 248, 227, 236, 217, 195, 141, 172, 172, 141, 195, 217, 236, 227, 249, 255]*16*16 # Replace with actual bitmap data
# Display images
oled.fill(1)
oled.show_image(bitmap1)
time.sleep(2) # Display for 2 seconds
oled.fill(1)
oled.show_image(bitmap2)
time.sleep(2) # Display for 2 seconds