adafruit / Adafruit_CircuitPython_DisplayIO_SH1106

CircuitPython library for SH1106 OLED displays
MIT License
4 stars 4 forks source link

Adafruit MacroPad RP2040 display shifted slightly left #12

Closed Anomalocaridid closed 1 year ago

Anomalocaridid commented 1 year ago

I am trying to use this library to drive the Adafruit MacroPad's SH1106 display without using the MacroPad library and it appears that whatever is drawn on the screen gets shifted slightly to the left. This problem does not occur on the CircuitPython boot screen or on code that does not rely on this library, such as the arduino-based demo code it came with or the code from this guide.

The below image shows what happens when I try to write "Hello World" at (0,0) (code at bottom). Note the extra pixels on the right edge, which I believe is part of the CircuitPython boot screen that did not get erased when the display was initialized. IMG_20230808_211319

Here is a picture of the CircuitPython boot screen. The rightmost part of the "n" at the end of the second line appears to line up with the extra pixels in the above picture. IMG_20230808_211611

The code that I used:

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

displayio.release_displays()

# Use for SPI
spi = busio.SPI(board.SCK, board.MOSI)
display_bus = displayio.FourWire(
    spi,
    command=board.OLED_DC,
    chip_select=board.OLED_CS,
    reset=board.OLED_RESET,
    baudrate=1000000,
)

display = adafruit_displayio_sh1106.SH1106(display_bus, width=128, height=64)

# Make the display context
splash = displayio.Group()
display.show(splash)

# Draw a label
text = "Hello, World!"
text_area = label.Label(
    terminalio.FONT,
    text=text,
    color=0xFFFFFF,
    anchor_point=(0.0, 0.0),
    anchored_position=(0, 0),
)
splash.append(text_area)

while True:
    pass
makermelissa commented 1 year ago

The driver is built into circuitpython, so there's no need to reinitialize the screen. You should be able to just use board.DISPLAY.

Anomalocaridid commented 1 year ago

My bad. It works perfectly with board.DISPLAY. Thanks a lot!