Created
March 19, 2023 13:41
-
-
Save dglaude/ab2340ff3263547a51484967139a7f75 to your computer and use it in GitHub Desktop.
S2 PICO V1.0.0 WEMOS.CC testing: board.DISPLAY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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