def __init__(self): super().__init__() self._oled_reset = digitalio.DigitalInOut(D4) self._i2c = busio.I2C(SCL, SDA) # Create the SSD1305 OLED class. # The first two parameters are the pixel width and pixel height. # Change these to the right size for your display! self._disp = adafruit_ssd1305.SSD1305_I2C(128, 32, self._i2c, reset=self._oled_reset) self.clear() # Create blank image for drawing. # Make sure to create image with mode '1' for 1-bit color. self._width = self._disp.width self._height = self._disp.height self._image = Image.new("1", (self._width, self._height)) # Get drawing object to draw on image. self._draw = ImageDraw.Draw(self._image) # Draw a black filled box to clear the image. self._draw.rectangle((0, 0, self._width, self._height), outline=0, fill=0) self._top = -2 self._font = BaseDisplay.font(8)
import subprocess from board import SCL, SDA, D4 import busio import digitalio from PIL import Image, ImageDraw, ImageFont import adafruit_ssd1305 import keyboard import string import curses import sys from os import listdir oled_reset = digitalio.DigitalInOut(D4) i2c = busio.I2C(SCL, SDA) disp = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c, reset=oled_reset) # Make sure to create image with mode '1' for 1-bit color. width = disp.width height = disp.height # Splash screen image = Image.open(r'piskel.png') image = image.convert('1') disp.image(image) disp.show() time.sleep(2) image = Image.new('1', (width, height)) # Get drawing object to draw on image.
# Import all board pins. from board import SCL, SDA import busio # Import the SSD1305 module. import adafruit_ssd1305 # Create the I2C interface. i2c = busio.I2C(SCL, SDA) # Create the SSD1305 OLED class. # The first two parameters are the pixel width and pixel height. Change these # to the right size for your display! display = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c) # Alternatively you can change the I2C address of the device with an addr parameter: #display = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c, addr=0x31) # Clear the display. Always call show after changing pixels to make the display # update visible! display.fill(0) display.show() # Set a pixel in the origin 0,0 position. display.pixel(0, 0, 1) # Set a pixel in the middle 64, 16 position. display.pixel(64, 16, 1) # Set a pixel in the opposite 127, 31 position. display.pixel(127, 31, 1) display.show()
import busio import digitalio # Import the SSD1305 module. import adafruit_ssd1305 # Define the Reset Pin oled_reset = digitalio.DigitalInOut(D4) # Create the I2C interface. i2c = busio.I2C(SCL, SDA) # Create the SSD1305 OLED class. # The first two parameters are the pixel width and pixel height. Change these # to the right size for your display! display = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c, addr=0x3C, reset=oled_reset) # Alternatively you can change the I2C address of the device with an addr parameter: # display = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c, addr=0x31, reset=oled_reset) # Clear the display. Always call show after changing pixels to make the display # update visible! display.fill(0) display.show() # Set a pixel in the origin 0,0 position. display.pixel(0, 0, 1) # Set a pixel in the middle 64, 16 position. display.pixel(64, 16, 1) # Set a pixel in the opposite 127, 31 position.
###################### # Globals ###################### ###################### # Pre-Main Setup ###################### oled_reset = digitalio.DigitalInOut(board.D4) WIDTH = 128 HEIGHT = 32 BORDER = 8 i2c = busio.I2C(SCL, SDA) oled = adafruit_ssd1305.SSD1305_I2C(WIDTH, HEIGHT, i2c) oled.fill(0) oled.show() image = Image.new("1", (oled.width, oled.height)) draw = ImageDraw.Draw(image) font = ImageFont.truetype("arial.ttf", 24) ###################### # Classes and Methods ###################### ###################### # Functions ######################