Pico Unicorn & Pico Graphics

Greetings,

I was curious if anyone out there had managed to get the excellent pico graphics api running on the pico unicorn?

Also, are there any plans to add pico unicorn support into the pico graphics api?

Cheers,

I think it’s already in, isn’t it?

Try

from picographics import PicoGraphics, DISPLAY_UNICORN_PACK

display = PicoGraphics(display=DISPLAY_UNICORN_PACK)

Hi Hel 👋

I’m using the 1.20.4 pimoroni .uf2, on a non ‘W’ pico, and the following code:

import picounicorn
from picographics import PicoGraphics, DISPLAY_UNICORN_PACK

display = PicoGraphics(display=DISPLAY_UNICORN_PACK)

RED = display.create_pen(255, 0, 0)
display.set_pen(RED)
display.pixel(0, 0)

display.update()

Seems to load the picographics module just fine. Hit run, and nothing happens on the display. Just retuning the >>> prompt.

Trying the more “traditional” old hat method with the v1.20.4 pimoroni .uf2 and the following code:

import picounicorn, utime, urandom

picounicorn.init()

while True:
    x = urandom.randint(0, 15)
    y = urandom.randint(0, 6)
    r = urandom.randint(0, 255)
    g = urandom.randint(0, 128)
    b = urandom.randint(0, 128)

    print(x, y, r, g, b)

    picounicorn.set_pixel(x, y, r, g, b)

    utime.sleep(0.1)

Returns:

>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
AttributeError: 'module' object has no attribute 'init'

With the same error for set_pixel as well.

Only when re flashed with pimoroni v1.19.15 uf2 do things start working again. But not with pico graphics. 😕

Sorry it’s taken a while for me to find the hardware and try this out - it’s been a busy couple of weeks!

Try this:

from picounicorn import PicoUnicorn
from picographics import PicoGraphics, DISPLAY_UNICORN_PACK

picounicorn = PicoUnicorn()
graphics = PicoGraphics(display=DISPLAY_UNICORN_PACK)

RED = graphics.create_pen(255, 0, 0)

graphics.set_pen(RED)
graphics.pixel(0, 0)

picounicorn.update(graphics)

Looks like the secret sauce is that you need to update the instance of your picounicorn class and feed it your picographics instance, as is the case with Galactic Unicorn and co.

We could do with some Unicorn Pack examples that use PicoGraphics - I’ve added it to my to-do list (but if anyone gets there first PRs are always much appreciated :) ).

Ask and ye shall receive :-)

1 Like

Blimey, that was fast. Thank you! 💜

I’ll be honest, I was about to say “send me a Pico Unicorn and I’ll see what I can do” when I realised I already had one in my Box Of Shame, so it only seemed right to actually make it do something for a change :-)

1 Like

That’s great Hel, super-mega-awesome & marked as a solution.

Was hoping to bag a pico display 2 today after getting a stock notification. By the time I got to order they’d all gone?

Is there any kind of hint when they might be available again, please?

1 Like

Looks like our wholesale team snaffled up that first batch fairly promptly, but more are in the process of being tested so there should be more stock added over the next couple of days.