Hi to everyone reading.
I'm having a problem getting my coding to the next level. I'd like to reduce the redundancy and the copy-paste. Is there a way to having a void with a recall to a function inside the argument? i hope to have used the right terms, here's my particular case:
void resetIn3(int k, void f()) {
if (millis() - currentMillis > k && millis() - currentMillis <= k+1000) {
lcd.setCursor(13, 0);
lcd.print("3");
}
if (millis() - currentMillis > k+1000 && millis() - currentMillis <= k+2000) {
lcd.setCursor(13, 0);
lcd.print("2");
}
if (millis() - currentMillis > k+2000 && millis() - currentMillis <= k+3000) {
lcd.setCursor(13, 0);
lcd.print("1");
}
if (millis() - currentMillis > k+3000) {
lcd.setCursor(13, 0);
lcd.print("OK");
f();
}
}
void resetClock() {
setTime(00, 00, 00, 01, 01, 1970);
mode = 1;
}
I'd like to have resetClock executed within the resetIn3() when I write f(). Of course this is to re-use the countdown code with other functions beside resetClock().
Is it possible? the sketch compiles as it is, but when I write
resetIn3(2000, resetClock());
inside the void loop, it doesn't compile... where ai I doing wrong?