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