Git Product home page Git Product logo

inky-phat's Introduction

Inky pHAT http://shop.pimoroni.com/products/inky-phat

NOTE This library has been superceded by the new Inky Python library that supports both the Inky pHAT e-paper displays and the larger Inky wHAT e-paper displays, all in one library. The new Inky library does however drop support for the very first version of Inky pHAT, so if you have one of them then you'll need to use this older Inky pHAT library.

You have a newer Inky pHAT if:

  • It's any colour other than Red (IE: Yellow and Black/White Inky pHATs were only available as V2)
  • Has a square inductor on the reverse of the board (large compared to the other components, and dark grey)

Installing

Full install (recommended):

We've created an easy installation script that will install all pre-requisites and get your Inky pHAT up and running with minimal efforts. To run it, fire up Terminal which you'll find in Menu -> Accessories -> Terminal on your Raspberry Pi desktop, as illustrated below:

Finding the terminal

In the new terminal window type the command exactly as it appears below (check for typos) and follow the on-screen instructions:

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

If you choose to download examples you'll find them in /home/pi/Pimoroni/inkyphat/.

Manual install:

Library install for Python 3:

sudo apt-get install python3-inkyphat

Library install for Python 2:

sudo apt-get install python-inkyphat

Development:

If you want to contribute, or like living on the edge of your seat by having the latest code, you should clone this repository, cd to the library directory, and run:

sudo apt-get install python-dev python-setuptools
sudo python3 setup.py install

(or sudo python setup.py install whichever your primary Python environment may be)

In all cases you will have to enable the SPI bus.

Documentation & Support

inky-phat's People

Contributors

gadgetoid avatar roguem avatar sandyjmacdonald avatar scruss avatar therijn 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

inky-phat's Issues

display funkyness after update

display no longer looks right after the update. Looks like the wrong display size was used?

Edit - I just noticed the comment about a possible setting causing dead lines on the display. That may be what I'm experiencing but wanted to go back to the old library to be sure. Would it work to just copy the init and ILI9xxx files back and replace the newer ones or is the process more involved than that? Is there a path to just curl the old one down again?

No such file: dev/i2c-1

Trying to run examples after a fresh install, followed the instructions

python logo.py --type "phat" --colour "red"
Traceback (most recent call last):
  File "logo.py", line 26, in <module>
    inky_display = InkyPHAT(colour)
  File "/usr/local/lib/python2.7/dist-packages/inky/phat.py", line 27, in __init__
    v_flip=False)
  File "/usr/local/lib/python2.7/dist-packages/inky/inky.py", line 74, in __init__
    self.eeprom = eeprom.read_eeprom()
  File "/usr/local/lib/python2.7/dist-packages/inky/eeprom.py", line 103, in read_eeprom
    i2c = SMBus(1)
  File "/usr/local/lib/python2.7/dist-packages/smbus2/smbus2.py", line 253, in __init__
    self.open(bus)
  File "/usr/local/lib/python2.7/dist-packages/smbus2/smbus2.py", line 265, in open
    self.fd = os.open("/dev/i2c-{}".format(bus), os.O_RDWR)
OSError: [Errno 2] No such file or directory: '/dev/i2c-1'

Refresh rate?

Hello everyone,

I just received my screen today, and I'm having some issues displaying things. With the same code, sometimes it doesn't update, or it "prints" weird things (parts of letters, etc). I test it with

inkyphat.paste(inkyphat.Image.new('P', (inkyphat.WIDTH, inkyphat.HEIGHT)))

sometimes and even this sometimes doesn't do anything. At somepoint I had a mostly black screen, with a white line on top and some white pixels making a weird curvy line on the black. I thought it was broken, and I couldn't update it anymore. 20 minutes later I tried again, and it worked.

So do I have a defective unit, or is there a limit fresh rate? Even trying to update it every minute or so seems to make it irresponsive.

Thanks!

icalendar

123

