GithubHelp home page GithubHelp logo

pimoroni / inky Goto Github PK

View Code? Open in Web Editor NEW
552.0 24.0 117.0 12.33 MB

Combined library for V2/V3 Inky pHAT and Inky wHAT.

Home Page: https://shop.pimoroni.com/?q=inky

License: MIT License

Python 95.55% CSS 1.05% HTML 0.93% Makefile 1.79% Shell 0.68%
pypi-package

inky's Introduction

Inky

Build Status Coverage Status PyPi Package Python Versions

Python library for Inky pHAT, Inky wHAT and Inky Impression e-paper displays for Raspberry Pi.

Inky pHAT

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 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 is our line of glorious 7 colour eInk displays, available in 4" (640 x 400 pixel) 5.7" (600 x 448 pixel) and 7.3" (800 x 480 pixel) flavours. They're packed with strong colours and perfect for displaying striking graphics or lots of data.

Installation

First, make sure you have I2C and SPI enabled in sudo raspi-config.

The Python pip package is named inky, on the Raspberry Pi install with:

pip3 install inky[rpi,example-depends]

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:

pip3 install inky

You may need to use sudo pip3 or sudo pip depending on your environment and Python version.

Usage

The library should be run with Python 3.

Auto Setup

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.

from inky.auto import auto
display = auto()

You can then get the colour and resolution from the board:

display.colour
display.resolution

Manual Setup

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:

from inky import InkyPHAT

You'll then need to pick your colour, one of 'red', 'yellow' or 'black' and instantiate the class:

display = InkyPHAT('red')

If you're using the wHAT you'll need to load the InkyWHAT class from the Inky library like so:

from inky import InkyWHAT
display = InkyWHAT('red')

Once you've initialised Inky, there are only three methods you need to be concerned with:

Set Image

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.

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

Set Border

Set the border colour of you pHAT or wHAT.

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.

Update The Display

Once you've prepared and set your image, and chosen a border colour, you can update your e-ink display with:

display.show()

Migrating

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().

inky's People

Contributors

ageeandakeyboard avatar ajpoulter-soton avatar cluening avatar corranwebster avatar danieldulaney avatar danielssilva avatar davidskeck avatar daviehh avatar fisherthewol avatar francesco-vannini avatar gadgetoid avatar georgehall avatar helgibbons avatar jamesmconroy avatar jerbzz avatar jimmadge avatar joe-warren avatar jscd avatar missionfloyd avatar peacedealer avatar peteruithoven avatar sandyjmacdonald avatar trepidacious avatar unfinishedstuff avatar unsignedarduino avatar waveform80 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

inky's Issues

inky.set_border() from examples/7color/cycle.py is not implemented for inky_uc8159

Here is how it fails if you try to run "cycle" example for 7color (Inky Impression):

~/git/inky/examples/7color $ python3 cycle.py
Color: Black
Traceback (most recent call last):
  File "cycle.py", line 16, in <module>
    inky.set_border(color)
  File "/home/tango/.local/lib/python3.7/site-packages/inky/inky_uc8159.py", line 369, in set_border
    raise NotImplementedError
NotImplementedError

Mock version of inky doesn't work on windows anymore

On a windows desktop, it was possible to use install inky and use inky.mock to simulate an inky display.
Since spidev is a requirement for installing in more recent versions, and spidev is not available on windows, this is not possible anymore.
Is there an option to keep spidev optional or separate the mocking functionality/library from the actual implementation which needs spidev?

SPI mode for the Inky

Hello!

I am looking to use an Inky as well as another device on SPI. Looking through your code, you use SPI bus 0, which for the Pi, only allows for SPI modes 1 and 3 (i.e. CPOL, CPHA = 0,1 or 1,1).

Is your device able to operate on bus 1, which only allows for SPI modes 0 and 2 (i.e. CPOL, CPHA = 0,0 or 1,0)?

Cheers!

Inky pHat red, 1 electrode, EEPROM. Which version is it?

I bough an inky phat, the product page showed a screen with two electrodes. After reading this blog post I knew it was the right one to purchase.

