/ examples / ssd1305_simpletest.py
ssd1305_simpletest.py
 1  # Import all board pins.
 2  from board import SCL, SDA, D4
 3  import busio
 4  import digitalio
 5  
 6  # Import the SSD1305 module.
 7  import adafruit_ssd1305
 8  
 9  # Define the Reset Pin
10  oled_reset = digitalio.DigitalInOut(D4)
11  
12  # Create the I2C interface.
13  i2c = busio.I2C(SCL, SDA)
14  
15  # Create the SSD1305 OLED class.
16  # The first two parameters are the pixel width and pixel height.  Change these
17  # to the right size for your display!
18  display = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c, addr=0x3C, reset=oled_reset)
19  
20  # Alternatively you can change the I2C address of the device with an addr parameter:
21  # display = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c, addr=0x31, reset=oled_reset)
22  
23  # Clear the display.  Always call show after changing pixels to make the display
24  # update visible!
25  display.fill(0)
26  
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()