pi@raspberrypi:~/Pimoroni/inkyphat/examples $ ./cal-ics.py
Traceback (most recent call last):
File "./cal-ics.py", line 7, in
import icalendar
ImportError: No module named icalendar

'ImageDraw' object has no attribute 'setfill' with Pillow >= 4.1.0

When importing inkphat, an AttributeError is triggered:

Traceback (most recent call last):
  File "logo.py", line 5, in <module>
    import inkyphat
  File "/usr/local/lib/python3.4/dist-packages/inkyphat/__init__.py", line 29, in <module>
    globals()[method] = getattr(_draw, method)
AttributeError: 'ImageDraw' object has no attribute 'setfill'

This is due to setink(), setfill() and setfont() being deprecated in Pillow 4.1.0. This is easily fixed by removing references in __init__.py line 28.

Change background of the inky phat?

How it is possible to change the background of the inky phat?

Where i can find all available Methods of the drawing Library? What is Pillow and Why it is different from PIL? Is it compatibile with inky phat?

Where I can find some more information about the process to write on my inky phat? How it works: Draw on a Canvas, create image and then show image on inky phat...

pillow dependency on stretch-lite

So I just set up a new stretch-lite build and it looks like pillow doesn't compile just leaving to pip. This means python2 users on stretch-lite couldn't easily get setup with the inky-phat.

sudo apt-get install python-pip python-dev python python-pillow instead of sudo apt-get install python-pip python-dev python or the documented from README.md works perfectly and then the sudo pip install inkyphat works too.

Happy to submit a pr if you think this will be helpful

Waveshare compatibility?

