OK, as I’m a complete noob, but I am getting there, there is one thing that’s tearing my hair out! How do I compile all the driver, libraries etc to get the Pico Display hat to work? It’s all cmake, cpp, hpp files etc. I don’t have a clue! Thanks. Whatever happened to good old .py files? 🥴
The easiest way is to just use the custom Pimoroni uf2 file that has all that included in it. If your already doing that ignore this and move on to part two of my answer
Releases · pimoroni/pimoroni-pico (github.com)
v1.18.7 will likely work with the current examples.
Sounds like you may have just went to the wrong folder. The Micro Python examples are here.
pimoroni-pico/micropython/examples/pico_display at main · pimoroni/pimoroni-pico (github.com)
Yes, I did install the Pimoroni firmware. You’re right, I probably did go the wrong way. I’ll let you know how I get on. Thanks for your input. 👍🏻
The link on the product page takes you too where you need to sellect c or micro python. Clicking examples gets you c. Clicking micro python gets you to the micro python examples. It caught me out at first.
I’m getting the error “no module named ‘st7789’” ☹️
Which Pimoroni uf2 did you use, version wise?
This worked for me with v1.18.8
import st7789 import utime display = st7789.ST7789(width=135, height=240, slot=0) # Display Pack portrait display.set_backlight(1.0) def hsv_to_rgb(h, s, v): if s == 0.0: return v, v, v i = int(h * 6.0) f = (h * 6.0) - i p = v * (1.0 - s) q = v * (1.0 - s * f) t = v * (1.0 - s * (1.0 - f)) i = i % 6 if i == 0: return v, t, p if i == 1: return q, v, p if i == 2: return p, v, t if i == 3: return p, q, v if i == 4: return t, p, v if i == 5: return v, p, q h = 0 while True: h += 1 r, g, b = [int(255 * c) for c in hsv_to_rgb(h / 360.0, 1.0, 1.0)] # rainbow magic #display.set_led(r, g, b) # Set LED to a converted HSV value display.set_pen(r, g, b) # Set pen to a converted HSV value display.clear() # Fill the screen with the colour display.set_pen(0, 0, 0) # Set pen to black display.text("pico disco!", 10, 10, 135, 4) # potrait display.update() # Update the display utime.sleep(1.0 / 60)
Isn’t v1.18.8 a beta?
Ah, Ok. Yes, in a way its Beta. It has updates in it for the new st7789 unified driver.
import time import random import picodisplay as display # Comment this line out to use PicoDisplay2 # import picodisplay2 as display # Uncomment this line to use PicoDisplay2 width = display.get_width() height = display.get_height() display_buffer = bytearray(width * height * 2) # 2-bytes per pixel (RGB565) display.init(display_buffer) display.set_backlight(1.0) class Ball: def __init__(self, x, y, r, dx, dy, pen): self.x = x self.y = y self.r = r self.dx = dx self.dy = dy self.pen = pen # initialise shapes balls =  for i in range(0, 100): r = random.randint(0, 10) + 3 balls.append( Ball( random.randint(r, r + (width - 2 * r)), random.randint(r, r + (height - 2 * r)), r, (14 - r) / 2, (14 - r) / 2, display.create_pen(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)), ) ) while True: display.set_pen(40, 40, 40) display.clear() for ball in balls: ball.x += ball.dx ball.y += ball.dy xmax = width - ball.r xmin = ball.r ymax = height - ball.r ymin = ball.r if ball.x < xmin or ball.x > xmax: ball.dx *= -1 if ball.y < ymin or ball.y > ymax: ball.dy *= -1 display.set_pen(ball.pen) display.circle(int(ball.x), int(ball.y), int(ball.r)) display.update() time.sleep(0.01)
That worked! So if I changed the newer examples that ask for st7789 to picodisplay (and subsequent commands to match) then they should work? I’ll give it a go…
Yes, the bit you need is as follows.
perfect, but I needed to define height and width and RGB like this…
from pimoroni import RGBLED
import picodisplay as display # Comment this line out to use PicoDisplay2
WIDTH, HEIGHT = 240, 135 # Pico Display
width = display.get_width()
height = display.get_height()
display_buffer = bytearray(width * height * 2) # 2-bytes per pixel (RGB565)
Thank you so much for your help!
I think just
width = 240
height = 135
will work instead of the display.get_height, and no need for the WIDTH, HEIGHT = 240, 135
I’m running v1.18.8 with my Display Pack. And a new experimental st7789 8 bit frame buffer version on a dual Display Pack v2 setup.
One final question. How do I rotate/flip the screen 180 degrees? I tried picodisplay,flip() and display,flip() without success.
I don’t think you can with that version uf2 / library?
There is a rotate function in the newer release though.
Ok, thanks. I’ll have to have a look.
I’m a bit responsible for some of this transition. It stared here,
Pico Display Pack V2 x 2? · Issue #299 · pimoroni/pimoroni-pico (github.com)
Which led to this when I wanted portrait mode.
Unified display drivers · Issue #309 · pimoroni/pimoroni-pico (github.com)
And then this when I ran out of room for my code.
ST7789: Experimental 8-bit framebuffer by Gadgetoid · Pull Request #373 · pimoroni/pimoroni-pico (github.com)
The thing with the latest uf2 builds is, they will break code written for the earlier ones.
If your starting out fresh, its not as big a deal.
I’m running the experimental 8-bit frame buffer uf2 on my weather station build. All my i2c breakouts etc are running just fine.
Pi Pico based Weather Station Project - Discussion / Projects - Pimoroni Buccaneers
I should be able to help you with code for the Display Pack which ever uf2 you use.
Thanks! That’s very much appreciated. I’m still using the last official release so I’ve altered the scripts to match. But I have kept the originals if it changes. I know where to come for help! 😉👍🏻
And I’m more than happy to help. I got spoiled by being able to run 2 and 3 LCD setups on a Pi in Python. Plus, the Breakout Garden breakouts, i2c and SPI, can be used on a Pi or Pico. I’m swapping back and forth all the time. You could use a display Pack on a Pi if you wanted to do some custom wiring. Its st7789 and 3.3v logic.