Millis stop for delay?

I have a few millis counters in my design and was wondering, does a 'delay' anywhere in the script stop the millis from counting or does it continue regardless?

The millis() incr. also if delay() is used.
Try avoiding delays

Thanks. What I'm trying to work around is a timed call issue. Basically I have the following...

If (tm.hour == 0) && (tm.minute == 0) && (tm.second == 0)
{
Void something();
}

However this will call void something several times in that 1 second. I only want it calling once. I thought by adding a delay of just 1000 after the void call it will elimate multiple calls. Unless there is a better way of doing it

However this will call void something several times in that 1 second. I only want it calling once.

You don't have to let that happen.

bool beenThereDoneThat = false;
if (tm.hour == 0) && (tm.minute == 0) && (tm.second == 0)
{
   if(!beenThereDoneThat)
   {
      GoThere();
      DoThat();

      beenThereDoneThat = true;
   }
}
else
   beenThereDoneThat = false;

Stevelondon wrote (in part):

If (tm.hour == 0) && (tm.minute == 0) && (tm.second == 0)
{
  Void something();
}

I hope not. I think that Stevelondon meant

If ((tm.hour == 0) && (tm.minute == 0) && (tm.second == 0))
{
  something();
}

(void does not have a capital V and should not occur here, and I have added parentheses to the if statement.)

Stevelondon could use something like (untested):

boolean callSomething = true ;  //  Put this near the top as a global variable.

If ((tm.hour == 0) && (tm.minute == 0) && (tm.second == 0))
{
  if (callSomething) 
  {
    something();
    callSomething = false ;
  }
} else 
{
    callSomething = true ;
}

Stevelondon:
Thanks. What I'm trying to work around is a timed call issue. Basically I have the following...

Basically I'd do something like

void loop()
{
static byte oldhour;
updateTimeVariables(); // i.e. read them fresh from RTC
if (hour!=oldhour&& hour==0) something();
oldhour=hour;
}

In that case the if clause becomes true after hour changed from 23 to 0,
especially if time changes from 23:59:59 to 00:00:00

Stevelondon:
I have a few millis counters in my design and was wondering, does a ‘delay’ anywhere in the script stop the millis from counting or does it continue regardless?

You don’t have “a few millis counters”, you have one millis counter. Its read by millis() and
maintained by the timer0 interrupt handler, so it counts all by itself.

vaj4088:
Stevelondon wrote (in part):

If (tm.hour == 0) && (tm.minute == 0) && (tm.second == 0)

{
 Void something();
}




I hope **not**. I think that Stevelondon meant



If ((tm.hour == 0) && (tm.minute == 0) && (tm.second == 0))
{
 something();
}




(void does not have a capital V and should not occur here, and I have added parentheses to the if statement.)

I apologise, I was on the train on the way home and quickly wrote the code out from memory on my phone. I'm not a hardcore coder and taught myself the basics. Sorry.

MarkT:
You don't have "a few millis counters", you have one millis counter. Its read by millis() and
maintained by the timer0 interrupt handler, so it counts all by itself.

Yeah I realise that MarkT, I just meant I have a few things running from it if you know what I mean.

PaulS:
You don't have to let that happen.

bool beenThereDoneThat = false;
if (tm.hour == 0) && (tm.minute == 0) && (tm.second == 0)

{
  if(!beenThereDoneThat)
  {
      GoThere();
      DoThat();

beenThereDoneThat = true;
  }
}
else
  beenThereDoneThat = false;

Thanks Paul. I did think of doing something like this but my only concern was at the point of 00 seconds, it would do the above as you have mentioned, but then if it gets back to 'beenThereDoneThat = false;' before the clock goes to 01, it will cycle it again won't it? I'm pretty sure when I tried something similar before it managed the cycle about 3 times in that one second timeframe.

but then if it gets back to 'beenThereDoneThat = false;' before the clock goes to 01, it will cycle it again won't it?

How will it get to the statement that sets beenThereDoneThat to false? Will that EVER happen when tm.hour is 0 and tm.minute is 0 and tm.second is 0?

I think is needs a && beenThereDoneThat==false in the if, then no matter how fast it gets there, even while second is 0, because we just set beenThereDoneThat==true it won't go in there.

edit: then you need to set it back to false a bit later, by say testing second for becoming 1, then you're good for next time.

Stevelondon:
Yeah I realise that MarkT, I just meant I have a few things running from it if you know what I mean.

Well if you say what you mean it causes less confusion to others.

PaulS:
How will it get to the statement that sets beenThereDoneThat to false? Will that EVER happen when tm.hour is 0 and tm.minute is 0 and tm.second is 0?

Well the first time it will enter it and activate 'go there' and 'do that', then the next time around it will miss that and reset 'beentheredonethat' to false meaning that the third pass it will reenter the condition and 'go there' and 'do that' again. If it loops quick enough to cover 3 loops within that one second gap, it will activate it more than once.

manor_royal:
I think is needs a && beenThereDoneThat==false in the if, then no matter how fast it gets there, even while second is 0, because we just set beenThereDoneThat==true it won’t go in there.

edit: then you need to set it back to false a bit later, by say testing second for becoming 1, then you’re good for next time.

Yes yes yes… Great idea. Thanks.

Stevelondon:
Yes yes yes... Great idea. Thanks.

Was just typing a reply to your #13 to go look at my #11 :wink:

Stevelondon:
Thanks. What I'm trying to work around is a timed call issue. Basically I have the following...

If (tm.hour == 0) && (tm.minute == 0) && (tm.second == 0)
{
Void something();
}

However this will call void something several times in that 1 second.

No it will not. I'm not sure you have acknowledged why.

I was on the train on the way home and quickly wrote the code out from memory on my phone.

You haven't shown you realize what you did there.

See Gammon Forum : Electronics : Microprocessors : Arduino programming traps, tips and style guide