@@ -131,7 +131,14 @@ def text(self, string, xpos, ypos, col=1):
131131 self .framebuf .text (string , xpos , ypos , col )
132132
133133class 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.
135142 """
136143
137144 def __init__ (self , width , height , i2c , * , addr = 0x3c , external_vcc = False ):
@@ -167,7 +174,15 @@ def poweron(self):
167174
168175#pylint: disable-msg=too-many-arguments
169176class 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").
171186 """
172187 def __init__ (self , width , height , spi , dc , res , cs , * ,
173188 external_vcc = False , baudrate = 8000000 , polarity = 0 , phase = 0 ):
@@ -176,28 +191,28 @@ def __init__(self, width, height, spi, dc, res, cs, *,
176191 res .switch_to_output (value = 0 )
177192 self .spi_device = spi_device .SPIDevice (spi , cs , baudrate = baudrate ,
178193 polarity = polarity , phase = phase )
179- self .d_or_c = dc
180- self .res = res
194+ self .dc_pin = dc
195+ self .reset_pin = res
181196 self .buffer = bytearray ((height // 8 ) * width )
182197 framebuffer = framebuf .FrameBuffer1 (self .buffer , width , height )
183198 super ().__init__ (framebuffer , width , height , external_vcc )
184199
185200 def write_cmd (self , cmd ):
186201 """Send a command to the SPI device"""
187- self .d_or_c .value = 0
202+ self .dc_pin .value = 0
188203 with self .spi_device as spi :
189204 spi .write (bytearray ([cmd ]))
190205
191206 def write_framebuf (self ):
192207 """write to the frame buffer via SPI"""
193- self .d_or_c .value = 1
208+ self .dc_pin .value = 1
194209 with self .spi_device as spi :
195210 spi .write (self .buffer )
196211
197212 def poweron (self ):
198213 """Turn power off on the device"""
199- self .res .value = 1
214+ self .reset_pin .value = 1
200215 time .sleep (0.001 )
201- self .res .value = 0
216+ self .reset_pin .value = 0
202217 time .sleep (0.010 )
203- self .res .value = 1
218+ self .reset_pin .value = 1
0 commit comments