/ examples / ssd1306_simpletest.py
ssd1306_simpletest.py
 1  # Basic example of clearing and drawing pixels on a SSD1306 OLED display.
 2  # This example and library is meant to work with Adafruit CircuitPython API.
 3  # Author: Tony DiCola
 4  # License: Public Domain
 5  
 6  # Import all board pins.
 7  from board import SCL, SDA
 8  import busio
 9  
10  # Import the SSD1306 module.
11  import adafruit_ssd1306
12  
13  
14  # Create the I2C interface.
15  i2c = busio.I2C(SCL, SDA)
16  
17  # Create the SSD1306 OLED class.
18  # The first two parameters are the pixel width and pixel height.  Change these
19  # to the right size for your display!
20  display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
21  # Alternatively you can change the I2C address of the device with an addr parameter:
22  # display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x31)
23  
24  # Clear the display.  Always call show after changing pixels to make the display
25  # update visible!
26  display.fill(0)
27  display.show()
28  
29  # Set a pixel in the origin 0,0 position.
30  display.pixel(0, 0, 1)
31  # Set a pixel in the middle 64, 16 position.
32  display.pixel(64, 16, 1)
33  # Set a pixel in the opposite 127, 31 position.
34  display.pixel(127, 31, 1)
35  display.show()