Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tweak rotation
  • Loading branch information
ladyada committed Jul 9, 2021
commit e98d07f1b3a9e4ff2ed1c233470db1604991611b
11 changes: 7 additions & 4 deletions adafruit_displayio_sh1107.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

"""

import sys
import displayio
from micropython import const
import sys

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SH1107.git"
Expand Down Expand Up @@ -86,6 +86,7 @@
b"\xaf\x00" # DISPLAY_ON
)
_PIXELS_IN_ROW = True
_ROTATION_OFFSET = 0
else:
_INIT_SEQUENCE = (
b"\xae\x00" # display off, sleep mode
Expand All @@ -96,16 +97,16 @@
b"\xc0\x00" # common output scan direction = 15 (0 to n-1 (POR=0))
b"\xa8\x01\x3f" # multiplex ratio = 128 (POR)
b"\xd3\x01\x60" # set display offset mode = 0x60
# b"\xd5\x01\x51" # divide ratio/oscillator: divide by 2, fOsc (POR)
#b"\xd5\x01\x51" # divide ratio/oscillator: divide by 2, fOsc (POR)
b"\xd9\x01\x22" # pre-charge/dis-charge period mode: 2 DCLKs/2 DCLKs (POR)
b"\xdb\x01\x35" # VCOM deselect level = 0.770 (POR)
# b"\xb0\x00" # set page address = 0 (POR)
#b"\xb0\x00" # set page address = 0 (POR)
b"\xa4\x00" # entire display off, retain RAM, normal status (POR)
b"\xa6\x00" # normal (not reversed) display
b"\xaf\x00" # DISPLAY_ON
)
_PIXELS_IN_ROW = False

_ROTATION_OFFSET = 90

class SH1107(displayio.Display):
"""
Expand All @@ -125,6 +126,7 @@ def __init__(
self,
bus,
display_offset=DISPLAY_OFFSET_ADAFRUIT_FEATHERWING_OLED_4650,
rotation=0,
**kwargs
):
init_sequence = bytearray(_INIT_SEQUENCE)
Expand All @@ -140,6 +142,7 @@ def __init__(
set_vertical_scroll=0xD3, # TBD -- not sure about this one!
brightness_command=0x81,
single_byte_bounds=True,
rotation=(rotation + _ROTATION_OFFSET) % 360,
# for sh1107 use column and page addressing.
# lower column command = 0x00 - 0x0F
# upper column command = 0x10 - 0x17
Expand Down
3 changes: 1 addition & 2 deletions examples/displayio_sh1107_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
# SH1107 is vertically oriented 64x128
WIDTH = 128
HEIGHT = 64
ROTATION = 90
BORDER = 2

display = adafruit_displayio_sh1107.SH1107(
display_bus, width=WIDTH, height=HEIGHT, rotation=ROTATION
display_bus, width=WIDTH, height=HEIGHT, rotation=0
)

# Make the display context
Expand Down