MichaelMeissner
Senior Member+
I switched my little neopixel bowtie project to use a Teensy 4.0 (from Teensy LC). One of the things that prompted me to use the Teensy 4.0 was the on/off pin that can be used to turn off most of the Teensy functionality. However, I forgot since I'm powering the neopixels from VIN, that the on/off switch doesn't affect that. That means when I turn off the Teensy 4.0, the LEDs are frozen at their last position (and of course using power).
Now, I likely will overload the button I use to switch patterns to off the lights as a state, but I was wondering if there was a way I can detect when the on/off pin was grounded to turn off the lights, and then another hook when the power is restored. Obviously I need some time to turn off the LEDs, so I could live with just notification of the button press before the 5 second window expires (or a blocking call that waits until the call finishes to turn off power), but I also would need a hook to run when power is restored.
Now, I likely will overload the button I use to switch patterns to off the lights as a state, but I was wondering if there was a way I can detect when the on/off pin was grounded to turn off the lights, and then another hook when the power is restored. Obviously I need some time to turn off the LEDs, so I could live with just notification of the button press before the 5 second window expires (or a blocking call that waits until the call finishes to turn off power), but I also would need a hook to run when power is restored.