Hi,
I researched this issue for a while now, but I can't seem to get any of the found solutions to work. I have an Arduino sketch that runs an underwater thruster test jig, controlling an ESC, and measuring the force using a load cell. I am using two standard libraries for this - Servo.h and HX711_ADC.h. In my sketch, I created an object for each of these library classes, and it worked fine. However, when I wrapped them inside of a custom class, I get compilation errors. The first one is:
C:\Users\Administrator\AppData\Local\Temp\.arduinoIDE-unsaved2023217-18000-exa87x.ufjn\sketch_mar17a\sketch_mar17a.ino: In constructor 'testInstance::testInstance()':
C:\Users\Administrator\AppData\Local\Temp\.arduinoIDE-unsaved2023217-18000-exa87x.ufjn\sketch_mar17a\sketch_mar17a.ino:15:5: error: no matching function for call to 'HX711_ADC::HX711_ADC()'
Here is a trimmed code that shows my setup:
#include <Servo.h>
#include <HX711_ADC.h>
class testInstance
{
private:
const int HX711_DOUT = 4; //mcu > HX711 dout pin
const int HX711_SCK = 5; //mcu > HX711 sck pin
Servo ESC;
HX711_ADC LoadCell;
public:
bool invertThrottle = false;
testInstance()
{
LoadCell = HX711_ADC(HX711_DOUT, HX711_SCK);
ESC = Servo();
}
void runTest()
{
//...
}
};
void setup()
{
Serial.begin(9600);
//forward
testInstance forwardTest;
forwardTest.runTest();
//reverse
testInstance reverseTest;
reverseTest.invertThrottle = true;
forwardTest.runTest();
}
I also get more errors, all referring to these objects I created. The full error list is this:
C:\Users\Administrator\AppData\Local\Temp\.arduinoIDE-unsaved2023217-18000-exa87x.ufjn\sketch_mar17a\sketch_mar17a.ino: In constructor 'testInstance::testInstance()':
C:\Users\Administrator\AppData\Local\Temp\.arduinoIDE-unsaved2023217-18000-exa87x.ufjn\sketch_mar17a\sketch_mar17a.ino:18:5: error: no matching function for call to 'HX711_ADC::HX711_ADC()'
{
^
In file included from C:\Users\Administrator\AppData\Local\Temp\.arduinoIDE-unsaved2023217-18000-exa87x.ufjn\sketch_mar17a\sketch_mar17a.ino:2:0:
C:\Users\Administrator\Documents\Arduino\libraries\HX711_ADC-1.2.12\src/HX711_ADC.h:53:3: note: candidate: HX711_ADC::HX711_ADC(uint8_t, uint8_t)
HX711_ADC(uint8_t dout, uint8_t sck); //constructor
^~~~~~~~~
C:\Users\Administrator\Documents\Arduino\libraries\HX711_ADC-1.2.12\src/HX711_ADC.h:53:3: note: candidate expects 2 arguments, 0 provided
C:\Users\Administrator\Documents\Arduino\libraries\HX711_ADC-1.2.12\src/HX711_ADC.h:49:7: note: candidate: constexpr HX711_ADC::HX711_ADC(const HX711_ADC&)
class HX711_ADC
^~~~~~~~~
C:\Users\Administrator\Documents\Arduino\libraries\HX711_ADC-1.2.12\src/HX711_ADC.h:49:7: note: candidate expects 1 argument, 0 provided
C:\Users\Administrator\Documents\Arduino\libraries\HX711_ADC-1.2.12\src/HX711_ADC.h:49:7: note: candidate: constexpr HX711_ADC::HX711_ADC(HX711_ADC&&)
C:\Users\Administrator\Documents\Arduino\libraries\HX711_ADC-1.2.12\src/HX711_ADC.h:49:7: note: candidate expects 1 argument, 0 provided
C:\Users\Administrator\AppData\Local\Temp\.arduinoIDE-unsaved2023217-18000-exa87x.ufjn\sketch_mar17a\sketch_mar17a.ino:19:49: error: use of deleted function 'HX711_ADC& HX711_ADC::operator=(HX711_ADC&&)'
LoadCell = HX711_ADC(HX711_DOUT, HX711_SCK);
^
In file included from C:\Users\Administrator\AppData\Local\Temp\.arduinoIDE-unsaved2023217-18000-exa87x.ufjn\sketch_mar17a\sketch_mar17a.ino:2:0:
C:\Users\Administrator\Documents\Arduino\libraries\HX711_ADC-1.2.12\src/HX711_ADC.h:49:7: note: 'HX711_ADC& HX711_ADC::operator=(HX711_ADC&&)' is implicitly deleted because the default definition would be ill-formed:
class HX711_ADC
^~~~~~~~~
C:\Users\Administrator\Documents\Arduino\libraries\HX711_ADC-1.2.12\src/HX711_ADC.h:49:7: error: non-static const member 'const uint8_t HX711_ADC::divBitCompiled', can't use default assignment operator
exit status 1
Compilation error: no matching function for call to 'HX711_ADC::HX711_ADC()'
What am I doing wrong here?