Skip to content

Add examples and lint #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ Installing from PyPI
.. note:: This library is not available on PyPI yet. Install documentation is included
as a standard element. Stay tuned for PyPI availability!

.. todo:: Remove the above note if PyPI version is/will be available at time of release.
If the library is not planned for PyPI, remove the entire 'Installing from PyPI' section.

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
PyPI <https://pypi.org/project/adafruit-circuitpython-il0373/>`_. To install for current user:

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

.. todo:: Add a quick, simple example. It and other examples should live in the examples folder and be included in docs/examples.rst.
.. code-block: python

"""Simple test script for 2.13" 212x104 tri-color featherwing.

Supported products:
* Adafruit 2.13" Tri-Color FeatherWing
* https://www.adafruit.com/product/4128
"""

import time
import board
import displayio
import adafruit_il0373

displayio.release_displays()

epd_cs = board.D9
epd_dc = board.D10

display_bus = displayio.FourWire(board.SPI(), command=epd_dc, chip_select=epd_cs, baudrate=1000000)
time.sleep(1)

display = adafruit_il0373.IL0373(display_bus, width=212, height=104, rotation=90,
highlight_color=0xff0000)

g = displayio.Group()

f = open("/display-ruler.bmp", "rb")

pic = displayio.OnDiskBitmap(f)
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
g.append(t)

display.show(g)

display.refresh()

print("refreshed")

time.sleep(120)

Contributing
============
Expand Down
27 changes: 21 additions & 6 deletions adafruit_il0373.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@

**Hardware:**

.. todo:: Add links to any specific hardware product page(s), or category page(s). Use unordered list & hyperlink rST
inline format: "* `Link Text <url>`_"
* `Adafruit 1.54" Tri-Color Display Breakout <https://www.adafruit.com/product/3625>`_
* `Adafruit 2.13" Tri-Color Display Breakout <https://www.adafruit.com/product/4086>`_
* `Adafruit Flexible 2.9" Black and White <https://www.adafruit.com/product/4262>`_
* `Adafruit Flexible 2.13" Black and White <https://www.adafruit.com/product/4243>`_
* `Adafruit 2.13" Tri-Color FeatherWing <https://www.adafruit.com/product/4128>`_

**Software and Dependencies:**

Expand Down Expand Up @@ -64,11 +67,10 @@
b"\x82\x01\x00" # VCM DC and delay 50ms
b"\x02\x00" # Power off
)

# pylint: disable=too-few-public-methods
class IL0373(displayio.EPaperDisplay):
"""IL0373 driver"""
def __init__(self, bus, **kwargs):
def __init__(self, bus, swap_rams=False, **kwargs):
start_sequence = bytearray(_START_SEQUENCE)

width = kwargs["width"]
Expand All @@ -80,8 +82,21 @@ def __init__(self, bus, **kwargs):
start_sequence[26] = width & 0xFF
start_sequence[27] = (height >> 8) & 0xFF
start_sequence[28] = height & 0xFF
if swap_rams:
color_bits_inverted = kwargs.get("black_bits_inverted", False)
write_color_ram_command = 0x10
black_bits_inverted = kwargs.get("color_bits_inverted", True)
write_black_ram_command = 0x13
else:
write_black_ram_command = 0x10
write_color_ram_command = 0x13
color_bits_inverted = kwargs.get("color_bits_inverted", True)
black_bits_inverted = kwargs.get("black_bits_inverted", False)
super().__init__(bus, start_sequence, _STOP_SEQUENCE, **kwargs,
ram_width=160, ram_height=296,
busy_state=False,
write_black_ram_command=0x10, write_color_ram_command=0x13,
color_bits_inverted=True, refresh_display_command=0x12)
write_black_ram_command=write_black_ram_command,
write_color_ram_command=write_color_ram_command,
black_bits_inverted=black_bits_inverted,
color_bits_inverted=color_bits_inverted,
refresh_display_command=0x12)
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
# autodoc_mock_imports = ["digitalio", "busio"]
autodoc_mock_imports = ["displayio"]


intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
Expand Down
10 changes: 6 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ Table of Contents
.. toctree::
:caption: Tutorials

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

.. toctree::
:caption: Related Products

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

.. toctree::
:caption: Other Links
Expand Down
Binary file added examples/display-ruler.bmp
Binary file not shown.
43 changes: 43 additions & 0 deletions examples/il0373_1.54_color.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Simple test script for 1.54" 152x152 tri-color display.

