From cc723fb9fb7053e7471fb2335d1324074af42305 Mon Sep 17 00:00:00 2001 From: Hel Gibbons Date: Thu, 23 Dec 2021 15:08:54 +0000 Subject: [PATCH 1/9] Fix 7 colour examples These examples now use inky.auto to detect the screen resolution, so should work on 4" and 5.7" Inkys. --- examples/7color/clear.py | 7 ++++--- examples/7color/cycle.py | 5 ++--- examples/7color/image.py | 10 ++++++---- examples/7color/stripes.py | 5 +++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/examples/7color/clear.py b/examples/7color/clear.py index 2e9a2b38..9666860f 100755 --- a/examples/7color/clear.py +++ b/examples/7color/clear.py @@ -1,10 +1,11 @@ #!/usr/bin/env python3 -import time -from inky.inky_uc8159 import Inky, CLEAN +import time +from inky.auto import auto +from inky.inky_uc8159 import CLEAN -inky = Inky() +inky = auto(ask_user=True, verbose=True) for _ in range(2): for y in range(inky.height - 1): diff --git a/examples/7color/cycle.py b/examples/7color/cycle.py index 313ed621..318ee01a 100755 --- a/examples/7color/cycle.py +++ b/examples/7color/cycle.py @@ -1,10 +1,9 @@ #!/usr/bin/env python3 import time -from inky.inky_uc8159 import Inky +from inky.auto import auto - -inky = Inky() +inky = auto(ask_user=True, verbose=True) colors = ['Black', 'White', 'Green', 'Blue', 'Red', 'Yellow', 'Orange'] diff --git a/examples/7color/image.py b/examples/7color/image.py index 2626adb5..5d570ced 100755 --- a/examples/7color/image.py +++ b/examples/7color/image.py @@ -3,9 +3,10 @@ import sys from PIL import Image -from inky.inky_uc8159 import Inky -inky = Inky() +from inky.auto import auto + +inky = auto(ask_user=True, verbose=True) saturation = 0.5 if len(sys.argv) == 1: @@ -15,9 +16,10 @@ sys.exit(1) image = Image.open(sys.argv[1]) +resizedimage = image.resize(inky.resolution) if len(sys.argv) > 2: saturation = float(sys.argv[2]) -inky.set_image(image, saturation=saturation) -inky.show() +inky.set_image(resizedimage, saturation=saturation) +inky.show() \ No newline at end of file diff --git a/examples/7color/stripes.py b/examples/7color/stripes.py index 8b9f0cdf..82008d44 100755 --- a/examples/7color/stripes.py +++ b/examples/7color/stripes.py @@ -1,10 +1,11 @@ #!/usr/bin/env python3 -from inky.inky_uc8159 import Inky +from inky.auto import auto + # To simulate: # from inky.mock import InkyMockImpression as Inky -inky = Inky() +inky = auto(ask_user=True, verbose=True) for y in range(inky.height - 1): color = y // (inky.height // 7) From e4db58e0090a623cbf9c5d671b697a67fdeb855b Mon Sep 17 00:00:00 2001 From: Hel Gibbons Date: Thu, 23 Dec 2021 15:27:49 +0000 Subject: [PATCH 2/9] linting --- examples/7color/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/7color/image.py b/examples/7color/image.py index 5d570ced..62fcc956 100755 --- a/examples/7color/image.py +++ b/examples/7color/image.py @@ -22,4 +22,4 @@ saturation = float(sys.argv[2]) inky.set_image(resizedimage, saturation=saturation) -inky.show() \ No newline at end of file +inky.show() From 48d8843b63e13f1dbd9e744c0d1c070639810cc4 Mon Sep 17 00:00:00 2001 From: Hel Gibbons Date: Thu, 23 Dec 2021 16:30:22 +0000 Subject: [PATCH 3/9] Add auto resizing to dither example --- examples/7color/advanced/dither.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/7color/advanced/dither.py b/examples/7color/advanced/dither.py index 7a67b774..7a82a5d5 100755 --- a/examples/7color/advanced/dither.py +++ b/examples/7color/advanced/dither.py @@ -3,7 +3,7 @@ import sys import hitherdither -from inky.inky_uc8159 import Inky +from inky import auto from PIL import Image print("""dither.py @@ -29,7 +29,7 @@ """) -inky = Inky() +inky = auto(ask_user=True, verbose=True) saturation = 0.5 # Saturation of palette thresholds = [64, 64, 64] # Threshold for snapping colours, I guess? @@ -45,17 +45,19 @@ palette = hitherdither.palette.Palette(inky._palette_blend(saturation, dtype='uint24')) image = Image.open(sys.argv[1]).convert("RGB") +image_resized = image.resize(inky.resolution) + # VERY slow (1m 40s on a Pi 4) - see https://github.com/hbldh/hitherdither for a list of methods -# image_dithered = hitherdither.diffusion.error_diffusion_dithering(image, palette, method="stucki", order=2) +# image_dithered = hitherdither.diffusion.error_diffusion_dithering(image_resized, palette, method="stucki", order=2) # Usably quick, your vanilla dithering -# image_dithered = hitherdither.ordered.bayer.bayer_dithering(image, palette, thresholds, order=8) +image_dithered = hitherdither.ordered.bayer.bayer_dithering(image_resized, palette, thresholds, order=8) # Usuably quick, half-tone comic-book feel, use order=4 for small dots and order=8 dot bigguns -image_dithered = hitherdither.ordered.cluster.cluster_dot_dithering(image, palette, thresholds, order=8) +#image_dithered = hitherdither.ordered.cluster.cluster_dot_dithering(image_resized, palette, thresholds, order=8) # VERY slow -# image_dithered = hitherdither.ordered.yliluoma.yliluomas_1_ordered_dithering(image, palette, order=8) +# image_dithered = hitherdither.ordered.yliluoma.yliluomas_1_ordered_dithering(image_resized, palette, order=8) inky.set_image(image_dithered.convert("P")) inky.show() From d79bda1edd40b097a4198596a6e381d8edc387a3 Mon Sep 17 00:00:00 2001 From: Hel Gibbons Date: Thu, 23 Dec 2021 16:32:22 +0000 Subject: [PATCH 4/9] linting dither example --- examples/7color/advanced/dither.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/7color/advanced/dither.py b/examples/7color/advanced/dither.py index 7a82a5d5..a4639707 100755 --- a/examples/7color/advanced/dither.py +++ b/examples/7color/advanced/dither.py @@ -54,7 +54,7 @@ image_dithered = hitherdither.ordered.bayer.bayer_dithering(image_resized, palette, thresholds, order=8) # Usuably quick, half-tone comic-book feel, use order=4 for small dots and order=8 dot bigguns -#image_dithered = hitherdither.ordered.cluster.cluster_dot_dithering(image_resized, palette, thresholds, order=8) +# image_dithered = hitherdither.ordered.cluster.cluster_dot_dithering(image_resized, palette, thresholds, order=8) # VERY slow # image_dithered = hitherdither.ordered.yliluoma.yliluomas_1_ordered_dithering(image_resized, palette, order=8) From 23332f4a6f6d20f701dd7f6484b5a49bdbe14b6b Mon Sep 17 00:00:00 2001 From: Hel Gibbons Date: Thu, 23 Dec 2021 17:15:32 +0000 Subject: [PATCH 5/9] Correct EEPROM info for Impression 4", tweak readme --- README.md | 34 +++++++++++++++++++--------------- library/inky/auto.py | 2 +- library/inky/eeprom.py | 1 + 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index fe000049..f66515af 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,20 @@ [![PyPi Package](https://img.shields.io/pypi/v/inky.svg)](https://pypi.python.org/pypi/inky) [![Python Versions](https://img.shields.io/pypi/pyversions/inky.svg)](https://pypi.python.org/pypi/inky) -Python library for the [Inky pHAT](https://shop.pimoroni.com/products/inky-phat) and [Inky wHAT](https://shop.pimoroni.com/products/inky-what) e-paper displays. +Python library for [Inky pHAT](https://shop.pimoroni.com/products/inky-phat), [Inky wHAT](https://shop.pimoroni.com/products/inky-what) and [Inky Impression](https://shop.pimoroni.com/?q=inky+impression) e-paper displays for Raspberry Pi. ## Inky pHAT -[Inky pHAT](https://shop.pimoroni.com/products/inky-phat) is a 212x104 pixel e-paper display, available in red/black/white, yellow/black/white and black/white. It's great for nametags and displaying very low frequency information such as a daily calendar or weather overview. +[Inky pHAT](https://shop.pimoroni.com/products/inky-phat) is a 250x122 pixel e-paper display, available in red/black/white, yellow/black/white and black/white. It's great for nametags and displaying very low frequency information such as a daily calendar or weather overview. ## Inky wHAT -[Inky wHAT](https://shop.pimoroni.com/products/inky-what) is a 400x300 pixel e-paper display available in red/black/white, yellow/black/white and black/white. It's got tons of resolution for detailed daily todo lists, multi-day weather forecasts, bus timetables and more. +[Inky wHAT](https://shop.pimoroni.com/products/inky-what) is a 400x300 pixel e-paper display available in red/black/white, yellow/black/white and black/white. It's got tons of resolution for detailed daily to-do lists, multi-day weather forecasts, bus timetables and more. + +## Inky Impression + +[Inky Impression](https://shop.pimoroni.com/?q=inky+impression) is our line of glorious 7 colour eInk displays, available in [4"](https://shop.pimoroni.com/products/inky-impression-4) (640 x 400 pixel) and [5.7"](https://shop.pimoroni.com/products/inky-impression-5-7) (600 x 448 pixel) flavours. They're packed with strong colours and perfect for displaying striking graphics or lots of data. # Installation @@ -36,27 +40,27 @@ You may need to use `sudo pip3` or `sudo pip` depending on your environment and # Usage -The library should be run with python 3 +The library should be run with Python 3. ## Auto Setup -Inky can try to automatically detect your board and set up accordingly: +Inky can try to automatically identify your board (from the information stored on its EEPROM) and set up accordingly. This is the easiest way to work with recent Inky displays. ```python from inky.auto import auto -board = auto() +display = auto() ``` You can then get the colour and resolution from the board: ```python -board.colour -board.resolution +display.colour +display.resolution ``` ## Manual Setup -The Inky library contains modules for both the pHAT and wHAT, load the InkyPHAT one as follows: +If you have an older Inky without an EEPROM, you can specify the type manually. The Inky library contains modules for both the pHAT and wHAT, load the Inky pHAT one as follows: ```python from inky import InkyPHAT @@ -65,14 +69,14 @@ from inky import InkyPHAT You'll then need to pick your colour, one of 'red', 'yellow' or 'black' and instantiate the class: ```python -inkyphat = InkyPHAT('red') +display = InkyPHAT('red') ``` If you're using the wHAT you'll need to load the InkyWHAT class from the Inky library like so: ```python from inky import InkyWHAT -inkywhat = InkyWHAT('red') +display = InkyWHAT('red') ``` Once you've initialised Inky, there are only three methods you need to be concerned with: @@ -82,7 +86,7 @@ Once you've initialised Inky, there are only three methods you need to be concer Set a PIL image, numpy array or list to Inky's internal buffer. The image dimensions should match the dimensions of the pHAT or wHAT you're using. ```python -inkyphat.set_image(image) +display.set_image(image) ``` You should use `PIL` to create an image. `PIL` provides an `ImageDraw` module which allow you to draw text, lines and shapes over your image. See: https://pillow.readthedocs.io/en/stable/reference/ImageDraw.html @@ -92,7 +96,7 @@ You should use `PIL` to create an image. `PIL` provides an `ImageDraw` module wh Set the border colour of you pHAT or wHAT. ```python -inkyphat.set_border(colour) +display.set_border(colour) ``` `colour` should be one of `inky.RED`, `inky.YELLOW`, `inky.WHITE` or `inky.BLACK` with available colours depending on your display type. @@ -102,10 +106,10 @@ inkyphat.set_border(colour) Once you've prepared and set your image, and chosen a border colour, you can update your e-ink display with: ```python -inkyphat.show() +display.show() ``` # Migrating -If you're migrating code from the `inkyphat` library you'll find that much of the drawing and image manipulation functions have been removed from Inky. These functions were always supplied by PIL, and the recommended approach is to use PIL to create and prepare your image before setting it to Inky with `set_image()`. +If you're migrating code from the old `inkyphat` library you'll find that much of the drawing and image manipulation functions have been removed from Inky. These functions were always supplied by PIL, and the recommended approach is to use PIL to create and prepare your image before setting it to Inky with `set_image()`. diff --git a/library/inky/auto.py b/library/inky/auto.py index 49cc17fc..a3a1ce8c 100644 --- a/library/inky/auto.py +++ b/library/inky/auto.py @@ -22,7 +22,7 @@ def auto(i2c_bus=None, ask_user=False, verbose=False): return InkyWHAT(_eeprom.get_color()) if _eeprom.display_variant == 14: return InkyUC8159() - if _eeprom.display_variant == 15: + if _eeprom.display_variant in (15, 16): return InkyUC8159(resolution=(640, 400)) if ask_user: diff --git a/library/inky/eeprom.py b/library/inky/eeprom.py index bfb1ed60..88a28df3 100644 --- a/library/inky/eeprom.py +++ b/library/inky/eeprom.py @@ -26,6 +26,7 @@ 'Yellow pHAT (SSD1608)', None, '7-Colour (UC8159)', + None, '7-Colour 640x400 (UC8159)' ] From 167972262ff2d16c20cbe4afd0471d3366740393 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 24 Dec 2021 19:27:17 +0000 Subject: [PATCH 6/9] UC8159: Test, fix and refactor --- library/inky/auto.py | 2 +- library/inky/inky_uc8159.py | 29 ++++++++++++++++------------- library/tests/conftest.py | 8 ++++++++ library/tests/test_eeprom.py | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 14 deletions(-) create mode 100644 library/tests/test_eeprom.py diff --git a/library/inky/auto.py b/library/inky/auto.py index a3a1ce8c..e13bf4d7 100644 --- a/library/inky/auto.py +++ b/library/inky/auto.py @@ -21,7 +21,7 @@ def auto(i2c_bus=None, ask_user=False, verbose=False): if _eeprom.display_variant in (2, 3, 6, 7, 8): return InkyWHAT(_eeprom.get_color()) if _eeprom.display_variant == 14: - return InkyUC8159() + return InkyUC8159(resolution=(600, 448)) if _eeprom.display_variant in (15, 16): return InkyUC8159(resolution=(640, 400)) diff --git a/library/inky/inky_uc8159.py b/library/inky/inky_uc8159.py index 49446f97..0af8649d 100644 --- a/library/inky/inky_uc8159.py +++ b/library/inky/inky_uc8159.py @@ -86,9 +86,12 @@ _SPI_COMMAND = 0 _SPI_DATA = 1 +_RESOLUTION_5_7_INCH = (600, 448) # Inky Impression 5.7" +_RESOLUTION_4_INCH = (640, 400) # Inky Impression 4" + _RESOLUTION = { - (600, 448): (600, 448, 0, 0, 0, 0b11), - (640, 400): (640, 400, 0, 0, 0, 0b10) + _RESOLUTION_5_7_INCH: (_RESOLUTION_5_7_INCH[0], _RESOLUTION_5_7_INCH[1], 0, 0, 0, 0b11), + _RESOLUTION_4_INCH: (_RESOLUTION_4_INCH[0], _RESOLUTION_4_INCH[1], 0, 0, 0, 0b10) } @@ -107,7 +110,7 @@ class Inky: WIDTH = 600 HEIGHT = 448 - def __init__(self, resolution=(600, 448), colour='multi', cs_pin=CS0_PIN, dc_pin=DC_PIN, reset_pin=RESET_PIN, busy_pin=BUSY_PIN, h_flip=False, v_flip=False, spi_bus=None, i2c_bus=None, gpio=None): # noqa: E501 + def __init__(self, resolution=None, colour='multi', cs_pin=CS0_PIN, dc_pin=DC_PIN, reset_pin=RESET_PIN, busy_pin=BUSY_PIN, h_flip=False, v_flip=False, spi_bus=None, i2c_bus=None, gpio=None): # noqa: E501 """Initialise an Inky Display. :param resolution: (width, height) in pixels, default: (600, 448) @@ -122,6 +125,15 @@ def __init__(self, resolution=(600, 448), colour='multi', cs_pin=CS0_PIN, dc_pin """ self._spi_bus = spi_bus self._i2c_bus = i2c_bus + self.eeprom = eeprom.read_eeprom(i2c_bus=i2c_bus) + + # Check for supported display variant and select the correct resolution + # Eg: 600x480 and 640x400 + if resolution is None: + if self.eeprom is not None and self.eeprom.display_variant in (14, 15, 16): + resolution = [_RESOLUTION_5_7_INCH, None, _RESOLUTION_4_INCH][self.eeprom.display_variant - 14] + else: + resolution = _RESOLUTION_5_7_INCH if resolution not in _RESOLUTION.keys(): raise ValueError('Resolution {}x{} not supported!'.format(*resolution)) @@ -135,17 +147,8 @@ def __init__(self, resolution=(600, 448), colour='multi', cs_pin=CS0_PIN, dc_pin raise ValueError('Colour {} is not supported!'.format(colour)) self.colour = colour - self.eeprom = eeprom.read_eeprom(i2c_bus=i2c_bus) self.lut = colour - - # Check for supported display variant and select the correct resolution - # Eg: 600x480 and 640x400 - if self.eeprom is not None and self.eeprom.display_variant in (14, 15): - eeprom_resolution = _RESOLUTION.keys[self.eeprom.display_variant - 14] - self.resolution = eeprom_resolution - self.width, self.height = eeprom_resolution - self.cols, self.rows, self.rotation, self.offset_x, self.offset_y, self.resolution_setting = _RESOLUTION[eeprom_resolution] - + self.buf = numpy.zeros((self.rows, self.cols), dtype=numpy.uint8) self.dc_pin = dc_pin diff --git a/library/tests/conftest.py b/library/tests/conftest.py index 324335f7..f5a711d6 100644 --- a/library/tests/conftest.py +++ b/library/tests/conftest.py @@ -33,6 +33,14 @@ def smbus2(): del sys.modules['smbus2'] +@pytest.fixture(scope='function', autouse=False) +def smbus2_eeprom(): + """Mock smbus2 module.""" + sys.modules['smbus2'] = mock.MagicMock() + yield sys.modules['smbus2'] + del sys.modules['smbus2'] + + @pytest.fixture(scope='function', autouse=False) def spidev(): """Mock spidev module.""" diff --git a/library/tests/test_eeprom.py b/library/tests/test_eeprom.py new file mode 100644 index 00000000..4bdfea90 --- /dev/null +++ b/library/tests/test_eeprom.py @@ -0,0 +1,32 @@ +"""EEPROM tests for Inky.""" + +import mock +import pytest + + +def test_eeprom_7color_7inch(spidev, smbus2_eeprom, PIL): + """Test EEPROM for 7color 7" Inky""" + from inky.inky_uc8159 import Inky + from inky.eeprom import EPDType + + eeprom_data = EPDType(600, 448, 0, 0, 14).encode() + + smbus2_eeprom.SMBus(1).read_i2c_block_data.return_value = eeprom_data + + inky = Inky() + + assert inky.resolution == (600, 448) + + +def test_eeprom_7color_5inch(spidev, smbus2_eeprom, PIL): + """Test EEPROM for 7color 5" Inky""" + from inky.inky_uc8159 import Inky + from inky.eeprom import EPDType + + eeprom_data = EPDType(640, 400, 0, 0, 16).encode() + + smbus2_eeprom.SMBus(1).read_i2c_block_data.return_value = eeprom_data + + inky = Inky() + + assert inky.resolution == (640, 400) From 2fd500e3138a33a3b85fd6e86de3959d4aa67521 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 24 Dec 2021 19:36:18 +0000 Subject: [PATCH 7/9] U8159: Longer busy timeout from #136 --- library/inky/inky_uc8159.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/inky/inky_uc8159.py b/library/inky/inky_uc8159.py index 0af8649d..50334cef 100644 --- a/library/inky/inky_uc8159.py +++ b/library/inky/inky_uc8159.py @@ -293,7 +293,7 @@ def setup(self): UC8159_PFS, [0x00] # PFS_1_FRAME ) - def _busy_wait(self, timeout=30.0): + def _busy_wait(self, timeout=60.0): """Wait for busy/wait pin.""" t_start = time.time() while not self._gpio.input(self.busy_pin): From 7a78f42306b9e9cdd421737e18aac2e7b69ea171 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 24 Dec 2021 19:50:34 +0000 Subject: [PATCH 8/9] UC8159: Linting & tweaks --- library/inky/inky_uc8159.py | 2 +- library/tests/test_eeprom.py | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/library/inky/inky_uc8159.py b/library/inky/inky_uc8159.py index 50334cef..d6f2ad2f 100644 --- a/library/inky/inky_uc8159.py +++ b/library/inky/inky_uc8159.py @@ -148,7 +148,7 @@ def __init__(self, resolution=None, colour='multi', cs_pin=CS0_PIN, dc_pin=DC_PI self.colour = colour self.lut = colour - + self.buf = numpy.zeros((self.rows, self.cols), dtype=numpy.uint8) self.dc_pin = dc_pin diff --git a/library/tests/test_eeprom.py b/library/tests/test_eeprom.py index 4bdfea90..545528f0 100644 --- a/library/tests/test_eeprom.py +++ b/library/tests/test_eeprom.py @@ -1,11 +1,8 @@ """EEPROM tests for Inky.""" -import mock -import pytest - -def test_eeprom_7color_7inch(spidev, smbus2_eeprom, PIL): - """Test EEPROM for 7color 7" Inky""" +def test_eeprom_7color_5_7_inch(spidev, smbus2_eeprom, PIL): + """Test EEPROM for 7color 5.7" Inky""" from inky.inky_uc8159 import Inky from inky.eeprom import EPDType @@ -18,8 +15,8 @@ def test_eeprom_7color_7inch(spidev, smbus2_eeprom, PIL): assert inky.resolution == (600, 448) -def test_eeprom_7color_5inch(spidev, smbus2_eeprom, PIL): - """Test EEPROM for 7color 5" Inky""" +def test_eeprom_7color_4_inch(spidev, smbus2_eeprom, PIL): + """Test EEPROM for 7color 4" Inky""" from inky.inky_uc8159 import Inky from inky.eeprom import EPDType From 4e1005b9396e5043f08c0cb7ea4c838109ba671d Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 24 Dec 2021 20:31:14 +0000 Subject: [PATCH 9/9] Prep for v1.3.1 --- library/CHANGELOG.txt | 5 +++++ library/README.md | 38 +++++++++++++++++++++----------------- library/inky/__init__.py | 2 +- library/setup.py | 2 +- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/library/CHANGELOG.txt b/library/CHANGELOG.txt index 2cc9656c..18f77deb 100644 --- a/library/CHANGELOG.txt +++ b/library/CHANGELOG.txt @@ -1,3 +1,8 @@ +1.3.1 +----- + +* BugFix: unbreak UC8159 + 1.3.0 ----- diff --git a/library/README.md b/library/README.md index 97fd33ab..f66515af 100644 --- a/library/README.md +++ b/library/README.md @@ -5,26 +5,30 @@ [![PyPi Package](https://img.shields.io/pypi/v/inky.svg)](https://pypi.python.org/pypi/inky) [![Python Versions](https://img.shields.io/pypi/pyversions/inky.svg)](https://pypi.python.org/pypi/inky) -Python library for the [Inky pHAT](https://shop.pimoroni.com/products/inky-phat) and [Inky wHAT](https://shop.pimoroni.com/products/inky-what) e-paper displays. +Python library for [Inky pHAT](https://shop.pimoroni.com/products/inky-phat), [Inky wHAT](https://shop.pimoroni.com/products/inky-what) and [Inky Impression](https://shop.pimoroni.com/?q=inky+impression) e-paper displays for Raspberry Pi. ## Inky pHAT -[Inky pHAT](https://shop.pimoroni.com/products/inky-phat) is a 212x104 pixel e-paper display, available in red/black/white, yellow/black/white and black/white. It's great for nametags and displaying very low frequency information such as a daily calendar or weather overview. +[Inky pHAT](https://shop.pimoroni.com/products/inky-phat) is a 250x122 pixel e-paper display, available in red/black/white, yellow/black/white and black/white. It's great for nametags and displaying very low frequency information such as a daily calendar or weather overview. ## Inky wHAT -[Inky wHAT](https://shop.pimoroni.com/products/inky-what) is a 400x300 pixel e-paper display available in red/black/white, yellow/black/white and black/white. It's got tons of resolution for detailed daily todo lists, multi-day weather forecasts, bus timetables and more. +[Inky wHAT](https://shop.pimoroni.com/products/inky-what) is a 400x300 pixel e-paper display available in red/black/white, yellow/black/white and black/white. It's got tons of resolution for detailed daily to-do lists, multi-day weather forecasts, bus timetables and more. + +## Inky Impression + +[Inky Impression](https://shop.pimoroni.com/?q=inky+impression) is our line of glorious 7 colour eInk displays, available in [4"](https://shop.pimoroni.com/products/inky-impression-4) (640 x 400 pixel) and [5.7"](https://shop.pimoroni.com/products/inky-impression-5-7) (600 x 448 pixel) flavours. They're packed with strong colours and perfect for displaying striking graphics or lots of data. # Installation The Python pip package is named inky, on the Raspberry Pi install with: ``` -pip3 install inky[rpi,example-depends] +pip3 install inky[rpi,fonts] ``` -This will install Inky along with dependencies for the Raspberry Pi, plus modules used by the examples. +This will install Inky along with dependencies for the Raspberry Pi, plus fonts used by the examples. If you want to simulate Inky on your desktop, use: @@ -36,27 +40,27 @@ You may need to use `sudo pip3` or `sudo pip` depending on your environment and # Usage -The library should be run with python 3 +The library should be run with Python 3. ## Auto Setup -Inky can try to automatically detect your board and set up accordingly: +Inky can try to automatically identify your board (from the information stored on its EEPROM) and set up accordingly. This is the easiest way to work with recent Inky displays. ```python from inky.auto import auto -board = auto() +display = auto() ``` You can then get the colour and resolution from the board: ```python -board.colour -board.resolution +display.colour +display.resolution ``` ## Manual Setup -The Inky library contains modules for both the pHAT and wHAT, load the InkyPHAT one as follows: +If you have an older Inky without an EEPROM, you can specify the type manually. The Inky library contains modules for both the pHAT and wHAT, load the Inky pHAT one as follows: ```python from inky import InkyPHAT @@ -65,14 +69,14 @@ from inky import InkyPHAT You'll then need to pick your colour, one of 'red', 'yellow' or 'black' and instantiate the class: ```python -inkyphat = InkyPHAT('red') +display = InkyPHAT('red') ``` If you're using the wHAT you'll need to load the InkyWHAT class from the Inky library like so: ```python from inky import InkyWHAT -inkywhat = InkyWHAT('red') +display = InkyWHAT('red') ``` Once you've initialised Inky, there are only three methods you need to be concerned with: @@ -82,7 +86,7 @@ Once you've initialised Inky, there are only three methods you need to be concer Set a PIL image, numpy array or list to Inky's internal buffer. The image dimensions should match the dimensions of the pHAT or wHAT you're using. ```python -inkyphat.set_image(image) +display.set_image(image) ``` You should use `PIL` to create an image. `PIL` provides an `ImageDraw` module which allow you to draw text, lines and shapes over your image. See: https://pillow.readthedocs.io/en/stable/reference/ImageDraw.html @@ -92,7 +96,7 @@ You should use `PIL` to create an image. `PIL` provides an `ImageDraw` module wh Set the border colour of you pHAT or wHAT. ```python -inkyphat.set_border(colour) +display.set_border(colour) ``` `colour` should be one of `inky.RED`, `inky.YELLOW`, `inky.WHITE` or `inky.BLACK` with available colours depending on your display type. @@ -102,10 +106,10 @@ inkyphat.set_border(colour) Once you've prepared and set your image, and chosen a border colour, you can update your e-ink display with: ```python -inkyphat.show() +display.show() ``` # Migrating -If you're migrating code from the `inkyphat` library you'll find that much of the drawing and image manipulation functions have been removed from Inky. These functions were always supplied by PIL, and the recommended approach is to use PIL to create and prepare your image before setting it to Inky with `set_image()`. +If you're migrating code from the old `inkyphat` library you'll find that much of the drawing and image manipulation functions have been removed from Inky. These functions were always supplied by PIL, and the recommended approach is to use PIL to create and prepare your image before setting it to Inky with `set_image()`. diff --git a/library/inky/__init__.py b/library/inky/__init__.py index 95343a64..aecbc1c1 100644 --- a/library/inky/__init__.py +++ b/library/inky/__init__.py @@ -8,7 +8,7 @@ from .inky_uc8159 import Inky as Inky7Colour # noqa: F401 from .auto import auto # noqa: F401 -__version__ = '1.3.0' +__version__ = '1.3.1' try: from pkg_resources import declare_namespace diff --git a/library/setup.py b/library/setup.py index 637ae274..11425f24 100755 --- a/library/setup.py +++ b/library/setup.py @@ -38,7 +38,7 @@ setup( name='inky', - version='1.3.0', + version='1.3.1', author='Philip Howard', author_email='phil@pimoroni.com', description='Inky pHAT Driver',