Skip to content

Commit 8fc5cae

Browse files
authored
Merge pull request #2 from tannewt/master
Add examples and lint
2 parents 73d94b1 + 9719109 commit 8fc5cae

10 files changed

+274
-15
lines changed

README.rst

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ Installing from PyPI
3131
.. note:: This library is not available on PyPI yet. Install documentation is included
3232
as a standard element. Stay tuned for PyPI availability!
3333

34-
.. todo:: Remove the above note if PyPI version is/will be available at time of release.
35-
If the library is not planned for PyPI, remove the entire 'Installing from PyPI' section.
36-
3734
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
3835
PyPI <https://pypi.org/project/adafruit-circuitpython-il0373/>`_. To install for current user:
3936

@@ -59,7 +56,46 @@ To install in a virtual environment in your current project:
5956
Usage Example
6057
=============
6158

62-
.. todo:: Add a quick, simple example. It and other examples should live in the examples folder and be included in docs/examples.rst.
59+
.. code-block: python
60+
61+
"""Simple test script for 2.13" 212x104 tri-color featherwing.
62+
63+
Supported products:
64+
* Adafruit 2.13" Tri-Color FeatherWing
65+
* https://www.adafruit.com/product/4128
66+
"""
67+
68+
import time
69+
import board
70+
import displayio
71+
import adafruit_il0373
72+
73+
displayio.release_displays()
74+
75+
epd_cs = board.D9
76+
epd_dc = board.D10
77+
78+
display_bus = displayio.FourWire(board.SPI(), command=epd_dc, chip_select=epd_cs, baudrate=1000000)
79+
time.sleep(1)
80+
81+
display = adafruit_il0373.IL0373(display_bus, width=212, height=104, rotation=90,
82+
highlight_color=0xff0000)
83+
84+
g = displayio.Group()
85+
86+
f = open("/display-ruler.bmp", "rb")
87+
88+
pic = displayio.OnDiskBitmap(f)
89+
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
90+
g.append(t)
91+
92+
display.show(g)
93+
94+
display.refresh()
95+
96+
print("refreshed")
97+
98+
time.sleep(120)
6399
64100
Contributing
65101
============

adafruit_il0373.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@
3333
3434
**Hardware:**
3535
36-
.. todo:: Add links to any specific hardware product page(s), or category page(s). Use unordered list & hyperlink rST
37-
inline format: "* `Link Text <url>`_"
36+
* `Adafruit 1.54" Tri-Color Display Breakout <https://www.adafruit.com/product/3625>`_
37+
* `Adafruit 2.13" Tri-Color Display Breakout <https://www.adafruit.com/product/4086>`_
38+
* `Adafruit Flexible 2.9" Black and White <https://www.adafruit.com/product/4262>`_
39+
* `Adafruit Flexible 2.13" Black and White <https://www.adafruit.com/product/4243>`_
40+
* `Adafruit 2.13" Tri-Color FeatherWing <https://www.adafruit.com/product/4128>`_
3841
3942
**Software and Dependencies:**
4043
@@ -64,11 +67,10 @@
6467
b"\x82\x01\x00" # VCM DC and delay 50ms
6568
b"\x02\x00" # Power off
6669
)
67-
6870
# pylint: disable=too-few-public-methods
6971
class IL0373(displayio.EPaperDisplay):
7072
"""IL0373 driver"""
71-
def __init__(self, bus, **kwargs):
73+
def __init__(self, bus, swap_rams=False, **kwargs):
7274
start_sequence = bytearray(_START_SEQUENCE)
7375

7476
width = kwargs["width"]
@@ -80,8 +82,21 @@ def __init__(self, bus, **kwargs):
8082
start_sequence[26] = width & 0xFF
8183
start_sequence[27] = (height >> 8) & 0xFF
8284
start_sequence[28] = height & 0xFF
85+
if swap_rams:
86+
color_bits_inverted = kwargs.get("black_bits_inverted", False)
87+
write_color_ram_command = 0x10
88+
black_bits_inverted = kwargs.get("color_bits_inverted", True)
89+
write_black_ram_command = 0x13
90+
else:
91+
write_black_ram_command = 0x10
92+
write_color_ram_command = 0x13
93+
color_bits_inverted = kwargs.get("color_bits_inverted", True)
94+
black_bits_inverted = kwargs.get("black_bits_inverted", False)
8395
super().__init__(bus, start_sequence, _STOP_SEQUENCE, **kwargs,
8496
ram_width=160, ram_height=296,
8597
busy_state=False,
86-
write_black_ram_command=0x10, write_color_ram_command=0x13,
87-
color_bits_inverted=True, refresh_display_command=0x12)
98+
write_black_ram_command=write_black_ram_command,
99+
write_color_ram_command=write_color_ram_command,
100+
black_bits_inverted=black_bits_inverted,
101+
color_bits_inverted=color_bits_inverted,
102+
refresh_display_command=0x12)

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# Uncomment the below if you use native CircuitPython modules such as
2121
# digitalio, micropython and busio. List the modules you use. Without it, the
2222
# autodoc module docs will fail to generate with a warning.
23-
# autodoc_mock_imports = ["digitalio", "busio"]
23+
autodoc_mock_imports = ["displayio"]
2424

2525

2626
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}

docs/index.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26-
.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave
27-
the toctree above for use later.
26+
Adafruit eInk Display Breakouts <https://learn.adafruit.com/adafruit-eink-display-breakouts>
2827

2928
.. toctree::
3029
:caption: Related Products
3130

32-
.. todo:: Add any product links here. If there are none, then simply delete this todo and leave
33-
the toctree above for use later.
31+
Adafruit 1.54" Tri-Color Display Breakout <https://www.adafruit.com/product/3625>
32+
Adafruit 2.13" Tri-Color Display Breakout <https://www.adafruit.com/product/4086>
33+
Adafruit Flexible 2.9" Black and White <https://www.adafruit.com/product/4262>
34+
Adafruit Flexible 2.13" Black and White <https://www.adafruit.com/product/4243>
35+
Adafruit 2.13" Tri-Color FeatherWing <https://www.adafruit.com/product/4128>
3436

3537
.. toctree::
3638
:caption: Other Links

examples/display-ruler.bmp

352 KB
Binary file not shown.

