コード例 #1
0
import time
import math
import random

from pimoroni_i2c import PimoroniI2C
from breakout_dotmatrix import BreakoutDotMatrix

PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}

i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
display = BreakoutDotMatrix(i2c)
start_time = time.time()


def eye(x, y):
    display.set_pixel(x, y, True)
    display.set_pixel(x, y + 1, True)
    display.set_pixel(x + 1, y, True)
    display.set_pixel(x + 1, y + 1, True)


while True:
    t = (time.time() - start_time) * math.pi

    # Get eye x and y positions in the range 0.0 to 1.0
    # You can plug in your own 0.0 to 1.0 values here
    x = (math.sin(t / 2) + 1) / 2
    y = (math.sin(t / 4) + 1) / 2

    # Multiply them up to display coords and convert to int
コード例 #2
0
ファイル: image.py プロジェクト: slabua/pimoroni-pico
import time
import math

from pimoroni_i2c import PimoroniI2C
from breakout_dotmatrix import BreakoutDotMatrix

PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}

i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
display = BreakoutDotMatrix(i2c)

#        Left Image     Padding  Right Image    Padding
image = [
    0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1,
    0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0,
    1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0
]

image_height = 7
image_padding = 3  # 3 columns of padding
image_width = math.floor(len(image) / image_height)

arr = bytearray(image)

offset = 0
while True:
    display.set_image(arr,
                      image_width,
コード例 #3
0
ファイル: timer.py プロジェクト: slabua/pimoroni-pico
import time

from pimoroni_i2c import PimoroniI2C
from breakout_dotmatrix import BreakoutDotMatrix

PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}

address = 0x61
start_time = time.time()

i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
display = BreakoutDotMatrix(i2c, address=address)
display.clear()
display.show()

while True:
    second = str((time.time() - start_time) % 60)
    if len(second) == 1:
        left = '0'
        right = second[0]
    else:
        left = second[0]
        right = second[1]

    display.set_character(0, ord(left))
    display.set_character(5, ord(right))
    display.show()
    time.sleep(1.0 / 60)
コード例 #4
0
import time
import math
import random

from breakout_dotmatrix import BreakoutDotMatrix

display = BreakoutDotMatrix()
width = display.WIDTH
height = display.HEIGHT

values = [0, 0, 0, 0, 0]
start_time = time.time()

while True:
    # Add a new random value to our list and prune the list to visible values
    values.insert(0, random.randint(0, height))
    values = values[:width]

    # Animate a value from 0 to height + 1
    value = (math.sin((time.time() - start_time) * math.pi) + 1) / 2.0
    value *= height + 1
    value = math.floor(value)

    for y in range(height):
        y = height - 1 - y

        for x in range(width // 2):
            # Left
            display.set_pixel(x, y, value <= y)

            # Right