File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change 35
35
SET_DISP_START_LINE = const (0x40 )
36
36
SET_SEG_REMAP = const (0xA0 )
37
37
SET_MUX_RATIO = const (0xA8 )
38
+ SET_IREF_SELECT = const (0xAD )
38
39
SET_COM_OUT_DIR = const (0xC0 )
39
40
SET_DISP_OFFSET = const (0xD3 )
40
41
SET_COM_PIN_CFG = const (0xDA )
@@ -126,15 +127,14 @@ def init_display(self):
126
127
0xFF , # maximum
127
128
SET_ENTIRE_ON , # output follows RAM contents
128
129
SET_NORM_INV , # not inverted
130
+ SET_IREF_SELECT ,
131
+ 0x30 , # enable internal IREF during display on
129
132
# charge pump
130
133
SET_CHARGE_PUMP ,
131
134
0x10 if self .external_vcc else 0x14 ,
132
135
SET_DISP | 0x01 ,
133
136
): # on
134
137
self .write_cmd (cmd )
135
- if self .width == 72 :
136
- self .write_cmd (0xAD )
137
- self .write_cmd (0x30 )
138
138
self .fill (0 )
139
139
self .show ()
140
140
@@ -177,14 +177,11 @@ def show(self):
177
177
if not self .page_addressing :
178
178
xpos0 = 0
179
179
xpos1 = self .width - 1
180
- if self .width == 64 :
181
- # displays with width of 64 pixels are shifted by 32
182
- xpos0 += 32
183
- xpos1 += 32
184
- if self .width == 72 :
185
- # displays with width of 72 pixels are shifted by 28
186
- xpos0 += 28
187
- xpos1 += 28
180
+ if self .width != 128 :
181
+ # narrow displays use centered columns
182
+ col_offset = (128 - self .width ) // 2
183
+ xpos0 += col_offset
184
+ xpos1 += col_offset
188
185
self .write_cmd (SET_COL_ADDR )
189
186
self .write_cmd (xpos0 )
190
187
self .write_cmd (xpos1 )
You can’t perform that action at this time.
0 commit comments