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 , , , .
, ( , , ), , .