1
0
mirror of https://gitlab.com/lander-team/lander-cpp.git synced 2025-06-16 07:06:51 +00:00
Lander-Embedded/include/LoadCells.h

39 lines
830 B
C

#include <HX711.h>
#pragma once
struct LoadCells {
HX711 lc0;
HX711 lc1;
HX711 lc2;
HX711 lc3;
// Current calibrated value
double lc0Val;
double lc1Val;
double lc2Val;
double lc3Val;
// Calibration offset
double lc0Cal;
double lc1Cal;
double lc2Cal;
double lc3Cal;
};
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 update_LoadCells(LoadCells &loadCells) {
loadCells.lc0Val = loadCells.lc0.read() - loadCells.lc0Cal;
loadCells.lc1Val = loadCells.lc1.read() - loadCells.lc1Cal;
loadCells.lc2Val = loadCells.lc2.read() - loadCells.lc2Cal;
loadCells.lc3Val = loadCells.lc3.read() - loadCells.lc3Cal;
}