long timed action(up to 2hrs)

I tried searching the forum and nothing seemed to help(or I just didn't understand it). I'm trying to get a long timed action, an hour or 2, and can't seem to get it to go. I looked up and found this

"For timers longer than about a minute, you will need to change the type of all variable and parameter definitions for intervl or interval from unsigned int to unsigned long (2 in the .cpp and 3 in the .h)."

So exactly what gets changed in these files?

//here's the cpp file

#ifndef TIMEDACTION_H
#define TIMEDACTION_H

#include "WProgram.h"

#define NO_PREDELAY 0

class TimedAction {

public:
TimedAction(unsigned long interval,void (*function)());
TimedAction(unsigned long prev,unsigned long interval,void (*function)());

void reset();
void disable();
void enable();
void check();

void setInterval( unsigned long interval );

private:
bool active;
unsigned long previous;
unsigned long interval;
void (*execute)();

};

#endif

//This is the h file

#include "TimedAction.h"

/*
|| <>
*/
TimedAction::TimedAction(unsigned long intervl,void (*function)()){
active = true;
previous = 0;
interval = intervl;
execute = function;
}

/*
|| <>
*/
TimedAction::TimedAction(unsigned long prev,unsigned long intervl,void (*function)()){
active = true;
previous = prev;
interval = intervl;
execute = function;
}

void TimedAction::reset(){
previous = millis();
}

void TimedAction::disable(){
active = false;
}

void TimedAction::enable(){
active = true;
}

void TimedAction::check(){
if ( active && (millis()-previous >= interval) ) {
previous = millis();
execute();
}
}

void TimedAction::setInterval( unsigned long intervl){
interval = intervl;
}

I do have one timed action of 10 minutes working as it should, but just cant get the 2hr one to go.
Thanx

Until someone suggests the proper way, you could just time 10 minutes and when that finishes, reset the timer and increment a value. Keep doing that until the value you increment is how long you need.

It looks like the values are set to unsigned long already.
2 hours = 1000 * 60 * 60 * 2 = 720000 mS. Have you tried setting the time action to this? 720000UL

Q12-00006:
Until someone suggests the proper way, you could just time 10 minutes and when that finishes, reset the timer and increment a value. Keep doing that until the value you increment is how long you need.

Thats a good idea. Never thought of it. Im new to this programming thing but sure am having fun learning it

LarryD:
It looks like the values are set to unsigned long already.
2 hours = 1000 * 60 * 60 * 2 = 720000 mS. Have you tried setting the time action to this? 720000UL

Thanx LarryD. I wasnt exactly sure what to look at. Heres my timed action

TimedAction timedAction = TimedAction(7200000,refresh);

So it should change to?

TimedAction timedAction = TimedAction(7200000ul,refresh);

Btw, you forgot a zero:)

Im having internet problems at home and am typing this on my phone, so it may be a while before I get to it.

I have got into the habit of using UL to force unsigned long for the constant (learned from Crossroads).
UL not ul
" left off a zero" I can barely see what I type on my iPad :wink:
TimedAction timedAction = TimedAction( 1000UL6060*2 ,refresh);
Keep having fun

LarryD:
I have got into the habit of using UL to force unsigned long for the constant (learned from Crossroads).
UL not ul
" left off a zero" I can barely see what I type on my iPad :wink:

Keep having fun

UL in caps. Got it. Thanx. I'll keep that in mind for future projects. Thanx a bunch