Closed mitra42 closed 1 week ago
First thoughts are a function like delay that uses a local variable specific to a actuator or sensor e.g. (and this is not correct or optimal C++, its just an example of what actuator_blinken might look like)
int foo; bool state;
foo = clock_now; state=HIGH;
if (state == HIGH && clock_waited(foo, 2000)) {
digitalWrite(BUILTIN_LED, LOW); // set the LED LOW if its been 2000
foo = clock_now();
state = LOW;
} else if (state == LOW && clock_waited(foo, 2000)) {
digitalWrite(BUILTIN_LED, HIGH); // set the LED HIGH if its been 2000 at LOW
foo = clock_now();
state = HIGH;
}
Thanks @janandrzejewski for the pull-request, note that this surfaced a need for a new section called system_clock as I'm envisioning logic for application dependent stuff, for example an application might decide that when a sensor exceeded some threshhold that the light gets blinked, and I see that happening in the logic_xxx area.
The demo version of actuator_blinken uses a
delay(2000)
which is obviously a bad idea.Instead it should be using some kind of system clock