Skip to content

Instantly share code, notes, and snippets.

@FoamyGuy
Created February 8, 2020 01:57
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 FoamyGuy/648f6264683d4032ed63cba0370f1ab0 to your computer and use it in GitHub Desktop.
Save FoamyGuy/648f6264683d4032ed63cba0370f1ab0 to your computer and use it in GitHub Desktop.
"""
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