Using IntervalTimer in Arduino Library

Status
Not open for further replies.

brtaylor

Well-known member
I'm sure I need more coffee, but...I'm trying to add an interval timer within an arduino library, specifically to emulate 2 stop bits on Teensy 3.1/3.2 for SBUS.

I have the interrupt function defined as well as the IntervalTimer object as private members of the SBUS class.

Code:
class SBUS{
	public:
    	        void write(int16_t* channels);
  	private:
  		void sendByte(void);
  		IntervalTimer serialTimer;	
};

And I have the sendByte function defined as:

Code:
void SBUS::sendByte(void) {
	
	if(_sendIndex < 25) {
		_port->write(_packet[_sendIndex]);
		_sendIndex++;
	}
	else{
		serialTimer.end();
	}
}

With it called like:

Code:
serialTimer.begin(sendByte,120);

But I'm getting a compile error about no matching function call with sendByte being overloaded.

Code:
error: no matching function for call to 'IntervalTimer::begin(<unresolved overloaded function type>, int)'
   serialTimer.begin(sendByte,120);

Any hints? Thanks much!
 
Yes, try a global function instead. It will not work with an object (only with dirty tricks, like using a pointer to your function, as far as i know.)
 
Status
Not open for further replies.
Back
Top