Open diminDDL opened 3 years ago
Are you attempting to use both screens at the same time? Or trading off between them just trying to either one to work independently?
If you are trying to use both at the same time I think it might be necessary to make a configuration change within the build of CircuitPython in order to enable it to use 2 screens at the same time, I believe the default build is limited to only 1.
I am not able to get a single one working, both of them are just here for testing, switching between them.
Are you able to show a photo from further away that shows the wiring between the pico and the display?
I don't have a concrete answer for what could be causing this right now, but the artifacts that are showing on the screen remind me of this issue: https://github.com/adafruit/circuitpython/pull/4793 It's possible that you are running into a similar problem. There are some more details on the issue here: https://github.com/adafruit/circuitpython/issues/4775
However I do think all of the linked issues were specifically around SPI displays, so if you are seeing the same thing on I2C possibly this is a red herring and perhaps something different.
The connections are the same as described in the code I posted, the real deal is a bit messy. I will try the I2C example now since the waveshare display has changeable jumpers to change it's operation.
Just tried I2C:
import busio
import board
import displayio
import terminalio
from adafruit_display_text import label
import adafruit_displayio_sh1106
displayio.release_displays()
oled_reset = board.GP15
# Use for I2C
i2c = busio.I2C(scl=board.GP1, sda=board.GP0)
display_bus = displayio.I2CDisplay(i2c, device_address=0x3c, reset=oled_reset)
# Use for SPI
#spi = busio.SPI(clock=board.GP2, MOSI=board.GP3, MISO=board.GP4)
#oled_cs = board.GP7
#oled_dc = board.GP5
#display_bus = displayio.FourWire(spi, command=oled_dc, chip_select=oled_cs,
# reset=oled_reset, baudrate=1000000)
WIDTH = 128
HEIGHT = 64 # Change to 64 if needed
BORDER = 5
display = adafruit_displayio_sh1106.SH1106(display_bus, width=WIDTH, height=HEIGHT)
# Make the display context
splash = displayio.Group(max_size=10)
display.show(splash)
color_bitmap = displayio.Bitmap(WIDTH, HEIGHT, 1)
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(WIDTH - BORDER * 2, HEIGHT - BORDER * 2, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0x000000 # Black
inner_sprite = displayio.TileGrid(
inner_bitmap, pixel_shader=inner_palette, x=BORDER, y=BORDER
)
splash.append(inner_sprite)
# Draw a label
text = "Hello World!"
text_area = label.Label(
terminalio.FONT, text=text, color=0xFFFFFF, x=28, y=HEIGHT // 2 - 1
)
splash.append(text_area)
while True:
pass
Experiencing the exact same weird behavior including REPL creeping on to the display.
Today I got the adafruit_displayio_sh1106.py file and edited it to use have the same initialization commands as the arduino logic analyzer capture, it didn't help and result in the exact same behavior, this might indicate that something is up with the drawing/display pushing functions in displayio perhaps. Not sure yet, will post updates when I manage to find anything.
I think I have identified the issue, it might be due to the way the clock signal operates when no data is available. All the arduino libraries that worked put the clock signal HIGH when no data was sent while this library does the opposite, confusing the display. Also the data appears to be optimized for being latched on the falling edge in the arduino libraries, while this library assumes a rising edge. Also the DC signal seems to be constantly HIGH on the pico. Arduino first initialization command: Pico first initialization command:
I have added the corresponding phase=0, polarity=1
in to the SPI initialization, the only problem now is that the D/C line is constantly low.
I tried to get 2 sh1106 displays working on the raspberry pi pico for the last 2 days. One of them is a Waveshare 1.3 inch 128x64 SH1106 OLED (in SPI mode), the other one is a generic 128x64 SPI OLED experimentally identified to be an SH106 module since just like the first one it worked perfectly with an aruino nano with the following library. However, when trying to get it working in CircuitPython on 6.3 the display occasionally only turned on and showed noise, however when switching to latest release of 7.0.0-beta I got some text out of the display, also randomly but not like it's supposed to be. In both cases the latest release of this repo was used for the libraries. It also appears that perhaps some memory mishap is going on since on several occasions I witnessed the REPL output appearing on the OLED:
The code I used is as follows: