Skip to content

Instantly share code, notes, and snippets.

@sobuildit
Created July 4, 2020 22:05
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 sobuildit/b0ac979126c0e80877c589b0b377c7ea to your computer and use it in GitHub Desktop.
Save sobuildit/b0ac979126c0e80877c589b0b377c7ea to your computer and use it in GitHub Desktop.
from board import SCL, SDA
import busio
from PIL import Image, ImageDraw
import adafruit_ssd1306
# Create the I2C interface.
i2c = busio.I2C(SCL, SDA)
disp = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
# Clear display.
disp.fill(0)
disp.show()
# Create blank image for drawing and blank it
width = disp.width
height = disp.height
image = Image.new("1", (width, height))
# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)
# Draw a black filled box to clear the image.
draw.rectangle((0, 0, width, height), outline=0, fill=0)
# ... Draw things using PIL ...
disp.image(image)
disp.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment