Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

I2C SSD 1306 Display with CircuitPython and Raspberry Pi Pic
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

I2C SSD 1306 Display with CircuitPython and Raspberry Pi Pic

by djairjr on Tue Mar 16, 2021 2:41 pm

This is my first experience with the Raspberry Pi Pico and CircuitPython. There are some differences to make the calls from the BUS I2C and I was having some difficulty in ordering the information. I hope it will be useful.

Code: Select all | TOGGLE FULL SIZE
# Adapting the example in https://learn.adafruit.com/adafruit-oled-featherwing/python-usage
# to use with Raspberry Pi Pico and CircuitPython

import board
import busio
import displayio
import terminalio
import adafruit_displayio_ssd1306
from adafruit_display_text import label

i2c = busio.I2C (scl=board.GP5, sda=board.GP4) # This RPi Pico way to call I2C

display_bus = displayio.I2CDisplay (i2c, device_address = 0x3C) # The address of my Board

display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=64)
splash = displayio.Group(max_size=10)
display.show(splash)

color_bitmap = displayio.Bitmap(128, 64, 1) # Full screen white
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 a smaller inner rectangle
inner_bitmap = displayio.Bitmap(118, 54, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0x000000  # Black
inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=5, y=4)
splash.append(inner_sprite)
 
# Draw a label
text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00, x=28, y=15)
splash.append(text_area)
 
while True:
    pass



djairjr
 
Posts: 2
Joined: Thu Oct 29, 2015 3:49 pm

Re: I2C SSD 1306 Display with CircuitPython and Raspberry Pi

by kattni on Tue Mar 16, 2021 3:02 pm

I think you have most of it figured out, there are some spacing issues with the code you posted. Try the following.
Code: Select all | TOGGLE FULL SIZE
import board
import busio
import displayio
import terminalio
import adafruit_displayio_ssd1306
from adafruit_display_text import label

i2c = busio.I2C(board.GP5, board.GP4)

display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)


Hopefully that's the only issue because I am unclear on what issue you're having.

kattni
 
Posts: 105
Joined: Fri Aug 18, 2017 6:33 pm

Re: I2C SSD 1306 Display with CircuitPython and Raspberry Pi

by djairjr on Tue Mar 16, 2021 4:05 pm

Sorry, Kattni. It was not an issue. I am learning to work on the board and I saw that the examples of CircuitPython have not yet been ported. I just wanted to contribute as much as I could. I think the indentation errors are due to a problem with Thonny. I just made an instructable and I had some problems with pasting the code over there as well. I'm sorry if I posted the message on the wrong topic, okay?

Here is the link:https://www.instructables.com/Raspberry-Pi-Pico-With-I2C-Oled-Display-and-Circui/

djairjr
 
Posts: 2
Joined: Thu Oct 29, 2015 3:49 pm

Please be positive and constructive with your questions and comments.