Looks like the spi instruction set is similar/same? (I didn't look too closely), but the inky-phat library is wayyyy better.

I tried to buy a genuine inky phat but adafruit was out, and I live in the US so it was just easier to buy the chinese waveshare einkphat vs waiting for adafruit to get back in stock, or buy direct.

I went into the library and changed the pinouts, but when I try and run anything I get the following:

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    import inkyphat
  File "/usr/local/lib/python2.7/dist-packages/inkyphat-1.0.0-py2.7.egg/inkyphat/__init__.py", line 24, in <module>
    _panel = inky212x104.Inky212x104(resolution=(HEIGHT, WIDTH), h_flip=False, v_flip=True)
  File "/usr/local/lib/python2.7/dist-packages/inkyphat-1.0.0-py2.7.egg/inkyphat/inky212x104.py", line 111, in __init__
    self._spi.open(0, self.cs_pin)
IOError: [Errno 2] No such file or directory

I figure it's because I changed the cs_pin from 0 (what is 0???) to 8, since that's what the waveshare one uses.

According to the documentation (pimoroni pinout), it appears that the inky-phat uses the the same cs_pin though... so I change it back to 0, and I get the following output after running "python test.py red"

Traceback (most recent call last):
  File "test.py", line 15, in <module>
    inkyphat.set_colour(colour)
  File "/usr/local/lib/python2.7/dist-packages/inkyphat-1.0.0-py2.7.egg/inkyphat/__init__.py", line 40, in set_colour
    return _panel.set_colour(colour)
  File "/usr/local/lib/python2.7/dist-packages/inkyphat-1.0.0-py2.7.egg/inkyphat/inky212x104.py", line 118, in set_colour
    raise ValueError("V1 is only available in Red")
ValueError: V1 is only available in Red

I forgot what I did but at some point (before I reset my cloned repo) I got the programs to execute, however I wouldn't see any change on my waveshare display. It was strange, that it looked like everything was executing properly, except I would see no change. I can't figure out how I got it to that point though...

Anyway, If this is wholly unsupported you can close this issue, otherwise I feel like it might be a worthy endeavor for people stuck in my situation. At least, a fork might be doable if it's impolite to make this library compatible with a competing product.

image always rendered with colours inverted

hello,

no matter what i do, i always get the colours in the attached image inverted (black background instead of white). can someone please help (i used logo.py from the examples section)? thank you, j
example

inkyphat.show() is very slow

The method inkyphat.show() is unnecessarily slow. On my Pi Zero the following code takes almost 2 seconds to complete:

    for y in range(WIDTH):
        for x in range(HEIGHT):
            _panel.set_pixel(x, y, _image.getpixel((y, x)))

I suggest to use numpy to set the whole of _panel's buffer at once, instead of setting each pixel individually. In order to transform _image to the required buffer, one could do something along the lines of this:

    buffer = numpy.swapaxes(numpy.array(_image, dtype=numpy.uint8),0,1)

This would save almost 2 seconds for each display refresh.

Of course this should be adapted a bit in order to avoid copying pixels which are not part of the palette, but the basic idea should be clear.

error on every example- IOError: [Errno 2] No such file or directory

Maybe you guys could extend the test program/examples to be more diagnostic?
Found the pinout here

~/Pimoroni/inkyphat/examples $ python3 test.py
Traceback (most recent call last):
File "test.py", line 6, in
import inkyphat
File "/usr/local/lib/python3.5/dist-packages/inkyphat/init.py", line 24, in
_panel = inky212x104.Inky212x104(resolution=(HEIGHT, WIDTH), h_flip=False, v_flip=True)
File "/usr/local/lib/python3.5/dist-packages/inkyphat/inky212x104.py", line 111, in init
self._spi.open(0, self.cs_pin)
FileNotFoundError: [Errno 2] No such file or directory

How to draw lines in black?

Hi,

I am actually using this line to draw a line:
inkyphat.line((31, 15, 184, 15))
This draws a white line on the specified coordinates.

Is there a way to be able to change the color? I would like the line to be black.

Thanks.

Documentation about the X,Y layout

You draw the pixels of the InkyPhat here

https://github.com/pimoroni/inky-phat/blob/master/library/inkyphat/inky212x104.py#L206-L215

I was looking for some documentation about how the layout is updated, i.e. what order pixels are drawn, can I reference an individual pixel or does the whole display need refreshing? Can i reference one line of the display etc? Does partial config have something to do with it? (is it like a clip)

Is there any documents or diagrams explaining this? or a datasheet?

Background, I am trying to port the InkyPhat Python code to Java with AndroidThings

inkyphat.clear broken

Thank you for adding a "clear" function to the library - but it's broken by the little h in hEIGHT:

`

def clear():

  | _image.paste(Image.new('P', (WIDTH, hEIGHT)))

`
Luckily "Letter Man" showed up (for anyone old enough to remember that) and changed the little h to a big one and mine is working ; ).

Palette Inky-pHAT.gpl has #feffff for white

Palette file contains

GIMP Palette
Name: Inky pHAT
Columns: 1
#
254 255 255	Untitled
  0   0   0	Untitled
255   0   0	Untitled

but images in examples have the following colour map (identified by ImageMagick):

  Colormap:
         0: (255,255,255) #FFFFFF white
         1: (  0,  0,  0) #000000 black
         2: (255,  0,  0) #FF0000 red

Rendering an image with the #ffffff colormap using inkyphat.set_image(Image.open(…)) seems to work as well as using the official #feffff one.

How do I rotate text?

I managed to create a box on the display using some ImageDraw stuff but I can't figure out how to write text to it (at least so that it is visible). I can print text fine using the inkyphat libs but that only allows me to place it in one way.

From what I have read in PIL/Pillow you should be able to create a temp image, write text to it, rotate the temp image and paste it into the inkyphat.

I can't figure out how to do this.

  • How do I create a new temporary image area to draw to?
  • How do I write text with the inkyphat fonts and colors into this temp area?
  • How do I rotate it (90 degrees)?
  • How do I paste this temp image into the inkyphat buffer that I've build with my other commands?

Can we have a simple function/method that allows rotating text? I would be happy for pointers of what I'm doing wrong with PIL to maybe understand what to do and add something here.

