SomeoneFromGermany
Well-known member
I have this written this class to simplify controlling 4 pumps (using an H-bridge motor driver which requires only a HIGH signal to work).
I need those 4 instances along with the IntervalTimers and callbacks.
But for some reason it raises the "invalid use of non-static member function" exception.
I also tried referencing the internal methods and external functions.
The external referencing worked to a certain degree, but due to the lack of arguments in the IntervalTimer.begin() function i cannot use the needed variables.
Anyone got a solution?
I need those 4 instances along with the IntervalTimers and callbacks.
But for some reason it raises the "invalid use of non-static member function" exception.
I also tried referencing the internal methods and external functions.
The external referencing worked to a certain degree, but due to the lack of arguments in the IntervalTimer.begin() function i cannot use the needed variables.
Anyone got a solution?
Code:
class PumpClass {
private:
IntervalTimer PumpTimeout;
void pumpOutWithTimer()
{
_secs = 0;
starttime = 0;
isActive = false;
digitalWriteFast(_Pin, LOW);
PumpTimeout.end();
}
public:
unsigned short _ID;
unsigned short _Pin;
volatile bool isActive = false;
volatile uint8_t _secs = 0;
volatile unsigned long starttime = 0;
PumpClass(unsigned short ID, unsigned short Pin/*, void *callback*/) {
_ID = ID;
_Pin = Pin;
//pumpOutWithTimer = &callback;
}
unsigned long millisLeft()
{
return isActive ? _secs - (millis() - starttime) : 0;
}
void run(uint8_t seconds) {
_secs = seconds;
starttime = millis();
isActive = true;
digitalWriteFast(_Pin, LOW);
PumpTimeout.begin(pumpOutWithTimer, seconds * 1000000);
}
};
//Pinout is a static class for used pins
PumpClass Pump0(0, Pinout.P0);
PumpClass Pump1(1, Pinout.P1);
PumpClass Pump2(2, Pinout.P2);
PumpClass Pump3(3, Pinout.P3);