I'm designing an Arduino project that makes use of multiple sensors so I need to create classes to abstract each sensor functionality in order to make it scalable and easy to maintain.
I should say that I'm not very experienced in C++ but I'm kind of fluent in Java and some patterns and techniques that can be applied to a wide variety of languages.
So, each sensor extends an abstract class functionality (as u'd probably guess, named Sensor
) and defines how a void setup()
and a T get()
methods should work for each implementation.
As a result each implementation would hold an instance to the basic class of its sensor library in order to make readings whenever the T get()
method is called but I can't seem to find a feasible solution for this idea since it seems I can't understand C++ constructors (even after a good amount of time invested in researching across Google and other StackOverflow questions) because I can't do:
#include <HX711_ADC.h>
HX711_ADC loadCell;
uint8_t dout = 4;
uint8_t sck = 5;
void setup() {
loadCell = HX711_ADC( dout, sck ); // Exception
loadCell( dout, sck ); // Exception
}
dout
and sck
are declared uint8_t as declared types for it's constructor as seen in HX711_ADC.h
Any idea would be greatly appreciated.