25
25
26
26
Framebuf (non-displayio) driver for SSD1305 displays
27
27
28
- * Author(s): Bryan Siepert, Tony DiCola, Michael McWethy
28
+ * Author(s): Melissa LeBlanc-Williamns, Bryan Siepert, Tony DiCola, Michael McWethy
29
29
30
30
Display init commands taken from
31
31
https://www.buydisplay.com/download/democode/ER-OLED022-1_I2C_DemoCode.txt
70
70
SET_COL_ADDR = const (0x21 )
71
71
SET_PAGE_ADDR = const (0x22 )
72
72
SET_DISP_START_LINE = const (0x40 )
73
+ SET_LUT = const (0x91 )
73
74
SET_SEG_REMAP = const (0xa0 )
74
75
SET_MUX_RATIO = const (0xa8 )
76
+ SET_MASTER_CONFIG = const (0xad )
75
77
SET_COM_OUT_DIR = const (0xc0 )
78
+ SET_COMSCAN_DEC = const (0xc8 )
76
79
SET_DISP_OFFSET = const (0xd3 )
77
80
SET_COM_PIN_CFG = const (0xda )
78
81
SET_DISP_CLK_DIV = const (0xd5 )
82
+ SET_AREA_COLOR = const (0xd8 )
79
83
SET_PRECHARGE = const (0xd9 )
80
84
SET_VCOM_DESEL = const (0xdb )
81
85
SET_CHARGE_PUMP = const (0x8d )
@@ -95,7 +99,9 @@ def __init__(self, buffer, width, height, *, external_vcc, reset):
95
99
if self .reset_pin :
96
100
self .reset_pin .switch_to_output (value = 0 )
97
101
self .pages = self .height // 8
98
- self ._column_offset = 4 # hardcoded for now...
102
+ self ._column_offset = 0
103
+ if self .height == 32 :
104
+ self ._column_offset = 4 # hardcoded for now...
99
105
# Note the subclass must initialize self.framebuf to a framebuffer.
100
106
# This is necessary because the underlying data buffer is different
101
107
# between I2C and SPI implementations (I2C needs an extra byte).
@@ -105,27 +111,26 @@ def __init__(self, buffer, width, height, *, external_vcc, reset):
105
111
def init_display (self ):
106
112
"""Base class to initialize display"""
107
113
for cmd in (
108
- 0xae | 0x00 , # off
114
+ SET_DISP | 0x00 , # off
109
115
# timing and driving scheme
110
- 0xd5 , 0x80 , #SET_DISP_CLK_DIV
111
- 0xa0 | 0x01 , # column addr 127 mapped to SEG0 SET_SEG_REMAP
112
- 0xa8 , self .height - 1 , #SET_MUX_RATIO
113
- 0xd3 , 0x00 , #SET_DISP_OFFSET
114
- 0xad , 0x8e , #Set Master Configuration
115
- 0xd8 , 0x05 , #Set Area Color Mode On/Off & Low Power Display Mode
116
- 0x20 , 0x00 , # horizontal SET_MEM_ADDR ADD
117
- 0x40 | 0x00 , #SET_DISP_START_LINE ADD
118
- 0xa1 , #set segment re-map 128 to 0
119
- 0xC8 , #Set COM Output Scan Direction 64 to 1
120
- 0xda , 0x12 , #SET_COM_PIN_CFG
121
- 0x91 , 0x3f , 0x3f , 0x3f , 0x3f ,#Current drive pulse width of BANK0, Color A, Band C.
122
- 0x81 , 0xff , # maximum SET_CONTRAST to maximum
123
- 0xd9 , 0xd2 , #SET_PRECHARGE orig: 0xd9, 0x22 if self.external_vcc else 0xf1,
124
- 0xdb , 0x34 , #SET_VCOM_DESEL 0xdb, 0x30, $ 0.83* Vcc
125
- 0xa6 , # not inverted SET_NORM_INV
126
- 0xa4 , # output follows RAM contents SET_ENTIRE_ON
127
- 0x8d , 0x10 if self .external_vcc else 0x14 , #SET_CHARGE_PUMP
128
- 0xaf ): #//--turn on oled panel
116
+ SET_DISP_CLK_DIV , 0x80 , #SET_DISP_CLK_DIV
117
+ SET_SEG_REMAP | 0x01 , # column addr 127 mapped to SEG0 SET_SEG_REMAP
118
+ SET_MUX_RATIO , self .height - 1 , #SET_MUX_RATIO
119
+ SET_DISP_OFFSET , 0x00 , #SET_DISP_OFFSET
120
+ SET_MASTER_CONFIG , 0x8e , #Set Master Configuration
121
+ SET_AREA_COLOR , 0x05 , #Set Area Color Mode On/Off & Low Power Display Mode
122
+ SET_MEM_ADDR , 0x00 , # horizontal SET_MEM_ADDR ADD
123
+ SET_DISP_START_LINE | 0x00 , 0x2E , #SET_DISP_START_LINE ADD
124
+ SET_COMSCAN_DEC , #Set COM Output Scan Direction 64 to 1
125
+ SET_COM_PIN_CFG , 0x12 , #SET_COM_PIN_CFG
126
+ SET_LUT , 0x3f , 0x3f , 0x3f , 0x3f ,#Current drive pulse width of BANK0, Color A, B, C
127
+ SET_CONTRAST , 0xff , # maximum SET_CONTRAST to maximum
128
+ SET_PRECHARGE , 0xd2 , #SET_PRECHARGE orig: 0xd9, 0x22 if self.external_vcc else 0xf1,
129
+ SET_VCOM_DESEL , 0x34 , #SET_VCOM_DESEL 0xdb, 0x30, $ 0.83* Vcc
130
+ SET_NORM_INV , # not inverted SET_NORM_INV
131
+ SET_ENTIRE_ON , # output follows RAM contents SET_ENTIRE_ON
132
+ SET_CHARGE_PUMP , 0x10 if self .external_vcc else 0x14 , #SET_CHARGE_PUMP
133
+ SET_DISP | 0x01 ): #//--turn on oled panel
129
134
self .write_cmd (cmd )
130
135
self .fill (0 )
131
136
self .show ()
@@ -171,8 +176,8 @@ def show(self):
171
176
xpos0 += 32
172
177
xpos1 += 32
173
178
self .write_cmd (SET_COL_ADDR )
174
- self .write_cmd (xpos0 + self ._column_offset )
175
- self .write_cmd (xpos1 + self ._column_offset )
179
+ self .write_cmd (xpos0 + self ._column_offset )
180
+ self .write_cmd (xpos1 + self ._column_offset )
176
181
self .write_cmd (SET_PAGE_ADDR )
177
182
self .write_cmd (0 )
178
183
self .write_cmd (self .pages - 1 )
0 commit comments