88CircuitPython driver for Adafruit SSD1680 display breakouts
99* Author(s): Melissa LeBlanc-Williams Mikey Sklar
1010"""
11+ import time
1112from micropython import const
1213import adafruit_framebuf
1314from adafruit_epd .epd import Adafruit_EPD
14- import time
1515
1616# Define all SSD1680 constants
1717_SSD1680_DRIVER_CONTROL = const (0x01 )
3030class Adafruit_SSD1680 (Adafruit_EPD ):
3131 """Driver for SSD1680 ePaper display, default driver."""
3232
33+ # pylint: disable=too-many-arguments
3334 def __init__ (self , width , height , spi , * , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin ):
35+ # Call parent class's __init__ to initialize sram and other attributes
3436 super ().__init__ (width , height , spi , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin )
3537
3638 self .cs_pin = cs_pin
@@ -40,8 +42,10 @@ def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, b
4042 self .busy_pin = busy_pin
4143
4244 self .initialize_buffers (width , height )
45+ # pylint: enable=too-many-arguments
4346
4447 def initialize_buffers (self , width , height ):
48+ """Initialize width height stride buffers"""
4549 stride = width
4650 if stride % 8 != 0 :
4751 stride += 8 - stride % 8
@@ -80,16 +84,22 @@ def power_up(self):
8084 self .command (_SSD1680_SW_RESET )
8185 self .busy_wait ()
8286
83- self .command (_SSD1680_DRIVER_CONTROL , bytearray ([self ._height - 1 , (self ._height - 1 ) >> 8 , 0x00 ]))
87+ self .command (
88+ _SSD1680_DRIVER_CONTROL ,
89+ bytearray ([self ._height - 1 , (self ._height - 1 ) >> 8 , 0x00 ]),
90+ )
8491 self .command (_SSD1680_DATA_MODE , bytearray ([0x03 ]))
8592 self .command (_SSD1680_SET_RAMXPOS , bytearray ([0x01 , 0x10 ]))
86- self .command (_SSD1680_SET_RAMYPOS , bytearray ([0 , 0 , self ._height - 1 , (self ._height - 1 ) >> 8 ]))
93+ self .command (
94+ _SSD1680_SET_RAMYPOS ,
95+ bytearray ([0 , 0 , self ._height - 1 , (self ._height - 1 ) >> 8 ]),
96+ )
8797
8898 def write_ram (self , index ):
8999 """Write to RAM for SSD1680."""
90100 if index == 0 :
91101 return self .command (_SSD1680_WRITE_BWRAM , end = False )
92- elif index == 1 :
102+ if index == 1 :
93103 return self .command (_SSD1680_WRITE_REDRAM , end = False )
94104 else :
95105 raise RuntimeError ("RAM index must be 0 or 1" )
@@ -112,13 +122,15 @@ def power_down(self):
112122 self .command (_SSD1680_DEEP_SLEEP , bytearray ([0x01 ]))
113123 time .sleep (0.1 )
114124
115-
116125class Adafruit_SSD1680Z (Adafruit_SSD1680 ):
117126 """Driver for SSD1680Z ePaper display, overriding SSD1680 settings."""
118127
128+ # pylint: disable=too-many-arguments
119129 def __init__ (self , width , height , spi , * , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin ):
130+ # Call the parent class's __init__() to initialize attributes
120131 super ().__init__ (width , height , spi , cs_pin = cs_pin , dc_pin = dc_pin ,
121132 sramcs_pin = sramcs_pin , rst_pin = rst_pin , busy_pin = busy_pin )
133+ # pylint: enable=too-many-arguments
122134
123135 def power_up (self ):
124136 """Power up sequence specifically for SSD1680Z."""
@@ -127,10 +139,16 @@ def power_up(self):
127139 self .command (_SSD1680_SW_RESET )
128140 self .busy_wait ()
129141
130- self .command (_SSD1680_DRIVER_CONTROL , bytearray ([self ._height - 1 , (self ._height - 1 ) >> 8 , 0x00 ]))
142+ self .command (
143+ _SSD1680_DRIVER_CONTROL ,
144+ bytearray ([self ._height - 1 , (self ._height - 1 ) >> 8 , 0x00 ]),
145+ )
131146 self .command (_SSD1680_DATA_MODE , bytearray ([0x03 ]))
132147 self .command (_SSD1680_SET_RAMXPOS , bytearray ([0x00 , (self ._width // 8 ) - 1 ]))
133- self .command (_SSD1680_SET_RAMYPOS , bytearray ([0x00 , 0x00 , self ._height - 1 , (self ._height - 1 ) >> 8 ]))
148+ self .command (
149+ _SSD1680_SET_RAMYPOS ,
150+ bytearray ([0x00 , 0x00 , self ._height - 1 , (self ._height - 1 ) >> 8 ]),
151+ )
134152
135153 def update (self ):
136154 """Update the display specifically for SSD1680Z."""
0 commit comments