Skip to content
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
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

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
tyeth authored Nov 13, 2024
commit 3be56706caf8d6004680c867a02a4480710ea775
25 changes: 11 additions & 14 deletions examples/tiny_fx/examples/showcase/rescue_vehicle.py
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

colour_player for clarity?

monoplayer = MonoPlayer(tiny.outputs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mono_player for readability


# 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: