BlinkBuzz - Terrapin-Rocket-Team/SRAD-Avionics GitHub Wiki
Home/Documentation/BlinkBuzz
Source: https://github.com/DrewBrandt/BlinkBuzz
This library allows you to control the onboard LED and buzzer on the Teensy 4.1. It is used to provide feedback to the user about the state of the rocket. The library is designed to be easy to use and flexible, allowing for easy control of the LED and buzzer. It includes async capabilities for feedback without blocking code execution.
See the source code for more information about how to use it.
Specifically, here is how we use it.
We start by initializing it:
int allowedPins[] = {LED_BUILTIN, BUZZER};
BlinkBuzz bb(allowedPins, 2, true);
The BlinkBuzz library includes a reference to an external bb
variable that allows us to access this object from any file that includes the library. This is useful for providing feedback from any class.
In the setup function, async features do not work. For feedback here, we simply use the synchronous versions:
bb.onoff(BUZZER, 100, 4, 100);//100ms on, 4 times, 100ms off
In the loop function, we call bb.update()
to allow the async features to work. Then in another class, such as in State.cpp
, we can include the library and call an async function for events, such as launch detection:
bb.aonoff(BUZZER, 200);//200ms beep
This will cause the buzzer to beep asynchronously for 200ms. The update()
function must be called in the loop function for this to work.
That's it. If you need more information, check the source code or reach out to Drew Brandt.