@@ -97,14 +97,14 @@ def init_display(self):
9797 # 64, 48: 0x80 0x12
9898 # 64, 32: 0x80 0x12
9999 for cmd in (
100- SET_DISP | 0x00 , # off
100+ SET_DISP , # off
101101 # address setting
102102 SET_MEM_ADDR ,
103103 0x10 # Page Addressing Mode
104104 if self .page_addressing
105105 else 0x00 , # Horizontal Addressing Mode
106106 # resolution and layout
107- SET_DISP_START_LINE | 0x00 ,
107+ SET_DISP_START_LINE ,
108108 SET_SEG_REMAP | 0x01 , # column addr 127 mapped to SEG0
109109 SET_MUX_RATIO ,
110110 self .height - 1 ,
@@ -132,15 +132,15 @@ def init_display(self):
132132 # charge pump
133133 SET_CHARGE_PUMP ,
134134 0x10 if self .external_vcc else 0x14 ,
135- SET_DISP | 0x01 ,
136- ): # on
135+ SET_DISP | 0x01 , # display on
136+ ):
137137 self .write_cmd (cmd )
138138 self .fill (0 )
139139 self .show ()
140140
141141 def poweroff (self ):
142142 """Turn off the display (nothing visible)"""
143- self .write_cmd (SET_DISP | 0x00 )
143+ self .write_cmd (SET_DISP )
144144 self ._power = False
145145
146146 def contrast (self , contrast ):
@@ -152,6 +152,12 @@ def invert(self, invert):
152152 """Invert all pixels on the display"""
153153 self .write_cmd (SET_NORM_INV | (invert & 1 ))
154154
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+
155161 def write_framebuf (self ):
156162 """Derived class must implement this"""
157163 raise NotImplementedError
0 commit comments