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
+
1
29
import time
2
30
from micropython import const
3
31
from adafruit_epd .epd import Adafruit_EPD
29
57
IL0373_VCM_DC_SETTING = const (0x82 )
30
58
31
59
class Adafruit_IL0373 (Adafruit_EPD ):
60
+ """driver class for Adafruit IL0373 ePaper display breakouts"""
32
61
# pylint: disable=too-many-arguments
33
62
def __init__ (self , width , height , rst_pin , dc_pin , busy_pin , srcs_pin , cs_pin , spi ):
34
63
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
41
70
# pylint: enable=too-many-arguments
42
71
43
72
def begin (self , reset = True ):
73
+ """Begin communication with the display and set basic settings"""
44
74
super (Adafruit_IL0373 , self ).begin (reset )
45
75
46
76
while self ._busy .value is False :
@@ -50,6 +80,7 @@ def begin(self, reset=True):
50
80
self .command (IL0373_BOOSTER_SOFT_START , bytearray ([0x17 , 0x17 , 0x17 ]))
51
81
52
82
def update (self ):
83
+ """update the display"""
53
84
self .command (IL0373_DISPLAY_REFRESH )
54
85
55
86
while self ._busy .value is False :
@@ -61,6 +92,7 @@ def update(self):
61
92
time .sleep (2 )
62
93
63
94
def power_up (self ):
95
+ """power up the display"""
64
96
self .command (IL0373_POWER_ON )
65
97
66
98
while self ._busy .value is False :
@@ -80,6 +112,7 @@ def power_up(self):
80
112
81
113
82
114
def display (self ):
115
+ """show the contents of the display buffer"""
83
116
self .power_up ()
84
117
85
118
while not self .spi_device .try_lock ():
@@ -134,6 +167,7 @@ def display(self):
134
167
self .update ()
135
168
136
169
def draw_pixel (self , x , y , color ):
170
+ """draw a single pixel in the display buffer"""
137
171
if (x < 0 ) or (x >= self .width ) or (y < 0 ) or (y >= self .height ):
138
172
return
139
173
@@ -156,9 +190,11 @@ def draw_pixel(self, x, y, color):
156
190
return
157
191
158
192
def clear_buffer (self ):
193
+ """clear the display buffer"""
159
194
self .sram .erase (0x00 , self .bw_bufsize , 0xFF )
160
195
self .sram .erase (self .bw_bufsize , self .red_bufsize , 0xFF )
161
196
162
197
def clear_display (self ):
198
+ """clear the entire display"""
163
199
self .clear_buffer ()
164
200
self .display ()
0 commit comments