Hello I am new to platformio and arduino and I have no clue how to fix this error.
.pio\build\teensy41\src\main.cpp.o: In function `EncoderTool::Encoder::Encoder()':
main.cpp:(.text._ZN11EncoderTool7EncoderC2Ev+0x0): multiple definition of `EncoderTool::Encoder::Encoder()'
.pio\build\teensy41\src\Encoders.cpp.o:Encoders.cpp:(.text._ZN11EncoderTool7EncoderC2Ev+0x0): first defined here
c:/users/e/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
.pio\build\teensy41\src\main.cpp.o: In function `EncoderTool::Encoder::Encoder()':
main.cpp:(.text._ZN11EncoderTool7EncoderC2Ev+0x0): multiple definition of `EncoderTool::Encoder::Encoder()'
.pio\build\teensy41\src\Encoders.cpp.o:Encoders.cpp:(.text._ZN11EncoderTool7EncoderC2Ev+0x0): first defined here
This is the Encoders.cpp code:
#include "Encoders.h"
Encoder enc1;
Encoder enc2;
Encoder enc3;
Encoder enc4;
Encoder enc5;
void Encoders::begin()
{
enc1.begin(28, 27, CountMode::half);
enc2.begin(25, 24, CountMode::half);
enc3.begin(11, 10, CountMode::half);
enc4.begin(8, 7, CountMode::half);
enc5.begin(5, 4, CountMode::half);
}
void Encoders::value()
{
if (enc1.valueChanged() || enc2.valueChanged() || enc3.valueChanged() || enc4.valueChanged() || enc5.valueChanged())
{
Serial.print("Enc1 = ");
Serial.print(enc1.getValue());
Serial.print(", Enc2 = ");
Serial.print(enc2.getValue());
Serial.print(", Enc3 = ");
Serial.print(enc3.getValue());
Serial.print(", Enc4 = ");
Serial.print(enc4.getValue());
Serial.print(", Enc5 = ");
Serial.print(enc5.getValue());
Serial.println();
}
}
And this is the Encoders.h code:
#ifndef ENCODERS_H
#define ENCODERS_H
#include "EncoderTool.h"
#include "Arduino.h"
using namespace EncoderTool;
extern Encoder enc1;
extern Encoder enc2;
extern Encoder enc3;
extern Encoder enc4;
extern Encoder enc5;
class Encoders
{
public:
void value();
void begin();
};
#endif
And this is the main.cpp code:
#include "Arduino.h"
#include "SPI.h"
#include "Display.h"
Display display;
#include "Encoders.h"
Encoders encoders;
#include "Sd.h"
SD sD;
void setup()
{
display.begin();
sD.begin();
encoders.begin();
}
void loop()
{
encoders.value();
}