Files
pybricks-api/examples/pup/hub_primehub/display_animate.py
T
Laurens Valk bd7806d2d4 all: Format with black.
Also activate auto formatting. Bump flake8 and mark black
disagreements in setup.cfg.
2022-05-27 16:22:05 +02:00

20 lines
540 B
Python

from pybricks.hubs import PrimeHub
from pybricks.parameters import Icon
from pybricks.tools import wait
# Initialize the hub.
hub = PrimeHub()
# Turn the hub light off (optional).
hub.light.off()
# Create a list of intensities from 0 to 100 and back.
brightness = list(range(0, 100, 4)) + list(range(100, 0, -4))
# Create an animation of the heart icon with changing brightness.
hub.display.animate([Icon.HEART * i / 100 for i in brightness], 30)
# The animation repeats in the background. Here we just wait.
while True:
wait(100)