Nothing is rendering on this screen when I use a Pico Plus 2 W. If I use a regular Pico 2 it works as expected. Using the Pimoroni Firmware (1.26.1) for the pico plus 2. What am I missing here?
Working OK for me?
import time
import random
from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY_2, PEN_P8
from pimoroni import RGBLED, Button
display = PicoGraphics(display=DISPLAY_PICO_DISPLAY_2, pen_type=PEN_P8)
display.set_backlight(1.0)
WIDTH, HEIGHT = display.get_bounds()
led = RGBLED(26, 27, 28)
led.set_rgb(0, 0, 0)
from machine import Pin
button_a = Pin(12, Pin.IN, Pin.PULL_UP)
button_b = Pin(13, Pin.IN, Pin.PULL_UP)
button_x = Pin(14, Pin.IN, Pin.PULL_UP)
button_y = Pin(15, Pin.IN, Pin.PULL_UP)
# We're creating 100 balls with their own individual colour and 1 BG colour
# for a total of 101 colours, which will all fit in the custom 256 entry palette!
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)),
)
)
BG = display.create_pen(40, 40, 40)
while True:
if button_a.value() == 0:
led.set_rgb(255, 0, 0)
elif button_b.value() == 0:
led.set_rgb(0, 255, 0)
elif button_x.value() == 0:
led.set_rgb(0, 0, 0)
elif button_y.value() == 0:
led.set_rgb(0, 0, 255)
else:
display.set_pen(BG)
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)
EDIT: Did you solder the headers on the Pico 2W
Yeah that code runs but doesn’t render to the screen. I did solder header pins to the pico plus 2 w. You think that has something to do with it?
Couldn’t hurt to have a good look at them and or post a pic.
The pins used are as follows, except for the RGB LED. Instead of 6, 7, 8 it’s 26, 27, 28. I just realized I tested with a Display Pack 2 not the 2.8, shouldn’t make any difference other than the onboard LED pins used. The rest of the code is identical.
Yeah, the 2.8” takes DISPLAY_PICO_DISPLAY_2 in the PicoGraphics constructor which I changed when running your demo code. I checked my solder job and it seems to be fine.
Ah, it’s DISPLAY_PICO_DISPLAY_2 for the 2 and 2.8, and that’s what I had in my code? I have a 2.8 I can test with if you want?
Anyway, you know the display works, and the code is good, so there must be an issue going on with the Pico Plus 2?
