Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Using IntervalTimer in Arduino Library

  1. #1
    Senior Member brtaylor's Avatar
    Join Date
    Mar 2016
    Location
    Portland, OR
    Posts
    536

    Using IntervalTimer in Arduino Library

    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!

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    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.)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •