@@ -97,14 +97,14 @@ def init_display(self):
97
97
# 64, 48: 0x80 0x12
98
98
# 64, 32: 0x80 0x12
99
99
for cmd in (
100
- SET_DISP | 0x00 , # off
100
+ SET_DISP , # off
101
101
# address setting
102
102
SET_MEM_ADDR ,
103
103
0x10 # Page Addressing Mode
104
104
if self .page_addressing
105
105
else 0x00 , # Horizontal Addressing Mode
106
106
# resolution and layout
107
- SET_DISP_START_LINE | 0x00 ,
107
+ SET_DISP_START_LINE ,
108
108
SET_SEG_REMAP | 0x01 , # column addr 127 mapped to SEG0
109
109
SET_MUX_RATIO ,
110
110
self .height - 1 ,
@@ -132,15 +132,15 @@ def init_display(self):
132
132
# charge pump
133
133
SET_CHARGE_PUMP ,
134
134
0x10 if self .external_vcc else 0x14 ,
135
- SET_DISP | 0x01 ,
136
- ): # on
135
+ SET_DISP | 0x01 , # display on
136
+ ):
137
137
self .write_cmd (cmd )
138
138
self .fill (0 )
139
139
self .show ()
140
140
141
141
def poweroff (self ):
142
142
"""Turn off the display (nothing visible)"""
143
- self .write_cmd (SET_DISP | 0x00 )
143
+ self .write_cmd (SET_DISP )
144
144
self ._power = False
145
145
146
146
def contrast (self , contrast ):
@@ -152,6 +152,12 @@ def invert(self, invert):
152
152
"""Invert all pixels on the display"""
153
153
self .write_cmd (SET_NORM_INV | (invert & 1 ))
154
154
155
+ def rotate (self , rotate ):
156
+ """Rotate the display 0 or 180 degrees"""
157
+ self .write_cmd (SET_COM_OUT_DIR | ((rotate & 1 ) << 3 ))
158
+ self .write_cmd (SET_SEG_REMAP | (rotate & 1 ))
159
+ # com output is immediate (vertical mirror) but you need to call show() for seg remap to be visible
160
+
155
161
def write_framebuf (self ):
156
162
"""Derived class must implement this"""
157
163
raise NotImplementedError
0 commit comments