Skip to content

Commit fde48fe

Browse files
authored
Merge pull request #5 from makermelissa/master
Added eInk Gizmo
2 parents c86935f + 5dccf38 commit fde48fe

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

adafruit_gizmo/eink_gizmo.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2019 Melissa LeBlanc-Williams 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_gizmo.tft_gizmo`
24+
================================================================================
25+
26+
Helper for the `Tri-Color E-Ink Gizmo <https://www.adafruit.com/product/4428>`_.
27+
28+
29+
* Author(s): Melissa LeBlanc-Williams
30+
"""
31+
32+
__version__ = "0.0.0-auto.0"
33+
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Gizmo.git"
34+
35+
from time import sleep
36+
import board
37+
import displayio
38+
from adafruit_il0373 import IL0373
39+
40+
# pylint: disable=invalid-name, too-few-public-methods
41+
class EInk_Gizmo(IL0373):
42+
"""Class representing a EInk Gizmo."""
43+
44+
def __init__(self, *, spi=None, cs=None, dc=None, reset=None, busy=None):
45+
displayio.release_displays()
46+
if spi is None:
47+
import busio
48+
spi = busio.SPI(board.SCL, MOSI=board.SDA)
49+
if cs is None:
50+
cs = board.RX
51+
if dc is None:
52+
dc = board.TX
53+
if reset is None:
54+
reset = board.A3
55+
self._display_bus = displayio.FourWire(spi,
56+
command=dc,
57+
chip_select=cs,
58+
reset=reset,
59+
baudrate=1000000)
60+
sleep(1)
61+
super().__init__(self._display_bus, width=152, height=152,
62+
busy_pin=busy, rotation=180,
63+
highlight_color=0xff0000)

examples/gizmo_eink_simpletest.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import time
2+
import displayio
3+
from adafruit_gizmo import eink_gizmo
4+
5+
display = eink_gizmo.EInk_Gizmo()
6+
7+
# Create a display group for our screen objects
8+
display_group = displayio.Group()
9+
10+
# Display a ruler graphic from the root directory of the CIRCUITPY drive
11+
file = open("/display-ruler.bmp", "rb")
12+
13+
picture = displayio.OnDiskBitmap(file)
14+
# Create a Tilegrid with the bitmap and put in the displayio group
15+
sprite = displayio.TileGrid(picture, pixel_shader=displayio.ColorConverter())
16+
display_group.append(sprite)
17+
18+
# Place the display group on the screen
19+
display.show(display_group)
20+
21+
# Refresh the display to have it actually show the image
22+
# NOTE: Do not refresh eInk displays sooner than 180 seconds
23+
display.refresh()
24+
print("refreshed")
25+
26+
time.sleep(180)

0 commit comments

Comments
 (0)