RSS Amplifier

M0YNG.uk Feed · Jul 22, 2021

Raspberry Pi Pico Display Pride

0
Sign in to vote or save

m0yng.uk

I couldn't resist the raspberry pi pico any longer, and I also got a pico display to do with it. This is a pico sized hat that sits directly onto the pico and provides a nice full colour screen, RGB LED, and 4 buttons.

After playing with the demo code I wanted to try something myself, so I thought I'd try making a name badge of sorts, and using the pride flag as the background. Then I wanted to use the buttons, so made each button show a different flag. The LED also changes, trying to show some key colours from the flag.

In this quick demo I've made it run through the flags automatically.

import time
import utime
import picodisplay as display
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)
display.set_led(255,255,0)
display.set_pen(255,255,0)
display.clear()
def clear():
    display.set_pen(0, 0, 0)
    display.clear()
    display.update()
def draw_trans():
    clear()
    stripe_height = int(height/5)
    display.set_pen(91,207,250)
    display.rectangle(0,0,width,stripe_height)
    display.rectangle(0,stripe_height*4,width,stripe_height)
    display.set_pen(245, 171, 185)
    display.rectangle(0,stripe_height,width,stripe_height)
    display.rectangle(0,stripe_height*3,width,stripe_height)
    display.set_pen(255, 255, 255)
    display.rectangle(0,stripe_height*2,width,stripe_height)
    display.set_led(255,0,255)
    display.set_pen(0,0,0)
def draw_pride():
    clear()
    stripe_height = int(height/6)
    display.set_pen(229,0,0)
    display.rectangle(0,stripe_height*0,width,stripe_height)
    display.set_pen(255, 141, 0)
    display.rectangle(0,stripe_height*1,width,stripe_height)
    display.set_pen(255, 238, 0)
    display.rectangle(0,stripe_height*2,width,stripe_height)
    display.set_pen(0, 129, 33)
    display.rectangle(0,stripe_height*3,width,stripe_height)
    display.set_pen(0,76,255)
    display.rectangle(0,stripe_height*4,width,stripe_height)
    display.set_pen(118, 1, 136)
    display.rectangle(0,stripe_height*5,width,stripe_height)
    display.set_led(100,100,100)
    display.set_pen(0,0,0)
def draw_intersex():
    clear()
    display.set_pen(255, 217, 0)
    display.clear()
    display.set_pen(122, 0, 172)
    display.circle(int(width/2), int(height/2), int(height/3))
    display.set_pen(255, 217, 0)
    display.circle(int(width/2), int(height/2), int(height/4))
    display.set_led(122, 0, 172)
    display.set_pen(0,0,0)
def draw_bi():
    clear()
    stripe_height = int(height/5)
    display.set_pen(214,2,112)
    display.rectangle(0,stripe_height*0, width, stripe_height*2)
    display.set_pen(155,79,150)
    display.rectangle(0,stripe_height*2, width, stripe_height)
    display.set_pen(0,56,168)
    display.rectangle(0,stripe_height*3, width, stripe_height*2)
    display.set_led(155,0,150)
    display.set_pen(0,0,0)
def draw_details():
    display.set_pen(0,0,0)
    display.text("Christopher", 5, 10, 100, 4)
    display.text("M0YNG", 20, 40, 100, 7)
    display.update()
while True:
    if display.is_pressed(display.BUTTON_A):
        draw_trans()
        display.text("Trans Rights!", 20,40,100,7)
        display.update()
        utime.sleep(2)
        draw_trans()
    elif display.is_pressed(display.BUTTON_B):
        draw_pride()
        display.text("Stonewall was a riot", 10,10,100,4)
        display.update()
        utime.sleep(2)
        draw_pride()
    elif display.is_pressed(display.BUTTON_X):
        draw_intersex()
        display.text("", 5, 10, 100, 7)
        display.update()
        utime.sleep(2)
        draw_intersex()
    elif display.is_pressed(display.BUTTON_Y):
        draw_bi()
        display.text("", 5, 10, 100, 7)
        display.update()
        utime.sleep(2)
        draw_bi()
    draw_details()
    utime.sleep(0.1)

Read the original on m0yng.uk

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.