I am attempting to write a library that expands on the functions of the Encoder library that is included with teensyduino. Normally when I pass an object to a library I am writing I dont run into issues, but I seem to have a gap in my understanding. It seems as tho the compilier is expecting an argument for the encoder object, but ive already declared the object in my main code. Do I need to pass the pins as an argument to the library? I dont have to do it that way, thats just how ive always passed objects to a library. Thanks!
Errors:
Code:
#ifndef _MYENCODER_h
#define _MYENCODER_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
#endif
#include "Encoder.h"
class myEncoder{
public:
myEncoder();
void attach(Encoder encX);
private:
Encoder encX;
};
Code:
#include "myEncoder.h"
myEncoder::myEncoder()
{}
void myEncoder::attach(Encoder encX){
this->encX = encX;
}
Errors:
myEncoder.cpp: In constructor myEncoder::myEncoder()
myEncoder.cpp: 8:22: error: no matching function for call to 'Encoder::Encoder()
myEncoder*: myEncoder()
Error compiling project sources
myEncoder.h:15: In file included from
myEncoder.cpp:5: from
Encoder.h:72: note candidate Encoder Encoder(uint8_t, uint8_t)
Encoder(uint8_t pin1, uint8_t pin2) {
Encoder.h:72: note candidate expects 2 arguments, 0 provided
Encoder.h:69: note candidate constexpr Encoder Encoder(const Encoder&)
class Encoder
Encoder.h:69: note candidate expects 1 argument, 0 provided
Encoder.h:69: note candidate constexpr Encoder Encoder(Encoder&&)
Encoder.h:69: note candidate expects 1 argument, 0 provided
Build failed