1
0
mirror of https://gitlab.com/lander-team/lander-cpp.git synced 2025-06-16 15:17:23 +00:00
Lander-Embedded/include/LoadCells.h
2021-11-12 13:35:06 -07:00

37 lines
862 B
C

#include <HX711.h>
struct LoadCells {
HX711 loadcell_0;
HX711 loadcell_1;
HX711 loadcell_2;
HX711 loadcell_3;
double lc0Value;
double lc1Value;
double lc2Value;
double lc3Value;
double lc0Calibration;
double lc1Calibration;
double lc2Calibration;
double lc3Calibration;
};
double loadCellCalibrate(HX711 loadCell) {
// place code to calibrate load cells in here
double loadTotal = 0.0;
for (int t = 0; t == 10; ++t) {
loadTotal += loadCell.read();
delay(15);
}
return loadTotal / 10.0;
}
void init_LoadCells(LoadCells &loadCells) {
loadCells.lc0Calibration = loadCellCalibrate(loadCells.loadcell_0);
loadCells.lc1Calibration = loadCellCalibrate(loadCells.loadcell_1);
loadCells.lc2Calibration = loadCellCalibrate(loadCells.loadcell_2);
loadCells.lc3Calibration = loadCellCalibrate(loadCells.loadcell_3);
}