Supported products:
* Adafruit 1.54" Tri-Color Display Breakout
* https://www.adafruit.com/product/3625
"""

import time
import board
import displayio
import adafruit_il0373

displayio.release_displays()

# This pinout works on a Feather M4 and may need to be altered for other boards.
spi = board.SPI() # Uses SCK and MOSI
epd_cs = board.D9
epd_dc = board.D10
epd_reset = board.D5
epd_busy = board.D6

display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset,
baudrate=1000000)
time.sleep(1)

display = adafruit_il0373.IL0373(display_bus, width=152, height=152, busy_pin=epd_busy,
highlight_color=0xff0000)

g = displayio.Group()

f = open("/display-ruler.bmp", "rb")

pic = displayio.OnDiskBitmap(f)
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
g.append(t)

display.show(g)

display.refresh()

print("refreshed")

time.sleep(120)
43 changes: 43 additions & 0 deletions examples/il0373_2.13_color.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Simple test script for 2.13" 212x104 tri-color display.

Supported products:
* Adafruit 2.13" Tri-Color Display Breakout
* https://www.adafruit.com/product/4086
"""

import time
import board
import displayio
import adafruit_il0373

displayio.release_displays()

# This pinout works on a Feather M4 and may need to be altered for other boards.
spi = board.SPI() # Uses SCK and MOSI
epd_cs = board.D9
epd_dc = board.D10
epd_reset = board.D5
epd_busy = board.D6

display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset,
baudrate=1000000)
time.sleep(1)

display = adafruit_il0373.IL0373(display_bus, width=212, height=104, rotation=90, busy_pin=epd_busy,
highlight_color=0xff0000)

g = displayio.Group()

f = open("/display-ruler.bmp", "rb")

pic = displayio.OnDiskBitmap(f)
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
g.append(t)

display.show(g)

display.refresh()

print("refreshed")

time.sleep(120)
41 changes: 41 additions & 0 deletions examples/il0373_flexible_2.13_monochrome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Simple test script for 2.13" 212x104 monochrome display.

Supported products:
* Adafruit Flexible 2.13" Monochrome
* https://www.adafruit.com/product/4243
"""

import time
import board
import displayio
import adafruit_il0373

displayio.release_displays()

# This pinout works on a Feather M4 and may need to be altered for other boards.
spi = board.SPI() # Uses SCK and MOSI
epd_cs = board.D9
epd_dc = board.D10
epd_reset = board.D5
epd_busy = board.D6

display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset,
baudrate=1000000)
time.sleep(1)

display = adafruit_il0373.IL0373(display_bus, width=212, height=104, rotation=90, busy_pin=epd_busy,
swap_rams=True)

g = displayio.Group()

f = open("/display-ruler.bmp", "rb")

pic = displayio.OnDiskBitmap(f)
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
g.append(t)

display.show(g)

display.refresh()

time.sleep(120)
41 changes: 41 additions & 0 deletions examples/il0373_flexible_2.9_monochrome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Simple test script for 2.9" 296x128 monochrome display.

Supported products:
* Adafruit Flexible 2.9" Monochrome
* https://www.adafruit.com/product/4262
"""

import time
import board
import displayio
import adafruit_il0373

displayio.release_displays()

# This pinout works on a Feather M4 and may need to be altered for other boards.
spi = board.SPI() # Uses SCK and MOSI
epd_cs = board.D9
epd_dc = board.D10
epd_reset = board.D5
epd_busy = board.D6

display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset,
baudrate=1000000)
time.sleep(1)

display = adafruit_il0373.IL0373(display_bus, width=296, height=128, rotation=90, busy_pin=epd_busy,
swap_rams=True)

g = displayio.Group()

f = open("/display-ruler.bmp", "rb")

pic = displayio.OnDiskBitmap(f)
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
g.append(t)

display.show(g)

display.refresh()

time.sleep(120)
38 changes: 38 additions & 0 deletions examples/il0373_simpletest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""Simple test script for 2.13" 212x104 tri-color featherwing.

Supported products:
* Adafruit 2.13" Tri-Color FeatherWing
* https://www.adafruit.com/product/4128
"""

import time
import board
import displayio
import adafruit_il0373

displayio.release_displays()

epd_cs = board.D9
epd_dc = board.D10

display_bus = displayio.FourWire(board.SPI(), command=epd_dc, chip_select=epd_cs, baudrate=1000000)
time.sleep(1)

display = adafruit_il0373.IL0373(display_bus, width=212, height=104, rotation=90,
highlight_color=0xff0000)

g = displayio.Group()

f = open("/display-ruler.bmp", "rb")

pic = displayio.OnDiskBitmap(f)
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
g.append(t)

display.show(g)

display.refresh()

print("refreshed")

time.sleep(120)