-- Leo's gemini proxy

-- Connecting to m0yng.uk:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini;lang=en

Raspberry Pi Pico Display Pride - M0YNG.uk

Created 2021-07-22

Tagged

Hacking

Code


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.


It can show:


Pride rainbow

Trans

Intersex

Bi


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


GIF of Pico display showing the flags [IMG]


Code uses the Pimoroni Pico Firmware


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)

-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-

๐Ÿ–ค Black Lives Matter

๐Ÿ’™๐Ÿค๐Ÿ’œ Trans Rights are Human Rights

โค๏ธ๐Ÿงก๐Ÿ’›๐Ÿ’š๐Ÿ’™๐Ÿ’œ Love is Love


Copyright ยฉ 2024 Christopher M0YNG - It is forbidden to use any part of this site for crypto/NFT/AI related projects.

Code snippets are licenced under the Hippocratic License 3.0 (or later.)

Page generated 2024-03-24 by Complex 19

-- Response ended

-- Page fetched on Sat May 18 20:02:14 2024