Howdy,
I'm working with PinChangeInt in my custom library, and I am curious how to use the attach interrupt function with a private function in my class? Here is my code:
.h:
#ifndef RXTX_H
#define RXTX_H
#include "Arduino.h"
class RxTx
{
public:
RxTx(byte ch1, byte ch2, byte ch3, byte ch4, byte bat);
...
private:
void calcThrottle();
void calcAileron();
void calcElevator();
void calcRudder();
};
#endif
.cpp:
#include <Arduino.h>
#include <RxTx.h>
#include "/Applications/Arduino.app/Contents/Resources/Java/libraries/PinChangeInt/PinChangeInt.h"
...
byte throttle;
byte aileron;
byte elevator;
byte rudder;
...
RxTx::RxTx(byte ch1, byte ch2, byte ch3, byte ch4, byte bat)
{
init();
pinMode(ch1, INPUT);
pinMode(ch2, INPUT);
pinMode(ch3, INPUT);
pinMode(ch4, INPUT);
pinMode(bat, OUTPUT);
digitalWrite(bat, LOW);
throttle = ch3;
aileron = ch1;
elevator = ch2;
rudder = ch4;
//This is where I'm attaching the interrupts
PCintPort::attachInterrupt(throttle, calcThrottle, CHANGE); // This doesn't work.
PCintPort::attachInterrupt(aileron, calcAileron, CHANGE); // It brings up an error that says
PCintPort::attachInterrupt(elevator, calcElevator, CHANGE);// "No matching function for call to 'PCintPort::attachInterrupt
PCintPort::attachInterrupt(rudder, calcRudder, CHANGE); // (byte&, <unresolved overloaded runction type>, int)'"
}
...
//These are the private functions I am trying to attach
void RxTx::calcThrottle()...
void RxTx::calcAileron()...
void RxTx::calcElevator()...
void RxTx::calcRudder()...
As always, help is greatly appreciated!
