Created
February 8, 2020 01:57
-
-
Save FoamyGuy/648f6264683d4032ed63cba0370f1ab0 to your computer and use it in GitHub Desktop.
This file contains 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
""" | |
This test will initialize the display using displayio and draw a solid white | |
background, and a black pixel. | |
""" | |
import board | |
import displayio | |
import terminalio | |
from adafruit_display_text import label | |
import adafruit_displayio_ssd1306 | |
displayio.release_displays() | |
i2c = board.I2C() | |
display_bus = displayio.I2CDisplay(i2c, device_address=0x3c) | |
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32) | |
# Make the display context | |
splash = displayio.Group(max_size=10) | |
display.show(splash) | |
color_bitmap = displayio.Bitmap(128, 32, 1) | |
color_palette = displayio.Palette(1) | |
color_palette[0] = 0xFFFFFF # White | |
bg_sprite = displayio.TileGrid(color_bitmap, | |
pixel_shader=color_palette, | |
x=0, y=0) | |
splash.append(bg_sprite) | |
# Draw single black pixel | |
inner_bitmap = displayio.Bitmap(1, 1, 1) # first two parameters are width, height. 1,1 gives us 1 pixel | |
inner_palette = displayio.Palette(1) | |
inner_palette[0] = 0x000000 # Black | |
inner_sprite = displayio.TileGrid(inner_bitmap, | |
pixel_shader=inner_palette, | |
x=5, y=4) # x,y location of the pixel | |
splash.append(inner_sprite) | |
while True: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment