Create devcontainer.json#283
Open
ghosted213 wants to merge 1 commit into
Open
Conversation
from tiny_fx import TinyFX
from picofx import MonoPlayer
from picofx.mono import FlashSequenceFX, StaticFX
"""
Play an alternating flashing sequence on two of TinyFX's outputs,
recreating the effect of rescue vehicle beacons.
The other outputs are static for illuminated head and tail lights.
Press "Boot" to exit the program.
"""
# Variables
tiny = TinyFX() # Create a new TinyFX object to interact with the board
player = MonoPlayer(tiny.outputs) # Create a new effect player to control TinyFX's mono outputs
# Create a FlashSequenceFX effect for the beacon lights
flashing = FlashSequenceFX(speed=1.0, # The speed to flash at, with 1.0 being 1 second
length=2.0, # The length of the sequence before positions repeat. Usually the number of outputs (6)
flashes=4, # The number of flashes to do within that time
window=0.5) # How much of the flash time to perform the flashes in
# Create StaticFX for the head and tail lights
headlights = StaticFX(brightness=0.7)
taillights = StaticFX(brightness=0.5)
# Set up the mono effects to play. The first two are flashing, the rest are static
player.effects = [
flashing(0),
flashing(1),
headlights,
headlights,
taillights,
taillights
]
# Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt)
try:
player.start() # Start the effects running
# Loop until the effect stops or the "Boot" button is pressed
while player.is_running() and not tiny.boot_pressed():
pass
# Stop any running effects and turn off all the outputs
finally:
player.stop()
tiny.shutdown()
|
您的邮件我已收到,谢谢!
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
from tiny_fx import TinyFX
from picofx import MonoPlayer
from picofx.mono import FlashSequenceFX, StaticFX
"""
Play an alternating flashing sequence on two of TinyFX's outputs, recreating the effect of rescue vehicle beacons.
The other outputs are static for illuminated head and tail lights.
Press "Boot" to exit the program.
"""
Variables
tiny = TinyFX() # Create a new TinyFX object to interact with the board
player = MonoPlayer(tiny.outputs) # Create a new effect player to control TinyFX's mono outputs
Create a FlashSequenceFX effect for the beacon lights
flashing = FlashSequenceFX(speed=1.0, # The speed to flash at, with 1.0 being 1 second
length=2.0, # The length of the sequence before positions repeat. Usually the number of outputs (6)
flashes=4, # The number of flashes to do within that time
window=0.5) # How much of the flash time to perform the flashes in
Create StaticFX for the head and tail lights
headlights = StaticFX(brightness=0.7)
taillights = StaticFX(brightness=0.5)
Set up the mono effects to play. The first two are flashing, the rest are static player.effects = [
]
Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt) try:
Stop any running effects and turn off all the outputs finally: