Hi All
I have just purchased the pico display pack 2.0 (320x240) and in the sample code it requires that I access Picographs ( from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY, PEN_P8 )
but I cannot install it from the PyPI plugin section.
I am able to find the folder in Pimoroni libraries on line but I dont know how to get the required file onto my computer, I’m using windows 11.
See code below
import time
import random
from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY, PEN_P8
display = PicoGraphics(display=DISPLAY_PICO_DISPLAY, pen_type=PEN_P8)
display.set_backlight(1.0)
WIDTH, HEIGHT = display.get_bounds()
# 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:
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) `
...................................................................
pico_graphics
} this is the path on the pimoroni site
I hope I have provided enough info, I have tried to correct the code formatting but it didn’t work
Hopefully this is understandable
looking forward to your replies
Nick