fix formula

This commit is contained in:
Joerg Lehmann 2020-02-29 12:39:54 +01:00
parent 92c1aaefbe
commit f3e2e0181a
1 changed files with 8 additions and 1 deletions

View File

@ -598,6 +598,8 @@ long my_read_average(byte gain, byte times) {
void ReadSensors(SENSOR_data &sensor_data) {
SENSOR_data res;
int32_t weight_current32;
long w1_0_real;
long w2_0_real;
// vBat
gCatena.poll();
@ -608,6 +610,8 @@ void ReadSensors(SENSOR_data &sensor_data) {
}
// Read Scales
w1_0_real = config_data.cal_w1_0;
w2_0_real = config_data.cal_w2_0;
if (setup_scales()) {
if (config_data.debug_level > 0) {
gCatena.SafePrintf("%010d - HX711 LoadCell is ready.\n", millis());
@ -620,6 +624,7 @@ void ReadSensors(SENSOR_data &sensor_data) {
}
} else {
res.weight1 = 0;
w1_0_real = 0;
if (config_data.debug_level > 0) {
gCatena.SafePrintf("%010d - Load_cell 1 is disabled\n", millis());
}
@ -632,6 +637,7 @@ void ReadSensors(SENSOR_data &sensor_data) {
}
} else {
res.weight2 = 0;
w2_0_real = 0;
if (config_data.debug_level > 0) {
gCatena.SafePrintf("%010d - Load_cell 2 is disabled\n", millis());
}
@ -648,7 +654,8 @@ void ReadSensors(SENSOR_data &sensor_data) {
digitalWrite(D10, LOW);
// Gewicht berechnen
weight_current32 = (int32_t)((((res.weight1 - config_data.cal_w1_0) / config_data.cal_w1_factor) + ((res.weight2 - config_data.cal_w2_0) / config_data.cal_w2_factor)) / 5.0);
weight_current32 = (int32_t)((((res.weight1 - w1_0_real) / config_data.cal_w1_factor) + ((res.weight2 - w2_0_real) / config_data.cal_w2_factor)) / 5.0);
if (weight_current32 < 0) {
weight_current32 = 0;
} else if (weight_current32 > UINT16_MAX) {