Hello - I’m working on a project to build a lighthouse style lighting effect using the TinyFX and the ‘pulse wave’ example - so far I’ve built a little 3d printed lantern for the leds:
but i’m stuck on the code (complete python novice). My desired effect is to cycle the LEDs once (like a lighthouse sweep) and then wait for 5 seconds (similar to the lighthouse flash pattern at Orfordness, which the model is based on), then repeat.
With the example code I’ve tried starting the stopping the player at the bottom:
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():
time. sleep(0.7)
player.stop()
tiny.shutdown()
time. sleep(4)
player.start()
pass
Stop any running effects and turn off all the outputs
finally:
player.stop()
tiny.shutdown()
but it starts where the code stopped running, so is incomplete cycle. Working out the exact timings is complicated. Is there a simpler way or am I missing something?
You could modify the PulseWaveFX class that’s being used by adding an additional, optional constructor argument named “delay”. If not included it would be ignored (i.e., the current behaviour). The source code is found in: tinyfx/lib/picofx/mono/pulse.py
You do need to import the utime library. I haven’t tested this but it would be something like:
A custom FX could be written to handle it too, but this would need to be a class based off Updatable rather than Cycling to give it access to the internal timing values, like the TrafficFX does: picofx/picofx/mono/traffic.py at main · pimoroni/picofx · GitHub
If anyone has a go at this, I’d happily accept any pull request :)