Skip to content

Instantly share code, notes, and snippets.

@dglaude
Created March 19, 2023 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dglaude/ab2340ff3263547a51484967139a7f75 to your computer and use it in GitHub Desktop.
Save dglaude/ab2340ff3263547a51484967139a7f75 to your computer and use it in GitHub Desktop.
S2 PICO V1.0.0 WEMOS.CC testing: board.DISPLAY
# Import all board pins.
import board
import busio
import time
import displayio
import adafruit_displayio_ssd1306
import vectorio
displayio.release_displays()
i2c = board.I2C() # uses board.SCL and board.SDA
oled_reset=board.LCD_RST
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C, reset=oled_reset)
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32)
### ^^^ Manual initialization until `display = board.DISPLAY` start working vvv
#display = board.DISPLAY
splash = displayio.Group(x=0, y=0, scale=1)
display.show(splash)
color_palette = displayio.Palette(2)
color_palette[0] = 0
color_palette[1] = 0xFFFFFF
lines = displayio.Group()
lines.append(vectorio.Rectangle(pixel_shader=color_palette, color_index=1,
x=0, y=0, width=display.width, height=display.height,
))
lines.append(vectorio.Rectangle(pixel_shader=color_palette, color_index=0,
x=1, y=1, width=display.width-2, height=display.height-2,
))
for y in range(0, display.height+1, 16):
lines.append(vectorio.Rectangle(pixel_shader=color_palette,
width=display.width, height=1, x=0, y=y, color_index=1,
))
for x in range(0, display.width+1, 16):
lines.append(vectorio.Rectangle(pixel_shader=color_palette,
width=1, height=display.height, x=x, y=0, color_index=1,
))
splash.append(lines)
# this must not crash with a "pin in use" error
i2c = board.I2C()
while True:
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment