1+ # The MIT License (MIT)
2+ #
3+ # Copyright (c) 2018 Dean Miller for Adafruit Industries
4+ #
5+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6+ # of this software and associated documentation files (the "Software"), to deal
7+ # in the Software without restriction, including without limitation the rights
8+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+ # copies of the Software, and to permit persons to whom the Software is
10+ # furnished to do so, subject to the following conditions:
11+ #
12+ # The above copyright notice and this permission notice shall be included in
13+ # all copies or substantial portions of the Software.
14+ #
15+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+ # THE SOFTWARE.
22+ """
23+ `adafruit_epd.il0373` - Adafruit il0373 - ePaper display driver
24+ ====================================================================================
25+ CircuitPython driver for Adafruit il0373 display breakouts
26+ * Author(s): Dean Miller
27+ """
28+
129import time
230from micropython import const
331from adafruit_epd .epd import Adafruit_EPD
2957IL0373_VCM_DC_SETTING = const (0x82 )
3058
3159class Adafruit_IL0373 (Adafruit_EPD ):
60+ """driver class for Adafruit IL0373 ePaper display breakouts"""
3261 # pylint: disable=too-many-arguments
3362 def __init__ (self , width , height , rst_pin , dc_pin , busy_pin , srcs_pin , cs_pin , spi ):
3463 super (Adafruit_IL0373 , self ).__init__ (width , height , rst_pin , dc_pin , busy_pin ,
@@ -41,6 +70,7 @@ def __init__(self, width, height, rst_pin, dc_pin, busy_pin, srcs_pin, cs_pin, s
4170 # pylint: enable=too-many-arguments
4271
4372 def begin (self , reset = True ):
73+ """Begin communication with the display and set basic settings"""
4474 super (Adafruit_IL0373 , self ).begin (reset )
4575
4676 while self ._busy .value is False :
@@ -50,6 +80,7 @@ def begin(self, reset=True):
5080 self .command (IL0373_BOOSTER_SOFT_START , bytearray ([0x17 , 0x17 , 0x17 ]))
5181
5282 def update (self ):
83+ """update the display"""
5384 self .command (IL0373_DISPLAY_REFRESH )
5485
5586 while self ._busy .value is False :
@@ -61,6 +92,7 @@ def update(self):
6192 time .sleep (2 )
6293
6394 def power_up (self ):
95+ """power up the display"""
6496 self .command (IL0373_POWER_ON )
6597
6698 while self ._busy .value is False :
@@ -80,6 +112,7 @@ def power_up(self):
80112
81113
82114 def display (self ):
115+ """show the contents of the display buffer"""
83116 self .power_up ()
84117
85118 while not self .spi_device .try_lock ():
@@ -134,6 +167,7 @@ def display(self):
134167 self .update ()
135168
136169 def draw_pixel (self , x , y , color ):
170+ """draw a single pixel in the display buffer"""
137171 if (x < 0 ) or (x >= self .width ) or (y < 0 ) or (y >= self .height ):
138172 return
139173
@@ -156,9 +190,11 @@ def draw_pixel(self, x, y, color):
156190 return
157191
158192 def clear_buffer (self ):
193+ """clear the display buffer"""
159194 self .sram .erase (0x00 , self .bw_bufsize , 0xFF )
160195 self .sram .erase (self .bw_bufsize , self .red_bufsize , 0xFF )
161196
162197 def clear_display (self ):
198+ """clear the entire display"""
163199 self .clear_buffer ()
164200 self .display ()
0 commit comments