Pico Inky & Raspberry Pi Pico

Hi all,
Does anyone know if there are any micropython graphics libraries for the Pico Inky eink display.
The product page links to the general repo but I can’t find anything related to this display, other than specific libraries for the badger product.

Any help would be appreciated.

Thanks

Hello! It will be supported in MicroPython with the PicoGraphics graphics library (or you can install the Badger image on your Pico of course, though you might run into problems with the lack of buttons/them being on different pins).

Here’s a simple example using PicoGraphics I just added. Software support for this screen is being worked on as we speak though, so things like how pen ‘colours’/dither works might be subject to change! You’ll need to be running the latest, greatest MicroPython (v19.1).

# This example shows you a simple, non-interrupt way of reading Pico Inky Pack's buttons with a loop that checks to see if buttons are pressed.

import time
from pimoroni import Button
from picographics import PicoGraphics, DISPLAY_INKY_PACK

display = PicoGraphics(display=DISPLAY_INKY_PACK)

# you can change the update speed here!
# it goes from 0 (slowest) to 3 (fastest)
display.set_update_speed(2)

display.set_font("bitmap8")

button_a = Button(12)
button_b = Button(13)
button_c = Button(14)


# a handy function we can call to clear the screen
# display.set_pen(1) is white and display.set_pen(0) is black
def clear():
    display.set_pen(1)
    display.clear()


# set up
clear()
display.set_pen(0)
display.text("Press any button!", 10, 10, 240, 3)
display.update()
time.sleep(0.5)

while True:
    if button_a.read():                                   # if a button press is detected then...
        clear()                                           # clear to white
        display.set_pen(0)                                # change the pen colour
        display.text("Button A pressed", 10, 10, 240, 3)  # display some text on the screen
        display.update()                                  # update the display
        time.sleep(0.5)
    elif button_b.read():
        clear()
        display.set_pen(0)
        display.text("Button B pressed", 10, 50, 240, 3)
        display.update()
        time.sleep(0.5)
    elif button_c.read():
        clear()
        display.set_pen(0)
        display.text("Button C pressed", 10, 90, 240, 3)
        display.update()
        time.sleep(0.5)
    time.sleep(0.1)  # this number is how frequently the Pico checks for button presses

That’s fantastic, thank you for your help.

Is anyone else able to run the more complex Pico Inky examples? Anything that pulls data over wireless complains about a missing urllib…?

Yep - same here. Getting “no module named ‘urllib’” running any of the networked inky examples with the latest 1.19.2 pimoroni UF2.

You can install the missing requests library via '‘Tools’ > ‘Manage Packages’ in Thonny - search for micropython-urllib.urequest

I’ll see if I can make that more obvious in the examples / on the shop page…

1 Like

Ahh! Thanks; I was probably hobbled by my complete lack of Micropython knowledge.

I did try looking for urllib as a package, didn’t think to add the urequest bit…

I am running Thonny 3.3.13 and have loaded pimoroni-picow-v1.19.6-micropython.uf2 onto the picow with an inky pack.

When I try to install the micropython-urllib.urequest using Tools->Manage packages, I get the following error. Basically, it is complaining about an expired certificate.

Has anyone else seen this error?
Is there another source for the library?
Any ideas?

Thanks,

Traceback (most recent call last):
File “C:\bin\Thonny\lib\urllib\request.py”, line 1350, in do_open
encode_chunked=req.has_header(‘Transfer-encoding’))
File “C:\bin\Thonny\lib\http\client.py”, line 1277, in request
self._send_request(method, url, body, headers, encode_chunked)
File “C:\bin\Thonny\lib\http\client.py”, line 1323, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “C:\bin\Thonny\lib\http\client.py”, line 1272, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “C:\bin\Thonny\lib\http\client.py”, line 1032, in _send_output
self.send(msg)
File “C:\bin\Thonny\lib\http\client.py”, line 972, in send
self.connect()
File “C:\bin\Thonny\lib\http\client.py”, line 1447, in connect
server_hostname=server_hostname)
File “C:\bin\Thonny\lib\ssl.py”, line 423, in wrap_socket
session=session
File “C:\bin\Thonny\lib\ssl.py”, line 870, in _create
self.do_handshake()
File “C:\bin\Thonny\lib\ssl.py”, line 1139, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1091)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\bin\Thonny\lib\tkinter_init_.py”, line 1705, in call
return self.func(*args)
File “C:\bin\Thonny\lib\tkinter_init_.py”, line 749, in callit
func(*args)
File “C:\bin\Thonny\lib\site-packages\thonny\plugins\micropython\pip_gui.py”, line 438, in poll_fetch_complete
_, bin_data = url_future.result()
File “C:\bin\Thonny\lib\concurrent\futures_base.py”, line 428, in result
return self.__get_result()
File “C:\bin\Thonny\lib\concurrent\futures_base.py”, line 384, in __get_result
raise self._exception
File “C:\bin\Thonny\lib\concurrent\futures\thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “C:\bin\Thonny\lib\site-packages\thonny\plugins\pip_gui.py”, line 1230, in load_url
with urlopen(url, timeout=timeout) as conn:
File “C:\bin\Thonny\lib\urllib\request.py”, line 222, in urlopen
return opener.open(url, data, timeout)
File “C:\bin\Thonny\lib\urllib\request.py”, line 525, in open
response = self._open(req, data)
File “C:\bin\Thonny\lib\urllib\request.py”, line 543, in _open
‘_open’, req)
File “C:\bin\Thonny\lib\urllib\request.py”, line 503, in _call_chain
result = func(*args)
File “C:\bin\Thonny\lib\urllib\request.py”, line 1393, in https_open
context=self._context, check_hostname=self._check_hostname)
File “C:\bin\Thonny\lib\urllib\request.py”, line 1352, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1091)>

Ooh yes, I came across this with my home computer - it’s a Windows error caused by out of date security certificates

I fixed it by updating the Windows root certificate: SSL: CERTIFICATE_VERIFY_FAILED, certificate has expired · Issue #1986 · thonny/thonny · GitHub

If you’d rather not do that, there’s an mpy compiled version of the urllib library here: pimoroni-pico/micropython/examples/common at main · pimoroni/pimoroni-pico · GitHub - copy it the ‘lib’ directory on your Pico using Thonny.

Thanks. I appreciate the help.