Skip to content

Commit ece8303

Browse files
committed
DM: update docstrings
1 parent 3d2ad78 commit ece8303

File tree

3 files changed

+102
-1
lines changed

3 files changed

+102
-1
lines changed

adafruit_epd/epd.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
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.epd` - Adafruit EPD - ePaper display driver
24+
====================================================================================
25+
CircuitPython driver for Adafruit ePaper display breakouts
26+
* Author(s): Dean Miller
27+
"""
28+
129
import time
230
from adafruit_epd import mcp_sram
331
import digitalio
@@ -39,6 +67,7 @@ def __init__(self, width, height, rst_pin, dc_pin, busy_pin, srcs_pin, cs_pin, s
3967
# pylint: enable=too-many-arguments
4068

4169
def begin(self, reset=True):
70+
"""Begin display and reset if desired."""
4271
self._cs.value = True
4372
self._dc.value = False
4473

adafruit_epd/il0373.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
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+
129
import time
230
from micropython import const
331
from adafruit_epd.epd import Adafruit_EPD
@@ -29,6 +57,7 @@
2957
IL0373_VCM_DC_SETTING = const(0x82)
3058

3159
class 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()

adafruit_epd/mcp_sram.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
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.mcp_sram` - Adafruit MCP SRAM - sram driver
24+
====================================================================================
25+
CircuitPython driver for Microchip SRAM chips
26+
* Author(s): Dean Miller
27+
"""
28+
129
from micropython import const
230
import digitalio
331

432
SRAM_SEQUENTIAL_MODE = const(1 << 6)
533

634
class Adafruit_MCP_SRAM(object):
7-
35+
"""supporting class for communicating with
36+
Microchip SRAM chips"""
837
SRAM_READ = 0x03
938
SRAM_WRITE = 0x02
1039
SRAM_RDSR = 0x05
@@ -24,6 +53,7 @@ def __init__(self, cs_pin, spi):
2453
self.spi_device.unlock()
2554

2655
def write(self, addr, buf, reg=SRAM_WRITE):
56+
"""write the passed buffer to the passed address"""
2757
cmd = bytearray([reg, (addr >> 8) & 0xFF, addr & 0xFF] + buf)
2858

2959
while not self.spi_device.try_lock():
@@ -34,6 +64,7 @@ def write(self, addr, buf, reg=SRAM_WRITE):
3464
self.spi_device.unlock()
3565

3666
def read(self, addr, length, reg=SRAM_READ):
67+
"""read passed number of bytes at the passed address"""
3768
cmd = bytearray([reg, (addr >> 8) & 0xFF, addr & 0xFF])
3869

3970
buf = bytearray(length)
@@ -47,19 +78,24 @@ def read(self, addr, length, reg=SRAM_READ):
4778
return buf
4879

4980
def read8(self, addr, reg=SRAM_READ):
81+
"""read a single byte at the passed address"""
5082
return self.read(addr, 1, reg)[0]
5183

5284
def read16(self, addr, reg=SRAM_READ):
85+
"""read 2 bytes at the passed address"""
5386
buf = self.read(addr, 2, reg)
5487
return buf[0] << 8 | buf[1]
5588

5689
def write8(self, addr, value, reg=SRAM_WRITE):
90+
"""write a single byte at the passed address"""
5791
self.write(addr, [value], reg)
5892

5993
def write16(self, addr, value, reg=SRAM_WRITE):
94+
"""write 2 bytes at the passed address"""
6095
self.write(addr, [value >> 8, value], reg)
6196

6297
def erase(self, addr, length, value):
98+
"""erase the passed number of bytes starting at the passed address"""
6399
cmd = bytearray([Adafruit_MCP_SRAM.SRAM_WRITE, (addr >> 8) & 0xFF, addr & 0xFF])
64100

65101
while not self.spi_device.try_lock():

0 commit comments

Comments
 (0)