#include "HX711.h" #include "ConfigHardware.h" #include template class Scale { public: bool measure(uint16_t & measurementOut) { if (hx711_.is_ready()) { long value = hx711_.read_average(CONFIG_MEASUREMENT_AVG_COUNT) - offset_; if(value < 0) measurementOut = (int16_t)(-value / DIVIDER); else measurementOut = 0; return true; } else return false; } void begin(uint32_t pinDOUT, uint32_t pinSCK) { hx711_.begin(pinDOUT, pinSCK); }; void tare(uint32_t numMeasurementsToAverage=50) { offset_ = hx711_.read_average(numMeasurementsToAverage); } private: HX711 hx711_; long offset_ = 0; };