robert-hh / SH1106

MicroPython driver for the SH1106 OLED controller
Other
163 stars 38 forks source link

Rotate does not work as expected #16

Closed spacemanspiff2007 closed 3 years ago

spacemanspiff2007 commented 3 years ago

I can't seem to get the display to rotate so it is upside down. The following code always shows the same image, regardless of the rotate parameter. I've tried 0 and 180. Do I have to call additional methods or am I missing something? Thank you for your help

_DSP_PIXEL_WIDTH = const(128)
_DSP_PIXEL_HEIGHT = const(64)
I2C = SoftI2C(scl=Pin(32), sda=Pin(16))
DSP = sh1106.SH1106_I2C(_DSP_PIXEL_WIDTH, _DSP_PIXEL_HEIGHT, I2C, rotate=180)
for y in (0, 14, 28, 42, 56):
    DSP.text('_Startup_...!_', 0, y)
DSP.show()
MicroPython v1.16 on 2021-06-23; ESP32 module with ESP32
spacemanspiff2007 commented 3 years ago

I got it working after playing around some more:

DSP = sh1106.SH1106_I2C(_DSP_PIXEL_WIDTH, _DSP_PIXEL_HEIGHT, I2C, rotate=180)
for y in (0, 14, 28, 42, 56):
    DSP.text('_Startup_...!_', 0, y)
DSP.flip()  # <-- replaced the first show with flip
...
# draw some other stuff
...
DSP.show()  # <-- use show from then on

Something I noticed: If I initialize without the rotate=180 it's not working