Though, when it arrived the screen only had only one electrode. Disappointed, I desperately searched for an hypothetical v3 I hadn't heard about in order to avoid returning my inky.
Eventually I found what I was looking for: "We now populate an EEPROM on each Inky display in order to store information about the type and resolution of each display, but our current approach to reading and acting upon that EEPROM is suboptimal, too." (issue#53)

Also, it works with the new library (this one) and refreshes pretty quickly around 10s instead of 15s as advertised (not complaining here).

Here are pics to show you what I'm talking about:
https://imgur.com/a/jsb53Yo

It's going to go through some intensive use so I'd like to avoid the v1. I'm a bit confused, could you confirm why one electrode and an EEPROM? v1 screen but v3 PCB?

Thanks in advance.

FileNotFoundError: [Errno 2] No such file or directory

Sorry, the title of the issue isn't very helpful, but I'm not sure what the error actually is.

I got through all the issues with Pil, and wikiquotes to get to the point of testing it using the quotes-what.py example, but I haven't found a solution to this error:

$ python3 quotes-what.py --colour red
Inky wHAT: Quotes

Display quotes on Inky wHAT.

"Science and everyday life cannot
  and should not be separated."
- Rosalind Franklin

Traceback (most recent call last):
  File "quotes-what.py", line 165, in <module>
    inky_display.show()
  File "/usr/local/lib/python3.5/dist-packages/inky/inky.py", line 288, in show
    self._update(buf_a, buf_b)
  File "/usr/local/lib/python3.5/dist-packages/inky/inky.py", line 209, in _update
    self.setup()
  File "/usr/local/lib/python3.5/dist-packages/inky/inky.py", line 184, in setup
    self._spi.open(0, self.cs_pin)
FileNotFoundError: [Errno 2] No such file or directory

For context, I'm on a raspberry pi zero w with the latest Raspbian Stretch Lite (Version: April 2019).

I'd appreciate any troubleshooting recommendations.

einky on non-rpi?

Is there a repository for einky?
I'd like to be able to install it on non-raspberry-pi machines to test out code before putting it on a board, but the pip install requires rpi-gpio which seems to be a native module whose compilation fails locally.

[Question/Performance] Only convert and send bits for colour screen when red or yellow?

While reading the source for inspiration for an elixir port I'm contributing to, I found that there seems to be an unnecessary conversion of the pixels in the accent colour (currently, red or yellow) to bits, even though the screen might be black.

My question: Is it necessary to convert and transmit bits for red/yellow on black screens due to a quirk in the chip(s)/the implementation or can it be skipped?

The code in question: https://github.com/pimoroni/inky/blob/master/library/inky/inky.py#L278-L288

(sorry about the word-soup-y title 😬)

LUT info, and possibility to clear with black?

Hey there! Having fun tinkering with my inky pHAT! I've been adding new lookup tables to get a custom update sequence and wondered:

One step in the default B&W sequence is "clear the buffer" which makes the screen go entirely white. Is there a similar command or hex code that would clear with black instead of clearing with white?

Currently my custom sequence does this:

  1. Draw screen entirely with black or white pixels depending on next image, then run busy_wait
  2. Now draw screen with a custom LUT depending on whether we are drawing in from black or white, run busy_wait again

I'd like to remove step 1 from this sequence to speed things up. To do this, I need a way to clear the screen with white or black.

It actually already seems possible to clear to white using 0b10100000 in the LUT, which could potentially remove step 1 in the context of a white background. However, another issue #12 is preventing me from doing that, as for whatever reason the clear operation is resetting the border to black. In the case of black background, I am close to being able to remove step 1, but I need a flag that says "clear to black" instead of "clear to white," if such a thing exists.

Any ideas? 😄

Thanks!

update only part of the screen?

Is it possible to update only part of the screen?

The inky interface only seems to allow entire screen refresh. Would it be possible to update only part of the screen - even if this meant not using deep sleep this might make small updates a lot faster.

Can't get it to work on WaveShare 2.13inch e-Paper HAT (B)

I'm attempting to use Inky on my new WaveShare 2.13inch e-Paper HAT (B) but nothing shows up, just blank still.

I've installed everything and tried every example, but nadda. Is there a way for this to work? I want to leverage Inky for a pi-hole stats screen and from what I've read, this is very polished system and easy to use...

Using auto mode I get:

Traceback (most recent call last):
  File "logo.py", line 44, in <module>
    inky_display = auto()
  File "/home/pi/.local/lib/python3.7/site-packages/inky/auto.py", line 10, in auto
    raise RuntimeError("No EEPROM detected! You must manually initialise your Inky board.")
RuntimeError: No EEPROM detected! You must manually initialise your Inky board.

when I run it with the args is says it runs, but no display...

pi@raspberrypi:~/Pimoroni/inky/examples$ python3 logo.py --type "phat" --colour "red"
Inky pHAT/wHAT: Logo

Displays the Inky pHAT/wHAT logo.


pi@raspberrypi:~/Pimoroni/inky/examples$

example/weather-phat.py no longer works

Looks like Yahoo have finally removed their weather api:
Traceback (most recent call last):
File "weather-phat.py", line 106, in
weather = get_weather(location_string)
File "weather-phat.py", line 71, in get_weather
res = requests.get(uri)
File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/adapters.py", line 513, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='query.yahooapis.com', port=443): Max retries exceeded with url: /v1/public/yql?env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&format=json&q=select%20%2A%20from%20weather.forecast%20where%20woeid%20in%20%28select%20woeid%20from%20geo.places%281%29%20where%20text%3D%22Sheffield%2C%20GB%22%29 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x75320570>: Failed to establish a new connection: [Errno -5] No address associated with hostname',))

From developer.yahoo.com/weather:-
Important EOL Notice: As of Thursday, Jan. 3, 2019, the weather.yahooapis.com and query.yahooapis.com for Yahoo Weather API will be retired.

Is there another service that can be used instead?

inkyphat doesn't react at all

I did everything like in the "getting started" guide and when I use the examples I get expected outputs like " Hello... my name is:" and the description what is does. However on the device itself nothing happens, I only see the image that it arrived with. I have no Idea where to start looking for the problem

Required GPIO pins for Inky pHAT

Is there a definitive list of the pins required to use the Inky pHAT?

The inky module lists the following pins,

RESET_PIN = 27
BUSY_PIN = 17
DC_PIN = 22

MOSI_PIN = 10
SCLK_PIN = 11
CS0_PIN = 0

while pinout.xyz indicates the CS pin should be BCM8. The MOSI_PIN and SCLK_PIN variables also appear to be unused.

When I connected only the pins from the Python module (along with 3.3V and 5V power). Writing to the display hangs in _busy_wait. When I connect the pins from the pinout.xyz page, there is no hang but the display is not changed.

Making a mistake in connecting the jumpers notwithstanding, are there more pins that need to be connected? Is there something I have missed?

smbus not found

smbus wasn't installed automatically by the install script, it should include
sudo apt install python3-smbus and sudo apt install python2-smbus.

Cannot import from inky

I have a Raspberry Pi Zero with a clean fresh install of the Raspbian image from April, so still with Stretch. I did nothing but update the locale to en-us and set the timezone. Then I install inky as described in the readme.md and it is successful. I try to create a script with only

from inky import InkyPHAT
inkyphat = InkyPHAT('red')
inkyphat.set_border(inky.RED)
inkyphat.show()

but when I try to run it I get the following error:

Traceback (most recent call last):
File "inky.py", line 1, in
from inky import InkyPHAT
File "/home/pi/inky/inky.py", line 1, in
from inky import InkyPHAT
ImportError: cannot import name InkyPHAT

I tried the same with the new Buster image, same issue. I updated both to the latest packages and kernel, same error.

I'd appreciate any hint on what stupid little thing I'm not seeing.

Various documentation fixes

I just got my Inky, and it took a bit of investigating to get it figured out. The documentation provided here is missing some important details, would be great if you could add them. Note, I was using Buster, I'm not sure of these errors aren't valid for previous versions.

  1. Inky requires Python 3, it does not work on 2.

  2. You need to install a whole bunch of external dependencies with

     curl https://get.pimoroni.com/inky | bash
    

this is listed on https://learn.pimoroni.com/tutorial/sandyj/getting-started-with-inky-phat, it would be nice to have them here too.
3. The code examples in the readme of this repo and on the above Pimoroni don't work - I get lots of errors of type

    OSError: [Errno 2] No such file or directory: '/dev/i2c-1'
  1. To display a custom image on your Inky, it must be in Indexed color mode, and your color table must be locked to the colors of your Inky (I have a red unit, so my allowed colors were 000000, ffffff, and ff0000)

Palette definition of Orange in invalid

In inky_uc8159.py the color definition for Orange in the saturated palette is [77, 106, 73] (see line 44 of inky_uc8159.py).
These values are more greenish than orange.
I think there is a mistake in this RGB value.

Loading Images from file result in nothing being displayed

Hello! I'm encountering an issue when trying to display images on my Black/White Inky Phat.

I generate the image using PIL. I save it locally it looks good (see attached pic)

The way I save it is:

img.convert('P').save("test.png") (If I don't convert it I get ValueError: cannot reshape array of size 66144 into shape (104,212)

When I load it with:
Image.open("test.png").convert('P')

The screen flashed and then stays white.
If I do the last step, but with pointing the path to the Inky Example image it works correctly.
How to I save correctly the image so that it works when I load it back?

SPI speed set to 488KHz

Is there any reason why the SPI speed is set so slow? The display controller supports up to 20MHz.

Confused about which model I recieved

Hello, I recently purchased the red Inky pHat red (similar to use issue #58) however upon downloading the packages I am faced with a similar issue. There is one electrode on the front of module

image

I've attempted to print read_eeprom() but it returns None.

I honestly have no idea which display has been sent to me and I've contacted the supplier to try and shed some light on the issue.

Issue running quotes-what.py

Hi,

I'm not able to run the quotes-what.py demo on my Raspbery Pi.

Running a fresh install raspbian latest, python 3, pip 3.

Issue is with installing wikiquotes, doesn't seem libxslt/libxml2 is installed by default and I can't find a suitable package that works without it.

Output from Pi:

  Running setup.py install for lxml ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-r071llkk/lxml/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-wex8tsge-record/install-record.txt --single-version-externally-managed --compile:
    Building lxml version 4.3.2.
    Building without Cython.
    ERROR: b'/bin/sh: 1: xslt-config: not found\n'
    ** make sure the development packages of libxml2 and libxslt are installed **

    Using build configuration of libxslt
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-armv7l-3.5
    creating build/lib.linux-armv7l-3.5/lxml
    copying src/lxml/sax.py -> build/lib.linux-armv7l-3.5/lxml
    copying src/lxml/builder.py -> build/lib.linux-armv7l-3.5/lxml
    copying src/lxml/pyclasslookup.py -> build/lib.linux-armv7l-3.5/lxml
    copying src/lxml/_elementpath.py -> build/lib.linux-armv7l-3.5/lxml
    copying src/lxml/__init__.py -> build/lib.linux-armv7l-3.5/lxml
    copying src/lxml/cssselect.py -> build/lib.linux-armv7l-3.5/lxml
    copying src/lxml/ElementInclude.py -> build/lib.linux-armv7l-3.5/lxml
    copying src/lxml/doctestcompare.py -> build/lib.linux-armv7l-3.5/lxml
    copying src/lxml/usedoctest.py -> build/lib.linux-armv7l-3.5/lxml
    creating build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/__init__.py -> build/lib.linux-armv7l-3.5/lxml/includes
    creating build/lib.linux-armv7l-3.5/lxml/html
    copying src/lxml/html/_setmixin.py -> build/lib.linux-armv7l-3.5/lxml/html
    copying src/lxml/html/_html5builder.py -> build/lib.linux-armv7l-3.5/lxml/html
    copying src/lxml/html/builder.py -> build/lib.linux-armv7l-3.5/lxml/html
    copying src/lxml/html/_diffcommand.py -> build/lib.linux-armv7l-3.5/lxml/html
    copying src/lxml/html/diff.py -> build/lib.linux-armv7l-3.5/lxml/html
    copying src/lxml/html/clean.py -> build/lib.linux-armv7l-3.5/lxml/html
    copying src/lxml/html/defs.py -> build/lib.linux-armv7l-3.5/lxml/html
    copying src/lxml/html/__init__.py -> build/lib.linux-armv7l-3.5/lxml/html
    copying src/lxml/html/ElementSoup.py -> build/lib.linux-armv7l-3.5/lxml/html
    copying src/lxml/html/soupparser.py -> build/lib.linux-armv7l-3.5/lxml/html
    copying src/lxml/html/html5parser.py -> build/lib.linux-armv7l-3.5/lxml/html
    copying src/lxml/html/usedoctest.py -> build/lib.linux-armv7l-3.5/lxml/html
    copying src/lxml/html/formfill.py -> build/lib.linux-armv7l-3.5/lxml/html
    creating build/lib.linux-armv7l-3.5/lxml/isoschematron
    copying src/lxml/isoschematron/__init__.py -> build/lib.linux-armv7l-3.5/lxml/isoschematron
    copying src/lxml/etree.h -> build/lib.linux-armv7l-3.5/lxml
    copying src/lxml/etree_api.h -> build/lib.linux-armv7l-3.5/lxml
    copying src/lxml/lxml.etree.h -> build/lib.linux-armv7l-3.5/lxml
    copying src/lxml/lxml.etree_api.h -> build/lib.linux-armv7l-3.5/lxml
    copying src/lxml/includes/xmlerror.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/relaxng.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/xpath.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/config.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/xmlparser.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/tree.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/etreepublic.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/dtdvalid.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/xmlschema.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/xinclude.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/htmlparser.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/schematron.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/xslt.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/uri.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/__init__.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/c14n.pxd -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/lxml-version.h -> build/lib.linux-armv7l-3.5/lxml/includes
    copying src/lxml/includes/etree_defs.h -> build/lib.linux-armv7l-3.5/lxml/includes
    creating build/lib.linux-armv7l-3.5/lxml/isoschematron/resources
    creating build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/rng
    copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/rng
    creating build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl
    creating build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-armv7l-3.5/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    running build_ext
    building 'lxml.etree' extension
    creating build/temp.linux-armv7l-3.5
    creating build/temp.linux-armv7l-3.5/src
    creating build/temp.linux-armv7l-3.5/src/lxml
    arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-6waWnr/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DCYTHON_CLINE_IN_TRACEBACK=0 -Isrc -Isrc/lxml/includes -I/usr/include/python3.5m -c src/lxml/etree.c -o build/temp.linux-armv7l-3.5/src/lxml/etree.o -w
    In file included from src/lxml/etree.c:687:0:
    src/lxml/includes/etree_defs.h:14:31: fatal error: libxml/xmlversion.h: No such file or directory
     #include "libxml/xmlversion.h"
                                   ^
    compilation terminated.
    Compile failed: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
    cc -I/usr/include/libxml2 -c /tmp/xmlXPathInitjm8no0xj.c -o tmp/xmlXPathInitjm8no0xj.o
    /tmp/xmlXPathInitjm8no0xj.c:1:26: fatal error: libxml/xpath.h: No such file or directory
     #include "libxml/xpath.h"
                              ^
    compilation terminated.
    *********************************************************************************
    Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
    *********************************************************************************
    error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

    ----------------------------------------

cc @isaacwellish

Impression library not working on Jessie

Installed via the one line curl/bash script.

Fully updated Jessie install (yes, I know i should upgrade, but it's the pi zero I had to hand that I've been using with the inkey pHat & the script does say it's supported...)

Running any of the examples/7color code gives the following error:

$ ./clear.py 
Traceback (most recent call last):
  File "./clear.py", line 14, in <module>
    inky.show()
  File "/usr/local/lib/python3.4/dist-packages/inky/inky_uc8159.py", line 365, in show
    self._update(buf.astype('uint8').tolist(), busy_wait=busy_wait)
  File "/usr/local/lib/python3.4/dist-packages/inky/inky_uc8159.py", line 320, in _update
    self.setup()
  File "/usr/local/lib/python3.4/dist-packages/inky/inky_uc8159.py", line 217, in setup
    self._spi_bus.no_cs = True
AttributeError: 'SpiDev' object has no attribute 'no_cs'

I've tried running with python 3.4.2 and 2.4.7

It looks like the required version of python3-spidev is installed:

aptitude show python3-spidev 
Package: python3-spidev                  
State: installed
Automatically installed: no
Version: 2.0~git20150907
Priority: optional
Section: python
Maintainer: Stephen Caudle <[email protected]>
Architecture: armhf
Uncompressed Size: 56.3 k
Depends: python3 (< 3.5), python3 (>= 3.4~), libc6 (>= 2.4)
Description: Python bindings for Linux SPI access through spidev (Python 3)
 Python module for interfacing with SPI devices from user space via the spidev
 linux kernel driver.
Homepage: https://github.com/doceme/py-spidev
$ grep spidev inky.sh
SPIDEV3="python3-spidev_2.0~git20150907_armhf.deb"
...

Looks like no_cs was added in 2016 so after the 20150907 build available on Jessie.

Happy for this not to be fixed for Jessie if it's not simple, the right answer might be to say that Jessie is not supported.

Image palette is ignored

All input images are interpreted as having a white-black-red palette. Unfortunately lots of software does not let you choose the palette order.

I worked around it like this, but it would be nicer to honor the palette instead. (Of course red should be yellow if you have the yellow version...)

img = Image.open("temp.png")
cR = [255, 0, 0]
cB = [0, 0, 0]
cW = [255, 255, 255]

palette_old = img.getpalette()

p_conv = {0: palette_old[0:3],
        1: palette_old[3:6],
        2: palette_old[6:9]}

# p_target = {0: cW,
#             1: cB,
#             2: cR}

new_pixdata = []
old_pixdata = img.getdata()
for pix in old_pixdata:
    if pix not in p_conv:
        print('Pixel out of range: {}'.format(pix))
        new_pixdata.append(0)
    elif p_conv[pix] == cW:
        new_pixdata.append(0)
    elif p_conv[pix] == cB:
        new_pixdata.append(1)
    elif p_conv[pix] == cR:
        new_pixdata.append(2)

img.putdata(new_pixdata)
img.putpalette(cW + cB + cR)  # Goal palette

Cannot install Python libraries for pHat on Pi Zero W

I'm trying to install the python library for my brank new Inky pHat, but I get the following error with both the following commands:
curl https://get.pimoroni.com/inky | bash
sudo pip install inky

pi@raspberrypi:~ $ sudo pip install inky
Downloading/unpacking inky
  Downloading inky-0.0.5-py2-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/lib/python2.7/dist-packages (from inky)
Downloading/unpacking smbus2 (from inky)
  Downloading smbus2-0.3.0.tar.gz
  Running setup.py (path:/tmp/pip-build-Zm5bh7/smbus2/setup.py) egg_info for package smbus2
    error in smbus2 setup command: 'extras_require' must be a dictionary whose values are strings or lists of strings containing valid project/version requirement specifiers.
    Complete output from command python setup.py egg_info:
    error in smbus2 setup command: 'extras_require' must be a dictionary whose values are strings or lists of strings containing valid project/version requirement specifiers.

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-Zm5bh7/smbus2
Storing debug log for failure in /root/.pip/pip.log

Any ideas? My Pi version:

Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 8.0 (jessie)
Release:	8.0
Codename:	jessie

Inky pHAT revisions

When trying to merge a port of my inky-cryptochart project to this newer inky library from the older inky-phat library, I noticed that both my Inky pHAT and my Waveshare E-Ink display HAT stopped working.

As stated in your project description, this library does not support the older red v1 revision. Is there a specific reason for it? Will I hit a wall if I try to port the driver to this library? I don't think these Inky pHATs are open hardware, but can you share the changes between the different revisions? Do they use a different display or driver chip?

Also, I noticed a feature/ssd1608 branch. Is this for a future revision?

smbus2 not installed by one line installer

curl https://get.pimoroni.com/inky | bash doesn't currently install the smbus2 dependency needed to run the name-badge.py example. Can we get this included?

The error that the example generates suggests running sudo pip install smbus2 (even when using Python 3) but I needed to run sudo pip3 install smbus2 to grab the right version.

inky impression swaps white and black

I recently wanted to migrate my application from Inky-wHat to Inky-Impression and noticed that you swapped the color-codes for white and black. In a pure python-world, that is ok because you can use symbolic constants. But I have a json-file to configure fonts and colors and this really hurts.

Very strange since all versions up to the impression use 0 for white and 1 for black. Any reason for this incompatibility?

Using the weather-that.py script in crontab

Had to edit lines 131 and 135

from (131)
img = Image.open("resources/backdrop.png")
to
img = Image.open("/home/pi/Pimoroni/inky/examples/phat/resources/backdrop.png")

and

from (135)
for icon in glob.glob("resources/icon-*.png"):
to
for icon in glob.glob("/home/pi/Pimoroni/inky/examples/phat/resources/icon-*.png"):

in order to run a crontab schedule of
*/10 * * * * python ~/Pimoroni/inky/examples/phat/weather-phat.py --colour "red"

as suggested in the getting started page on Pimoroni web

Library seemingly no longer works with a stock Raspbian install

I'm trying to get started with my Inky Impression display, and have flashed the Raspbian Minimal latest image using the Raspberry Pi flasher, then ran curl https://get.pimoroni.com/inky | bash per the instructions on the store page, choosing to install the examples and documentation.
Upon doing so, rebooting, and manually enabling I2C as the script didn't actually enable it somehow, rebooting again and trying to run any of the example scripts other than the buttons and identify scripts fails.

When using Python2 and running from inky.auto import auto; disp=auto() I do correctly get an inky_uc8159 object, but when I then call disp.setup() (or indeed any other method that writes to the SPI bus) I get a TypeError: Non-Int/Long value in arguments exception.
When using Python3 and attempting to run from inky.auto import auto I get a UnicodeDecodeError.

This happens reproducibly with the latest Raspbian Minimal and the setup script, using both the Impression and my existing Inky wHAT (for which this library worked the last time I used it around a year ago), on multiple Pi 3 boards.

Add fonts to setup.py

The following fonts are required by the examples, and should probably be installed alongside the library:

  • font_hanken_grotesk
  • font_intuitive
  • font_fredoka_one
  • font_source_serif_pro
  • font_source_sans_pro

The latter two need to be added to the Python fonts library

Very dark red color in 0.0.5+

I just got a red inkyphat, and its red color seems very, very dark. After testing all of the available versions using sudo pip3 install inky==<versionnumber>, I found that it looks really good with 0.0.4, but gets really dark with 0.0.5. See photos below.

Version info from the eeprom:

>>> inky.eeprom.read_eeprom()
Display: 212x104
Color: red
PCB Variant: 1.2
Display Variant: 1
Time: b'2020-08-05 11:15:15.7'

My test is based off of the simple hello world example:

#!/usr/bin/python3

from inky import InkyPHAT
from PIL import Image, ImageFont, ImageDraw
from font_fredoka_one import FredokaOne

inky_display = InkyPHAT("red")

inky_display.set_border(inky_display.WHITE)

img = Image.new("P", (inky_display.WIDTH, inky_display.HEIGHT))
draw = ImageDraw.Draw(img)

font = ImageFont.truetype(FredokaOne, 28)
climacons = ImageFont.truetype("Climacons-Font/Climacons.ttf", 32)
climacons = ImageFont.truetype("Climacons-Font/webfont/climacons-webfont.ttf", 104)


draw.text((0, 0), "InkyPHAT", inky_display.BLACK, font)
draw.text((0, 40), "Version 0.0.5", inky_display.RED, font)
inky_display.set_image(img)
inky_display.show()

2020-10-24 22 00 51

2020-10-24 22 02 01

problems with the installation of the dependencies

So it's me again, so I tried a clean reinstall with the script: curl -sSL https://get.pimoroni.com/inky | bash

the first few things get installed without any problem but then at some point i get this:

Checking for additional software...
python-geocoder is required
Installing python-geocoder...
E: Unable to locate package python-geocoder
Apt failed to install python-geocoder!
Falling back on pypi...
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting geocoder
Downloading https://files.pythonhosted.org/packages/4f/6b/13166c909ad2f2d76b929a4227c952630ebaf0d729f6317eb09cbceccbab/geocoder-1.38.1-py2.py3-none-any.whl (98kB)
100% |████████████████████████████████| 102kB 425kB/s
Collecting click (from geocoder)
Downloading https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl (82kB)
100% |████████████████████████████████| 92kB 552kB/s
Collecting ratelim (from geocoder)
Downloading https://files.pythonhosted.org/packages/f2/98/7e6d147fd16a10a5f821db6e25f192265d6ecca3d82957a4fdd592cad49c/ratelim-0.1.6-py2.py3-none-any.whl
Collecting requests (from geocoder)
Downloading https://files.pythonhosted.org/packages/45/1e/0c169c6a5381e241ba7404532c16a21d86ab872c9bed8bdcd4c423954103/requests-2.24.0-py2.py3-none-any.whl (61kB)
100% |████████████████████████████████| 71kB 550kB/s
Requirement already satisfied: six in /usr/lib/python2.7/dist-packages (from geocoder) (1.12.0)
Collecting future (from geocoder)
Downloading https://files.pythonhosted.org/packages/45/0b/38b06fd9b92dc2b68d58b75f900e97884c45bedd2ff83203d933cf5851c9/future-0.18.2.tar.gz (829kB)
100% |████████████████████████████████| 829kB 91kB/s
Collecting decorator (from ratelim->geocoder)
Downloading https://files.pythonhosted.org/packages/ed/1b/72a1821152d07cf1d8b6fce298aeb06a7eb90f4d6d41acec9861e7cc6df0/decorator-4.4.2-py2.py3-none-any.whl
Collecting idna<3,>=2.5 (from requests->geocoder)
Downloading https://files.pythonhosted.org/packages/a2/38/928ddce2273eaa564f6f50de919327bf3a00f091b5baba8dfa9460f3a8a8/idna-2.10-py2.py3-none-any.whl (58kB)
100% |████████████████████████████████| 61kB 536kB/s
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests->geocoder)
Downloading https://files.pythonhosted.org/packages/9f/f0/a391d1463ebb1b233795cabfc0ef38d3db4442339de68f847026199e69d7/urllib3-1.25.10-py2.py3-none-any.whl (127kB)
100% |████████████████████████████████| 133kB 489kB/s
Collecting certifi>=2017.4.17 (from requests->geocoder)
Downloading https://files.pythonhosted.org/packages/5e/c4/6c4fe722df5343c33226f0b4e0bb042e4dc13483228b4718baf286f86d87/certifi-2020.6.20-py2.py3-none-any.whl (156kB)
100% |████████████████████████████████| 163kB 410kB/s
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/lib/python2.7/dist-packages (from requests->geocoder) (3.0.4)
Building wheels for collected packages: future
Running setup.py bdist_wheel for future ... done
Stored in directory: /root/.cache/pip/wheels/8b/99/a0/81daf51dcd359a9377b110a8a886b3895921802d2fc1b2397e
Successfully built future
Installing collected packages: click, decorator, ratelim, idna, urllib3, certifi, requests, future, geocoder
Successfully installed certifi-2020.6.20 click-7.1.2 decorator-4.4.2 future-0.18.2 geocoder-1.38.1 idna-2.10 ratelim-0.1.6 requests-2.24.0 urllib3-1.25.10
python3-geocoder is required
Installing python3-geocoder...

and not only with the python3-geocoder
also with: python-beautifulsoup4, with python3-beautifulsoup4, with python-fonts, with python3-fonts, python-font_hanken_grotesk, python3-font_hanken_grotesk, and every other font too and also the python-wikiquotes and python3-wikiquotes

does anyone know why?

Failed to detect inky board

I have just received an Inky Impression but it doesn't seem to be recognised at all. I have updated all software.

pip3 installs old version

pip3 seems to install an old version of the Inky-Impression code (set_border still raises an exception).

`set_border` is not working

The set_border colour is not working as expected for me. Below is a simple program in which I would expect the border color to turn white, but it doesn't.

#!/usr/bin/python
from PIL import Image
from inky import InkyPHAT

display = InkyPHAT("black")

def get_filled_image (color):
  img = Image.new("P", (display.WIDTH, display.HEIGHT))
  for x in range(display.WIDTH):
    for y in range(display.HEIGHT):
      img.putpixel((x, y), color)
  return img

img = get_filled_image(display.WHITE)
display.set_border(display.WHITE)
display.set_image(img)
display.show()

At first I thought this was some sort of hardware limitation, but while hacking around with the lookup tables I managed to get a pretty nice update that entirely fills the screen with black or white. To solve this, I created a new lookup table that, instead of drawing the correct black or white pixels in phase 3, just draws pure black or pure white pixels. The result is that the border finally turns white.

Problems with the calendar-phat.py

So I have installed everything on a clean Buster-Installation, i could clean the screen but as soon as i want to use the calendar-phat.py i get the following output:

_Inky pHAT: Calendar
Draws a calendar for the current month to your Inky pHAT.
This example uses a sprite sheet of numbers and month names which are
composited over the background in a couple of different ways.

Traceback (most recent call last):
File "calendar-phat.py", line 6, in
import calendar
File "/home/pi/Pimoroni/inky/examples/phat/calendar.py", line 85, in
text = Image.open(os.path.join(PATH, "resources/calendar.png"))
NameError: name 'Image' is not defined_

Does anyone knows why? This happened with every Installation i had. The other things also didn't worked. It actually bothers me a bit because I have no idea why it is happening

Edit: I tried to remove the backdrop.png from the original code by removing the lines 98 to 100 but you could guess, that also didn't work out because still nothing really wants to work ._. maybe someone can help and tell me a) how/why the error is getting up there and b) how to remove the backdrop.png properly from the calendar

Example script fonts not installed in Raspbian Buster

Though #2 appears to have resolved this some time ago, a fresh install on Raspbian Buster resulted in font errors when running the name-badge.py example script.

Steps to reproduce

  1. Clean install of Raspbian 2019-07-10 release
  2. Install inky phat library via pip
  3. run name-badge.py script

Steps to resolve

Install missing fonts via pip.

Some commands seem to be missing data

I've been reviewing this code to see how to control the display that I have (Inky pHAT Black/White/Red v2) and noticed what I think are some inconsistencies. Granted that some of my information is based upon my assumption that the display is using an SSD1675 controller, which could be wrong but all the other commands match.

Is gate driving voltage being set correctly? It seems that the two bytes should be ORed together instead of being sent as separate bytes.

self._send_command(0x03, [0b10000, 0b0001]) # Gate Driving Voltage

image


I think this command is missing the three data bytes. I note that they are present in the old library.

self._send_command(0x04) # Power On

image

TODO: Find a better way for the mock/simulator to handle exit

Right now for single shot display updates (name-badge.py and logo.py) we have an exit trap in the code that abuses input() to prevent the script from exiting, without blocking Tkinter's UI thread.

Tkinter should have some way to deal with this already, so we should find a way to block exit until the user clicks close in the output window.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.