I noticed while reading one of @Gunner post he used a clever bit of coding with a Timed Lambda Function.
// Timed Lambda Function - UpTime
upTime = timer.setInterval(500L, []() {
Blynk.virtualWrite(V12, millis() / 1000);
}); // END Timer Function
I’m trying to use @Gunner timer example with an encased “If Statement”.
BLYNK_WRITE(V13) {
int autoOff = param.asInt();
if ((autoOff == HIGH) && (lightsOn > 0) && (X1 == 1) || (X2 == 1) ) {
timer1 = tripWire.setTimeout(lightsOn * 3600000L, []() {
if (autoOff == HIGH) {
digitalWrite(Exterior, LOW);
}
});
The purpose of the second “if (autoOFF == HIGH)” is to re-verify after the timers time has past that the condition is still HIGH (Blynk Virtual Button is still HIGH) before the next command possible hours later. As soon as I put the IF statement within the timer1’s statement, I get an error that “… autoOff is not captured”.
Everything compiles fine until I throw in the second IF Statement no matter how simple or nested.
Can you not use “IF Statements” within a Timed Lambda environment within Blynk?
Having been a student of @Gunner work, comments and code, I’ve searched high and low and only seen a limited number of comments or code similar to this and none with IF Statements nested inside.
Thanks in advance