I imagine there is a simple answer to this, but struggling to find it...
I am using the IRrecv library, and a couple of custom classes to handle different inputs under different circumstances. (ie there would be a Foo1, a Foo2, etc depending on what state the program is in)
I'm trying to pass the an IRrecv object into those classes to that they can read things directly, but can't seem to pass it because it wants the constructor of what pin it is going to read from.
Main
#include <IRremote.h>
#include "Foo1.cpp"
const int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
irrecv.enableIRIn();
}
void loop() {
Foo1 foo(irrecv, results);
while (true) {
foo.handleIR();
}
}
Foo1.cpp
#include <IRremote.h>
class Foo1 {
IRrecv myIR;
decode_results myResults;
public:
Foo1(IRrecv passedIr, decode_results passedResults) {
myIR = passedIr;
myResults = passedResults;
}
void handleIR() {
if (myIR.decode(&myResults)) {
if (myResults.decode_type == NEC && myResults.value != 0xFFFFFFFF) {
//do something with myResults.value
}
}
myIR.resume();
}
};
Foo1.cpp:8: error: no matching function for call to 'IRrecv::IRrecv()'
Foo1(IRrecv passedIr, decode_results passedResults) {
IRrecv(int recvpin);
class IRrecv
no matching function for call to 'IRrecv::IRrecv()'