Lack of corresponding function error when using attachInterrupt

I have a small mistake with my latest Arduino project code, which uses the TimerOne library to display numbers on a 4-digit 7-segment display. I use interrupt so that the microprocessor constantly switches between each digit, since they are essentially connected to each other.

I have code that works great if I store all this in the main PDE file, but I thought it was better to isolate the display in my class.

My compiler has problems with the second line of the following code in the PDE:

Timer1.initialize(500);
Timer1.attachInterrupt(digitDisplay.flashDigit,500); 

The second argument to attachInterrupt should be optional, I tried with this and without it! Anyway, I get the following error:

DigitDisplayTest.cpp: In function 'void setup()':
DigitDisplayTest:29: error: no matching function for call to     'TimerOne::attachInterrupt(<unresolved overloaded function type>)'
C:\Program Files (x86)\arduino-0022\arduino-0022\libraries\Timer1/TimerOne.h:62: note: candidates are: void TimerOne::attachInterrupt(void (*)(), long int)

DigitDisplay ( digitDisplay ), flashDigit :

class DigitDisplay
{
  private:
    /*...*/
  public:
    /*...*/
    void flashDigit();
}

void DigitDisplay::flashDigit()
{ 
  wipeDisplay();
  for (int i = 0; i < _digitCount ; i++)
  {
    if ( i == _digit ) digitalWrite( _digitPins[i], HIGH );
    else digitalWrite( _digitPins[i], LOW );
  }
  displayNumber(_digits[_digit]);
  _digit++ ;
  _digit %= _digitCount; 
}

, , , , gubbings flashDigit() - , , , .

, ,

void Interrupt()
{
   digitDisplay.flashDigit();
}

PDE , , , .

, ( , , ), , .

+5
2

. - - (flashDigit()) - , ( void()). - ptr , , , . (, msg ). " ". , . -, , - ​​.

static void flashDigit();

33.1-33.3 Cline ++

+3

TWI Arduino . , .

.h :

#ifndef Classname
#define Classname
class Classname {
  pubic:
    void receiveEvent(int numBytes);
    static void receiveEvent_wrapper(int numBytes);
};
#endif

.cpp :

#include "Classname.h" 
void* pt2Object;

void Classname::receiveEvent_wrapper (int numBytes){
   // explicitly cast to a pointer to Classname
   Classname* mySelf = (Classname*) pt2Object;

   // call member
   mySelf->receiveEvent(numBytes);
}

-

: http://www.newty.de/fpt/callback.html#static

+1

All Articles