-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add a Bool to return a value to pattern blink #1
Comments
Good idea! This could also be solved by a function which returns the current state, something like an enum Your example would become something like this: int distance_mm = read_distance();
if light.state == IDLE {
light.pattern(distance_mm);
} Let me know what you think about this. |
Great! Will you update the library then? :) |
Yep, first thing in the new year ;) |
Hi! Any news?? 😊😊😊 |
Hey, yes I found that you can already do this with the existing code: #include <Blinkenlight.h>
Blinkenlight led(13);
int count = 1;
void setup()
{
led.setSpeed(200);
}
void loop()
{
if (!led.isOn()) {
count++;
if (count >= 5) {
count = 1;
}
led.pattern(count, false);
}
led.update();
} This will blink 1, 2, 3, 4, 1, 2, 3, ... For your usecase you just have to replace |
There could be a function like this:
bool pattern(int num, SpeedSetting speed, bool repeat = false)
Then the blink code would play only once, and some action by another function could be taken as soon as the blink is over. Like this:
If I put my hand over a distance sensor, it would blink the number of millimeters that the hand is over the sensor. But then some function could only allow another "distance measure by the sensor" when the number of mms blinked is over. So the bool argument would indicate the end of the blink pattern (for a repeat = false)
Thanks!
The text was updated successfully, but these errors were encountered: