BlynkTimer Remaining time

Hi all,

no code to paste, just a question about BlynkTimer.

As Pete Knight proposed me a few weeks ago to use BlynkTimer instead of millies…and he was right as its more understandable/cleaner coding.

But…does anybody know if we can get the remaining time from a timer? I mean, I start a timer, then disable it (by using it’s ID as Pete explains)…but then I would like to know the time it has been running or the remaining time.

Thx!!!

It’s not a piece of functionality that’s built-in to the original SimpleTimer, so I doubt that it exists in BlynkTimer either.

There are some (rather clunky) workarounds though.

Lets say you have a timer that has an interval of two hours (120 minutes or 7200 seconds). You could instead have a timer that runs once every second, and increments a counter then does a simple if test…

counter++;
if(counter ==7200) // if we've reached teh 2 hyour mark
{
  counter = 0;
  // call the function you wnat to execute every 2 hours in here...
}

your ‘counter’ then tells you how many seconds you’ve been running for, and 7200-counter tells you time remaining.

As I said, it’s clunky though!

Pete.

Hi Pete,

I was expecting you to answer :slight_smile:

I’m already using your ‘clunky’ solution but I was hoping there was a cleaner way.

Ok, thx for the info/reply again!!!

1 Like