I think you will find that the RGB LED is already set up and expecting PWM control with r,g,b in the range 0-255.
Just use
display.set_led(r,g,b)
It is all set up for you in PWM not boolean 0/1 True/False
That is what I did in the tutorial
Pimoroni Pico Display Workout : 3 Steps - Instructables
Hope this helps
# Pimoroni Pico Display Using the RGB LED
# Tony Goodhew 1st March 2021
# Tested with Pimoroni UF2 Ver: 0.0.7
import picodisplay as display
import utime, random, math
from machine import Pin
width = display.get_width()
height = display.get_height()
display_buffer = bytearray(width * height * 2)
display.init(display_buffer)
# Set the backlight to 90% - Needed on Display
display.set_backlight(0.9)
def blk():
display.set_pen(0,0,0)
display.clear()
display.update()
def title(msg,r,g,b):
blk()
display.set_pen(r,g,b)
display.text(msg, 20, 10, 200, 4)
display.update()
utime.sleep(2)
blk()
blk()
display.set_pen(255,255,0)
title("Blink",0,0,200)
display.set_pen(255,255,255)
for i in range(5):
display.set_led(0,255,0)
utime.sleep(0.5)
display.set_led(0,0,0)
utime.sleep(0.5)
display.set_pen(255,255,0)
title("Control",0,0,200)
display.set_pen(200,200,200)
display.text(" Press buttons A & B ", 5, 3, 230, 2)
display.text("Press Y button to halt", 5, 17, 230, 2)
display.update()
pot = 50
running = True
while running:
if display.is_pressed(0): # A pressed
pot = pot + 1
if pot > 100: pot = 100
if display.is_pressed(1): # B pressed
pot = pot - 1
if pot < 0 : pot = 0
utime.sleep(0.02)
display.update()
display.set_pen(pot,pot,pot) # grey to white
display.circle(120,140,50)
# Calculate rainbow colour
if pot < 50: # Blue -> Cyan -> Green
r = 0
g = int(pot * 2)
b = int(100 - pot * 2)
else: # Green -. Yellow -> Red
r = int((pot-50)*2)
g = int(100 - ((pot-50)*2))
b = 0
display.set_led(r,g,b)
percent = pot
display.set_pen(0,0,0)
display.rectangle(0,30,200,40)
display.set_pen(200,0,0)
display.text(str(pot), 100, 30, 200, 4)
display.update()
if display.is_pressed(3): # Y button is pressed ?
running = False
# Tidy up
blk()
display.set_led(0,0,0) # Set the LED to black
display.set_pen(200,0,0)
led = Pin(25, Pin.IN, Pin.PULL_DOWN) # Normal state
display.text("All Done!", 55, 40, 200, 3)
display.update()
utime.sleep(2)
blk()