@@ -131,7 +131,14 @@ def text(self, string, xpos, ypos, col=1):
131
131
self .framebuf .text (string , xpos , ypos , col )
132
132
133
133
class SSD1306_I2C (_SSD1306 ):
134
- """ I2C class for SSD1306
134
+ """
135
+ I2C class for SSD1306
136
+
137
+ :param width: the width of the physical screen in pixels,
138
+ :param height: the height of the physical screen in pixels,
139
+ :param i2c: the I2C peripheral to use,
140
+ :param addr: the 8-bit bus address of the device,
141
+ :param external_vcc: whether external high-voltage source is connected.
135
142
"""
136
143
137
144
def __init__ (self , width , height , i2c , * , addr = 0x3c , external_vcc = False ):
@@ -167,7 +174,15 @@ def poweron(self):
167
174
168
175
#pylint: disable-msg=too-many-arguments
169
176
class SSD1306_SPI (_SSD1306 ):
170
- """ SPI class for SSD1306
177
+ """
178
+ SPI class for SSD1306
179
+
180
+ :param width: the width of the physical screen in pixels,
181
+ :param height: the height of the physical screen in pixels,
182
+ :param spi: the SPI peripheral to use,
183
+ :param dc: the data/command pin to use (often labeled "D/C"),
184
+ :param res: the reset pin to use,
185
+ :param cs: the chip-select pin to use (sometimes labeled "SS").
171
186
"""
172
187
def __init__ (self , width , height , spi , dc , res , cs , * ,
173
188
external_vcc = False , baudrate = 8000000 , polarity = 0 , phase = 0 ):
@@ -176,28 +191,28 @@ def __init__(self, width, height, spi, dc, res, cs, *,
176
191
res .switch_to_output (value = 0 )
177
192
self .spi_device = spi_device .SPIDevice (spi , cs , baudrate = baudrate ,
178
193
polarity = polarity , phase = phase )
179
- self .d_or_c = dc
180
- self .res = res
194
+ self .dc_pin = dc
195
+ self .reset_pin = res
181
196
self .buffer = bytearray ((height // 8 ) * width )
182
197
framebuffer = framebuf .FrameBuffer1 (self .buffer , width , height )
183
198
super ().__init__ (framebuffer , width , height , external_vcc )
184
199
185
200
def write_cmd (self , cmd ):
186
201
"""Send a command to the SPI device"""
187
- self .d_or_c .value = 0
202
+ self .dc_pin .value = 0
188
203
with self .spi_device as spi :
189
204
spi .write (bytearray ([cmd ]))
190
205
191
206
def write_framebuf (self ):
192
207
"""write to the frame buffer via SPI"""
193
- self .d_or_c .value = 1
208
+ self .dc_pin .value = 1
194
209
with self .spi_device as spi :
195
210
spi .write (self .buffer )
196
211
197
212
def poweron (self ):
198
213
"""Turn power off on the device"""
199
- self .res .value = 1
214
+ self .reset_pin .value = 1
200
215
time .sleep (0.001 )
201
- self .res .value = 0
216
+ self .reset_pin .value = 0
202
217
time .sleep (0.010 )
203
- self .res .value = 1
218
+ self .reset_pin .value = 1
0 commit comments