Skip to content

Commit e98d07f

Browse files
committed
tweak rotation
1 parent 86ccffb commit e98d07f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

adafruit_displayio_sh1107.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
2727
"""
2828

29-
import sys
3029
import displayio
3130
from micropython import const
31+
import sys
3232

3333
__version__ = "0.0.0-auto.0"
3434
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SH1107.git"
@@ -86,6 +86,7 @@
8686
b"\xaf\x00" # DISPLAY_ON
8787
)
8888
_PIXELS_IN_ROW = True
89+
_ROTATION_OFFSET = 0
8990
else:
9091
_INIT_SEQUENCE = (
9192
b"\xae\x00" # display off, sleep mode
@@ -96,16 +97,16 @@
9697
b"\xc0\x00" # common output scan direction = 15 (0 to n-1 (POR=0))
9798
b"\xa8\x01\x3f" # multiplex ratio = 128 (POR)
9899
b"\xd3\x01\x60" # set display offset mode = 0x60
99-
# b"\xd5\x01\x51" # divide ratio/oscillator: divide by 2, fOsc (POR)
100+
#b"\xd5\x01\x51" # divide ratio/oscillator: divide by 2, fOsc (POR)
100101
b"\xd9\x01\x22" # pre-charge/dis-charge period mode: 2 DCLKs/2 DCLKs (POR)
101102
b"\xdb\x01\x35" # VCOM deselect level = 0.770 (POR)
102-
# b"\xb0\x00" # set page address = 0 (POR)
103+
#b"\xb0\x00" # set page address = 0 (POR)
103104
b"\xa4\x00" # entire display off, retain RAM, normal status (POR)
104105
b"\xa6\x00" # normal (not reversed) display
105106
b"\xaf\x00" # DISPLAY_ON
106107
)
107108
_PIXELS_IN_ROW = False
108-
109+
_ROTATION_OFFSET = 90
109110

110111
class SH1107(displayio.Display):
111112
"""
@@ -125,6 +126,7 @@ def __init__(
125126
self,
126127
bus,
127128
display_offset=DISPLAY_OFFSET_ADAFRUIT_FEATHERWING_OLED_4650,
129+
rotation=0,
128130
**kwargs
129131
):
130132
init_sequence = bytearray(_INIT_SEQUENCE)
@@ -140,6 +142,7 @@ def __init__(
140142
set_vertical_scroll=0xD3, # TBD -- not sure about this one!
141143
brightness_command=0x81,
142144
single_byte_bounds=True,
145+
rotation=(rotation + _ROTATION_OFFSET) % 360,
143146
# for sh1107 use column and page addressing.
144147
# lower column command = 0x00 - 0x0F
145148
# upper column command = 0x10 - 0x17

examples/displayio_sh1107_simpletest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@
2727
# SH1107 is vertically oriented 64x128
2828
WIDTH = 128
2929
HEIGHT = 64
30-
ROTATION = 90
3130
BORDER = 2
3231

3332
display = adafruit_displayio_sh1107.SH1107(
34-
display_bus, width=WIDTH, height=HEIGHT, rotation=ROTATION
33+
display_bus, width=WIDTH, height=HEIGHT, rotation=0
3534
)
3635

3736
# Make the display context

0 commit comments

Comments
 (0)