-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RGB emergency - Add support for RGB channel, and use button long press to toggle effect #13
Closed
+46
−11
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Update rescue_vehicle.py - add RGB support
I've only got RGB LEDs 🎨 It was also an exercise in understanding how to do multi colour flash. Next I need to look at using the sequences, or adding a flashing RGB FX function
commit 3be56706caf8d6004680c867a02a4480710ea775
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
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 | ||
player = ColourPlayer(tiny.rgb) # Create a new effect player to control TinyFX's RGB output | ||
monoplayer = MonoPlayer(tiny.outputs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
# Create and set up an red blue flashing effect to play | ||
player.effects = [ | ||
RGBBlinkFX(colour=COLOURS, # The colour (or colours to blink in sequence) | ||
phase=0.0, | ||
speed=EMERGENCY_BLINK_SPEED, # The speed to cycle through colours at, with 1.0 being 1 second (1/T) | ||
duty=0.5) # Amount of the cycle to be "on" | ||
] | ||
|
||
# Create a FlashSequenceFX effect for the beacon lights | ||
flashing = FlashSequenceFX(speed=1.0, # The speed to flash at, with 1.0 being 1 second | ||
|
@@ -27,7 +23,7 @@ | |
|
||
|
||
# Set up the mono effects to play. The first two are flashing, the rest are static | ||
player.effects = [ | ||
monoplayer.effects = [ | ||
flashing(0), | ||
flashing(1), | ||
headlights, | ||
|
@@ -36,6 +32,7 @@ | |
taillights | ||
] | ||
|
||
player.pair(monoplayer) | ||
|
||
# Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt) | ||
try: | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
colour_player
for clarity?