Hi everyone,
my question is rather c++-oriented since I have trouble with a self-made library...
Abstract of my project : I wrote a sketch for controlling a 8x8 led matrix, then transformed it in a library.
In this libray, a "screen refreshment" method uses the MsTimer2 library to induce an interruption every 40 ms, calling a "show" function to update the matrix display
#include "Led.h"
#include <inttypes.h>
#include "Arduino.h"
#include <MsTimer2.h>
//constructeur
Led::Led()
{
//initialisation
void Led::begin()
MsTimer2::set(40, show); //setting of the timer to invoke the "show" method ( see below ) when an interrupt occurs ( every 40 ms )
MsTimer2::start();
}
void Led::show() { //the "refresh screen" method.....
MsTimer2::stop(); /unables the timer
for(int row = 0; row < 8; row++)
{
digitalWrite(rowPins[row], HIGH);
for(int column = 0; column < 8; column++)
{
bool pixel = bitRead(courant[row],7-column); //"courant" is the array to be displayed on the matrix
if(pixel == 1)
{
digitalWrite(columnPins[column], LOW); //
}
delayMicroseconds(300);
digitalWrite(columnPins[column], HIGH);
}
digitalWrite(rowPins[row], LOW);
}
MsTimer2::start();
}
and here is my trouble : the timer delay, and the function to call when an interrupt occurs, are set in my library; when I try to compile, I receive that error :
libraries/Led/Led.cpp:72: error: argument of type ‘void (Led::)()’ does not match ‘void (*)()’
The "set" method of the MsTimer2 library waits for a function pointer as second argument...I guess here is the trouble, but I'm unable to find the right formulation...In the example supplied with the MsTimer2 library, the argument is the name of the function only...But there's still a trick....Maybe the problem is my library calls another library ??
Anyaway, if anyone more comfortable with pointers can find the answer, I'd be very grateful !
Oxirane