I want to rotate this temperature text and use the same functionality to label the scale.

2017-07-07 21 04 05

inkyphat install failed to install Python library

I followed the install process to install the inkyphat library but the python library (both 2 & 3) cant be imported.

Below is the result of the install script.

pi@pizerow2:~ $ curl https://get.pimoroni.com/inkyphat  | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 38486  100 38486    0     0  77757      0 --:--:-- --:--:-- --:--:-- 77906

This script will install everything needed to use
Inky pHAT

Always be careful when running scripts and commands copied
from the internet. Ensure they are from a trusted source.

If you want to see what this script does before running it,
you should run: 'curl https://get.pimoroni.com/inkyphat'

Note: Inky pHAT requires SPI communication

Do you wish to continue? [y/N] y

Checking environment...
Updating apt indexes...
.....................

Checking hardware requirements...

Checking for packages required for GPIO control...
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
RPi.GPIO installed and up-to-date

SPI must be enabled for Inky pHAT to work
SPI is now enabled

Checking packages required by SPI interface...
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
spidev installed and up-to-date

Inky pHAT comes with examples and documentation that you may wish to install.
Performing a full install will ensure those resources are installed,
along with all required dependencies. It may however take a while!

Do you wish to perform a full install? [y/N] y

Checking for dependencies...
python-numpy is already installed
python3-numpy is already installed
python-pil is already installed
python3-pil is already installed

Installing python-inkyphat...
install ok installed
Installing python3-inkyphat...
install ok installed

Checking for additional software...
python-requests is already installed
python3-requests is already installed

Downloading examples and documentation...
Resources for your Inky pHAT were copied to
/home/pi/Pimoroni/inkyphat

Finalising Install...

pi@pizerow2:~ $ cd Pimoroni/inkyphat/
pi@pizerow2:~/Pimoroni/inkyphat $ la
-bash: la: command not found
pi@pizerow2:~/Pimoroni/inkyphat $ ls
examples
pi@pizerow2:~/Pimoroni/inkyphat $ cd examples/
pi@pizerow2:~/Pimoroni/inkyphat/examples $ ls
cal-ics.py  hello.py              list-ics.py  qr.py      test.py
cal.py      InkyPhat-212x104.png  logo.py      resources  weather.py
pi@pizerow2:~/Pimoroni/inkyphat/examples $ python3 cal.py
Traceback (most recent call last):
  File "cal.py", line 10, in <module>
    import inkyphat
ImportError: No module named 'inkyphat'
pi@pizerow2:~/Pimoroni/inkyphat/examples $ python cal.py
Traceback (most recent call last):
  File "cal.py", line 10, in <module>
    import inkyphat
ImportError: No module named inkyphat
pi@pizerow2:~/Pimoroni/inkyphat/examples $

cal.py not working in Python3

Traceback (most recent call last):
File "./cal.py", line 108, in
inkyphat.paste(month, (monthyear_x, cal_y + 4), month_mask)
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 1319, in paste
im.load()
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 1970, in load
self.im = self.im.crop(self.__crop)
TypeError: integer argument expected, got float

Error with V1 Inkyphat

Because of this line:

inkyphat.set_colour('yellow')

The app crash on a "ValueError: V1 is only available in Red"

In fact even changing to "red" it makes it to crash.

In fact on V1 the call to "set_colour" always make it to stop on the call. Maybe not throwing an error in case of a V1 when asking for red would be a better approach?

Allow for arbitrary rotation

Seems to me that the PIL library could handle rotation in software, rather than simply mirror display for 0 or 180 degrees

r = r % 360
# Cannot remember if PIL rotate mutates image
set_image(
    get_image().rotate(r))

would have allowed for arbitrary rotation.

I understand that 90 degrees and 270 degrees change image dimensions without asking, but feel transposing the result over the initial image might help mitigate this. (If this removed sentence is true, switch to pillow from PIL)

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.