examples/il0373_1.54_color.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""Simple test script for 1.54" 152x152 tri-color display.
2+
3+
Supported products:
4+
* Adafruit 1.54" Tri-Color Display Breakout
5+
* https://www.adafruit.com/product/3625
6+
"""
7+
8+
import time
9+
import board
10+
import displayio
11+
import adafruit_il0373
12+
13+
displayio.release_displays()
14+
15+
# This pinout works on a Feather M4 and may need to be altered for other boards.
16+
spi = board.SPI() # Uses SCK and MOSI
17+
epd_cs = board.D9
18+
epd_dc = board.D10
19+
epd_reset = board.D5
20+
epd_busy = board.D6
21+
22+
display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset,
23+
baudrate=1000000)
24+
time.sleep(1)
25+
26+
display = adafruit_il0373.IL0373(display_bus, width=152, height=152, busy_pin=epd_busy,
27+
highlight_color=0xff0000)
28+
29+
g = displayio.Group()
30+
31+
f = open("/display-ruler.bmp", "rb")
32+
33+
pic = displayio.OnDiskBitmap(f)
34+
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
35+
g.append(t)
36+
37+
display.show(g)
38+
39+
display.refresh()
40+
41+
print("refreshed")
42+
43+
time.sleep(120)

examples/il0373_2.13_color.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""Simple test script for 2.13" 212x104 tri-color display.
2+
3+
Supported products:
4+
* Adafruit 2.13" Tri-Color Display Breakout
5+
* https://www.adafruit.com/product/4086
6+
"""
7+
8+
import time
9+
import board
10+
import displayio
11+
import adafruit_il0373
12+
13+
displayio.release_displays()
14+
15+
# This pinout works on a Feather M4 and may need to be altered for other boards.
16+
spi = board.SPI() # Uses SCK and MOSI
17+
epd_cs = board.D9
18+
epd_dc = board.D10
19+
epd_reset = board.D5
20+
epd_busy = board.D6
21+
22+
display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset,
23+
baudrate=1000000)
24+
time.sleep(1)
25+
26+
display = adafruit_il0373.IL0373(display_bus, width=212, height=104, rotation=90, busy_pin=epd_busy,
27+
highlight_color=0xff0000)
28+
29+
g = displayio.Group()
30+
31+
f = open("/display-ruler.bmp", "rb")
32+
33+
pic = displayio.OnDiskBitmap(f)
34+
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
35+
g.append(t)
36+
37+
display.show(g)
38+
39+
display.refresh()
40+
41+
print("refreshed")
42+
43+
time.sleep(120)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""Simple test script for 2.13" 212x104 monochrome display.
2+
3+
Supported products:
4+
* Adafruit Flexible 2.13" Monochrome
5+
* https://www.adafruit.com/product/4243
6+
"""
7+
8+
import time
9+
import board
10+
import displayio
11+
import adafruit_il0373
12+
13+
displayio.release_displays()
14+
15+
# This pinout works on a Feather M4 and may need to be altered for other boards.
16+
spi = board.SPI() # Uses SCK and MOSI
17+
epd_cs = board.D9
18+
epd_dc = board.D10
19+
epd_reset = board.D5
20+
epd_busy = board.D6
21+
22+
display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset,
23+
baudrate=1000000)
24+
time.sleep(1)
25+
26+
display = adafruit_il0373.IL0373(display_bus, width=212, height=104, rotation=90, busy_pin=epd_busy,
27+
swap_rams=True)
28+
29+
g = displayio.Group()
30+
31+
f = open("/display-ruler.bmp", "rb")
32+
33+
pic = displayio.OnDiskBitmap(f)
34+
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
35+
g.append(t)
36+
37+
display.show(g)
38+
39+
display.refresh()
40+
41+
time.sleep(120)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""Simple test script for 2.9" 296x128 monochrome display.
2+
3+
Supported products:
4+
* Adafruit Flexible 2.9" Monochrome
5+
* https://www.adafruit.com/product/4262
6+
"""
7+
8+
import time
9+
import board
10+
import displayio
11+
import adafruit_il0373
12+
13+
displayio.release_displays()
14+
15+
# This pinout works on a Feather M4 and may need to be altered for other boards.
16+
spi = board.SPI() # Uses SCK and MOSI
17+
epd_cs = board.D9
18+
epd_dc = board.D10
19+
epd_reset = board.D5
20+
epd_busy = board.D6
21+
22+
display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset,
23+
baudrate=1000000)
24+
time.sleep(1)
25+
26+
display = adafruit_il0373.IL0373(display_bus, width=296, height=128, rotation=90, busy_pin=epd_busy,
27+
swap_rams=True)
28+
29+
g = displayio.Group()
30+
31+
f = open("/display-ruler.bmp", "rb")
32+
33+
pic = displayio.OnDiskBitmap(f)
34+
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
35+
g.append(t)
36+
37+
display.show(g)
38+
39+
display.refresh()
40+
41+
time.sleep(120)

examples/il0373_simpletest.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Simple test script for 2.13" 212x104 tri-color featherwing.
2+
3+
Supported products:
4+
* Adafruit 2.13" Tri-Color FeatherWing
5+
* https://www.adafruit.com/product/4128
6+
"""
7+
8+
import time
9+
import board
10+
import displayio
11+
import adafruit_il0373
12+
13+
displayio.release_displays()
14+
15+
epd_cs = board.D9
16+
epd_dc = board.D10
17+
18+
display_bus = displayio.FourWire(board.SPI(), command=epd_dc, chip_select=epd_cs, baudrate=1000000)
19+
time.sleep(1)
20+
21+
display = adafruit_il0373.IL0373(display_bus, width=212, height=104, rotation=90,
22+
highlight_color=0xff0000)
23+
24+
g = displayio.Group()
25+
26+
f = open("/display-ruler.bmp", "rb")
27+
28+
pic = displayio.OnDiskBitmap(f)
29+
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
30+
g.append(t)
31+
32+
display.show(g)
33+
34+
display.refresh()
35+
36+
print("refreshed")
37+
38+
time.sleep(120)

0 commit comments

Comments
 (0)