from machine import Pin, SoftI2C
import ssd1306
from time import sleep
i2c = SoftI2C(sda=Pin(21), scl=Pin(22))
display = ssd1306.SSD1306_I2C(128, 64, i2c)
tree_sprite = [
" 1 ",
" 111 ",
" 11111 ",
" 1111111 ",
" 111111111 ",
" 11111 ",
" 1111111 ",
" 111111111 ",
" 11111111111 ",
" 1111111 ",
" 111111111 ",
" 11111111111 ",
"1111111111111",
" 111 ",
" 111 ",
" 111 "
]
def draw_tree(x_pos, y_pos, scale=3):
for row_idx, row in enumerate(tree_sprite):
for col_idx, pixel in enumerate(row):
if pixel == '1':
display.fill_rect(
x_pos + (col_idx * scale),
y_pos + (row_idx * scale),
scale,
scale,
1
)
display.poweron()
display.fill(0)
draw_tree(x_pos=40, y_pos=5, scale=3)
display.show()