Skip to content

Commit 9c51956

Browse files
committed
charge arg order/kwarg, make busy/reset optional
1 parent bdda668 commit 9c51956

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

adafruit_epd/epd.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,20 @@ class Adafruit_EPD:
4141
LIGHT = 5
4242

4343
# pylint: disable=too-many-arguments
44-
def __init__(self, width, height, rst_pin, dc_pin, busy_pin, srcs_pin, cs_pin, spi):
44+
def __init__(self, width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin):
4545
# pylint: enable=too-many-arguments
4646
self.width = width
4747
self.height = height
4848

49-
# Setup reset pin.
49+
# Setup reset pin.
5050
self._rst = rst_pin
51-
self._rst.direction = digitalio.Direction.OUTPUT
51+
if rst_pin:
52+
self._rst.direction = digitalio.Direction.OUTPUT
5253

53-
# Setup busy pin.
54+
# Setup busy pin.
5455
self._busy = busy_pin
55-
self._busy.direction = digitalio.Direction.INPUT
56+
if busy_pin:
57+
self._busy.direction = digitalio.Direction.INPUT
5658

5759
# Setup dc pin.
5860
self._dc = dc_pin
@@ -66,7 +68,7 @@ def __init__(self, width, height, rst_pin, dc_pin, busy_pin, srcs_pin, cs_pin, s
6668

6769
self.spi_device = spi
6870

69-
self.sram = mcp_sram.Adafruit_MCP_SRAM(srcs_pin, spi)
71+
self.sram = mcp_sram.Adafruit_MCP_SRAM(sramcs_pin, spi)
7072

7173
if self._rst:
7274
self._rst.value = False

adafruit_epd/il0373.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
from adafruit_epd.epd import Adafruit_EPD
3232
from adafruit_epd.mcp_sram import Adafruit_MCP_SRAM
3333

34-
IL0373_PANEL_SETTING = const(0x00)
3534
IL0373_POWER_SETTING = const(0x01)
35+
IL0373_PANEL_SETTING = const(0x00)
3636
IL0373_POWER_OFF = const(0x02)
3737
IL0373_POWER_OFF_SEQUENCE = const(0x03)
3838
IL0373_POWER_ON = const(0x04)
@@ -59,9 +59,9 @@
5959
class Adafruit_IL0373(Adafruit_EPD):
6060
"""driver class for Adafruit IL0373 ePaper display breakouts"""
6161
# pylint: disable=too-many-arguments
62-
def __init__(self, width, height, rst_pin, dc_pin, busy_pin, srcs_pin, cs_pin, spi):
63-
super(Adafruit_IL0373, self).__init__(width, height, rst_pin, dc_pin, busy_pin,
64-
srcs_pin, cs_pin, spi)
62+
def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin):
63+
super(Adafruit_IL0373, self).__init__(width, height, spi, cs_pin, dc_pin,
64+
sramcs_pin, rst_pin, busy_pin)
6565

6666
self.bw_bufsize = int(width * height / 8)
6767
self.red_bufsize = int(width * height / 8)
@@ -81,8 +81,11 @@ def update(self):
8181
"""update the display"""
8282
self.command(IL0373_DISPLAY_REFRESH)
8383

84-
while self._busy.value is False:
85-
pass
84+
if self._busy:
85+
while self._busy.value is False:
86+
pass
87+
else:
88+
time.sleep(15) # wait 15 seconds
8689

8790
self.command(IL0373_CDI, bytearray([0x17]))
8891
self.command(IL0373_VCM_DC_SETTING, bytearray([0x00]))
@@ -93,9 +96,11 @@ def power_up(self):
9396
"""power up the display"""
9497
self.command(IL0373_POWER_ON)
9598

96-
while self._busy.value is False:
97-
pass
98-
99+
if self._busy:
100+
while self._busy.value is False:
101+
pass
102+
else:
103+
time.sleep(3) # wait a bit
99104
time.sleep(.2)
100105

101106
self.command(IL0373_PANEL_SETTING, bytearray([0xCF]))
@@ -221,7 +226,6 @@ def draw_pixel(self, x, y, color):
221226

222227
def fill(self, color):
223228
"""fill the screen with the passed color"""
224-
print("ffffil")
225229
red_fill = 0xFF
226230
black_fill = 0xFF
227231
if color == Adafruit_EPD.BLACK:

examples/epd_simpletest.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
display = Adafruit_IL0373(152, 152, rst, dc, busy, srcs, ecs, spi)
1717

1818
# clear the buffer
19-
display.clear_buffer()
19+
display.fill(Adafruit_EPD.WHITE)
2020

2121
r_width = 5
2222
r_pos = display.height
@@ -25,9 +25,10 @@
2525
while r_pos > display.height/2:
2626
if r_pos < display.height - 50:
2727
color = Adafruit_EPD.RED
28-
display.rect(display.width - r_pos, display.height - r_pos,
28+
display.rect(display.width - r_pos,
29+
display.height - r_pos,
2930
display.width - 2*(display.width - r_pos),
30-
display.height - 2*(display.height - r_pos), color)
31+
display.height - 2*(display.height - r_pos),
32+
color)
3133
r_pos = r_pos - r_width
32-
3334
display.display()

0 commit comments

Comments
 (0)