Пример #1
0
    def __init__(self) -> None:
        collect()  #clean up memory
        self.__b = bytearray(115200)  #init buffer

        exp.init(self.__b)  #init explorer
        exp.set_audio_pin(0)  #set audio pin

        self.__palette = b'`\x06`\xce\x00\xc8\x19\x00\xe0\x07\xe0\xff\x00\xf8\x1f\x00@\x04@\x8c\x00\x88\x11\x00\x11\x88\x1f\xf8'
        self.__fart = 200  #loser/wrong sound
        self.__startscreen()  #init start screen
Пример #2
0
# This example takes the temperature from the Pico's onboard temperature sensor, and displays it on Pico Explorer, along with a little pixelly graph.
# It's based on the thermometer example in the "Getting Started with MicroPython on the Raspberry Pi Pico" book, which is a great read if you're a beginner!

import machine
import utime

# Pico Explorer boilerplate
import picoexplorer as display
width = display.get_width()
height = display.get_height()
display_buffer = bytearray(width * height * 2)
display.init(display_buffer)

# reads from Pico's temp sensor and converts it into a more manageable number
sensor_temp = machine.ADC(4)
conversion_factor = 3.3 / (65535)

i = 0

while True:
    # the following two lines do some maths to convert the number from the temp sensor into celsius
    reading = sensor_temp.read_u16() * conversion_factor
    temperature = round(27 - (reading - 0.706) / 0.001721)

    # this if statement clears the display once the graph reaches the right hand side of the display
    if i >= (width + 1):
        i = 0
        display.set_pen(0, 0, 0)
        display.clear()

    # chooses a pen colour based on the temperature
Пример #3
0
## This example borrows a CircuitPython hsv_to_rgb function to cycle through some rainbows on Pico Explorer's screen and RGB LED . If you're into rainbows, HSV (Hue, Saturation, Value) is very useful!

import utime
import picoexplorer as display

# Set up and initialise Pico Explorer
buf = bytearray(display.get_width() * display.get_height() * 2)
display.init(buf)


# From CPython Lib/colorsys.py
def hsv_to_rgb(h, s, v):
    if s == 0.0:
        return v, v, v
    i = int(h * 6.0)
    f = (h * 6.0) - i
    p = v * (1.0 - s)
    q = v * (1.0 - s * f)
    t = v * (1.0 - s * (1.0 - f))
    i = i % 6
    if i == 0:
        return v, t, p
    if i == 1:
        return q, v, p
    if i == 2:
        return p, v, t
    if i == 3:
        return p, q, v
    if i == 4:
        return t, p, v
    if i == 5:
Пример #4
0
import time
import picoexplorer as explorer

width = explorer.get_width()
height = explorer.get_height()

display_buffer = bytearray(width * height * 2)  # 2-bytes per pixel (RGB565)
explorer.init(display_buffer)

explorer.set_audio_pin(0)

i = 1

while True:
    explorer.set_pen(120, 40, 60)
    explorer.clear()

    adc0 = int(explorer.get_adc(0) * 120)
    adc1 = int(explorer.get_adc(1) * 120)
    adc2 = int(explorer.get_adc(2) * 120)

    explorer.set_pen(255, 255, 255)

    explorer.text("ADC0:", 20, 20, 100)
    explorer.text("ADC1:", 20, 40, 100)
    explorer.text("ADC2:", 20, 60, 100)

    explorer.set_pen(adc0 * 2, 0, 0)
    explorer.circle(90 + adc0, 26, 10)

    explorer.set_pen(0, adc1 * 2, 0)
Пример #5
0
# This example shows you how you can use Pico Explorer's onboard buzzer as a speaker to play different notes and string them together into a bleepy tune.
# It uses code written by Avram Piltch - check out his Tom's Hardware article! https://www.tomshardware.com/uk/how-to/buzzer-music-raspberry-pi-pico
# You'll need to connect a jumper wire between GPO and AUDIO on the Explorer Base to hear noise.

import utime
import picoexplorer as explorer

# Set up and initialise Pico Explorer
buf = bytearray(explorer.get_width() * explorer.get_height() * 2)
explorer.init(buf)

# tells Pico Explorer which pin you'll be using for noise
explorer.set_audio_pin(0)

# this handy list converts notes into frequencies, which you can use with the explorer.set_tone function
tones = {
    "B0": 31,
    "C1": 33,
    "CS1": 35,
    "D1": 37,
    "DS1": 39,
    "E1": 41,
    "F1": 44,
    "FS1": 46,
    "G1": 49,
    "GS1": 52,
    "A1": 55,
    "AS1": 58,
    "B1": 62,
    "C2": 65,
    "CS2": 69,
Пример #6
0
import time, random
import picoexplorer as exp
from machine import Pin

width = exp.get_width()
height = exp.get_height()

display_buffer = bytearray(width * height * 2)  # 2-bytes per pixel (RGB565)
exp.init(display_buffer)

#exp.set_backlight(1.0)
exp.set_audio_pin(0)

green = exp.create_pen(0, 155, 0)
red = exp.create_pen(155, 0, 0)
blue = exp.create_pen(0, 0, 155)
yellow = exp.create_pen(155, 155, 0)
lit_green = exp.create_pen(0, 255, 0)
lit_red = exp.create_pen(255, 0, 0)
lit_blue = exp.create_pen(0, 0, 255)
lit_yellow = exp.create_pen(255, 255, 0)
white = exp.create_pen(200, 200, 200)
black = 0

buttons = ["A", "B", "Y", "X"]
half_width = width // 2
half_height = height // 2
leda = Pin(4, Pin.OUT)
ledy = Pin(3, Pin.OUT)
ledx = Pin(2, Pin.OUT)
ledb = Pin(5, Pin.OUT)
Пример #7
0
 def __init__(self):
     AbstractPlotter.__init__(self)
     width = display.get_width()
     height = display.get_height()
     self._display_buffer = bytearray(width * height * 2)
     display.init(self._display_buffer)