#from machine import Pin, I2C
#import ssd1306
#i2c = I2C(0, scl=Pin(22), sda=Pin(21))
#oled_width = 128
#oled_height = 64
#oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
#oled.text('Hello, Wokwi!', 10, 10)
#oled.show()
from machine import Pin, I2C
import ssd1306
# Initialisation de l'I2C (selon les broches de votre ESP32)
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
# Initialisation de l'afficheur OLED
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
# Définition des formes 8x8
sun_image = [
0b00100100,
0b01000010,
0b00011000,
0b11100111,
0b11100111,
0b00011000,
0b01000010,
0b00100100,
]
water_drop_image = [
0b00010000,
0b00111000,
0b00111000,
0b01111100,
0b01111100,
0b00111000,
0b00010000,
0b00000000,
]
arrow_image = [
0b00001000,
0b00011100,
0b00111110,
0b01111111,
0b00011100,
0b00011100,
0b00011100,
0b00011100,
]
# Effacer l'écran
oled.fill(0)
# Affichage du soleil en haut à gauche (position (0,0))
for y in range(8):
for x in range(8):
if sun_image[y] & (1 << (7 - x)):
oled.pixel(x, y, 1)
# Affichage de la goutte d'eau en haut à droite (position (64,0))
offset_x = 64
for y in range(8):
for x in range(8):
if water_drop_image[y] & (1 << (7 - x)):
oled.pixel(offset_x + x, y, 1)
# Affichage de la flèche en bas à gauche (position (0,56))
offset_y = 56
for y in range(8):
for x in range(8):
if arrow_image[y] & (1 << (7 - x)):
oled.pixel(x, offset_y + y, 1)
# Afficher toutes les images sur l'écran OLED
oled.show()