only one HX711, rename load cell names
This commit is contained in:
parent
bac960c897
commit
c9875123f4
|
|
@ -94,12 +94,12 @@ void setTxCycleTime(unsigned txCycle, unsigned txCount);
|
|||
cCommandStream::CommandFn cmdHello;
|
||||
cCommandStream::CommandFn cmdGetCalibrationSettings;
|
||||
cCommandStream::CommandFn cmdGetSensorReadings;
|
||||
cCommandStream::CommandFn cmdGetScale1;
|
||||
cCommandStream::CommandFn cmdGetScale2;
|
||||
cCommandStream::CommandFn cmdCalibrateZeroScale1;
|
||||
cCommandStream::CommandFn cmdCalibrateZeroScale2;
|
||||
cCommandStream::CommandFn cmdCalibrateScale1;
|
||||
cCommandStream::CommandFn cmdCalibrateScale2;
|
||||
cCommandStream::CommandFn cmdGetScaleA;
|
||||
cCommandStream::CommandFn cmdGetScaleB;
|
||||
cCommandStream::CommandFn cmdCalibrateZeroScaleA;
|
||||
cCommandStream::CommandFn cmdCalibrateZeroScaleB;
|
||||
cCommandStream::CommandFn cmdCalibrateScaleA;
|
||||
cCommandStream::CommandFn cmdCalibrateScaleB;
|
||||
|
||||
// the individual commmands are put in this table
|
||||
static const cCommandStream::cEntry sMyExtraCommmands[] =
|
||||
|
|
@ -107,10 +107,10 @@ static const cCommandStream::cEntry sMyExtraCommmands[] =
|
|||
{ "hello", cmdHello },
|
||||
{ "get_calibration_settings", cmdGetCalibrationSettings },
|
||||
{ "get_sensor_readings", cmdGetSensorReadings },
|
||||
{ "calibrate_zero_scale1", cmdCalibrateZeroScale1 },
|
||||
{ "calibrate_zero_scale2", cmdCalibrateZeroScale2 },
|
||||
{ "calibrate_scale1", cmdCalibrateScale1 },
|
||||
{ "calibrate_scale2", cmdCalibrateScale2 },
|
||||
{ "calibrate_zero_scale_a", cmdCalibrateZeroScaleA },
|
||||
{ "calibrate_zero_scale_b", cmdCalibrateZeroScaleB },
|
||||
{ "calibrate_scale_a", cmdCalibrateScaleA },
|
||||
{ "calibrate_scale_b", cmdCalibrateScaleB },
|
||||
// other commands go here....
|
||||
};
|
||||
|
||||
|
|
@ -225,8 +225,7 @@ Catena_Mx25v8035f gFlash;
|
|||
bool fFlash;
|
||||
|
||||
// Scales
|
||||
HX711 LoadCell_1;
|
||||
HX711 LoadCell_2;
|
||||
HX711 LoadCell;
|
||||
|
||||
// USB power
|
||||
bool fUsbPower;
|
||||
|
|
@ -395,23 +394,14 @@ void setup_scales(void)
|
|||
#ifdef DEBUG
|
||||
gCatena.SafePrintf("Setup Scale 1...\n");
|
||||
#endif
|
||||
LoadCell_1.begin(A1, A0);
|
||||
LoadCell.begin(A1, A0);
|
||||
|
||||
if (!(LoadCell_1.wait_ready_timeout(1000))) {
|
||||
gCatena.SafePrintf("Scale 1 not ready.\n");
|
||||
if (!(LoadCell.wait_ready_timeout(1000))) {
|
||||
gCatena.SafePrintf("Scale not ready.\n");
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
gCatena.SafePrintf("Setup Scale 2...\n");
|
||||
#endif
|
||||
LoadCell_2.begin(D12, A2);
|
||||
|
||||
if (!(LoadCell_2.wait_ready_timeout(1000))) {
|
||||
gCatena.SafePrintf("Scale 2 not ready.\n");
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
gCatena.SafePrintf("Setup Scales is complete\n");
|
||||
gCatena.SafePrintf("Setup Scale is complete\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -635,26 +625,19 @@ void ReadSensors(bool firstTime, bool readOnly)
|
|||
setup_scales();
|
||||
|
||||
// Read Scales
|
||||
if (LoadCell_1.is_ready()) {
|
||||
if (LoadCell.is_ready()) {
|
||||
#ifdef DEBUG
|
||||
Serial.println("HX711 LoadCell_1 is ready.");
|
||||
Serial.println("HX711 LoadCell is ready.");
|
||||
#endif
|
||||
long w1 = LoadCell_1.read_average(5);
|
||||
LoadCell.set_gain(128);
|
||||
long w1 = LoadCell.read_average(5);
|
||||
weight1_current = (int32_t)w1;
|
||||
#ifdef DEBUG
|
||||
gCatena.SafePrintf("Load_cell 1 output val: %ld\n", w1);
|
||||
gCatena.SafePrintf("Load_cell 1 weight1_current: %ld\n", weight1_current);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
Serial.println("HX711 LoadCell_1 not ready.");
|
||||
}
|
||||
|
||||
if (LoadCell_2.is_ready()) {
|
||||
#ifdef DEBUG
|
||||
Serial.println("HX711 LoadCell_2 is ready.");
|
||||
#endif
|
||||
long w2 = LoadCell_2.read_average(5);
|
||||
LoadCell.set_gain(32);
|
||||
long w2 = LoadCell.read_average(5);
|
||||
weight2_current = (int32_t)w2;
|
||||
#ifdef DEBUG
|
||||
gCatena.SafePrintf("Load_cell 2 output val: %ld\n", w2);
|
||||
|
|
@ -662,7 +645,7 @@ void ReadSensors(bool firstTime, bool readOnly)
|
|||
#endif
|
||||
}
|
||||
else {
|
||||
Serial.println("HX711 LoadCell_2 not ready.");
|
||||
Serial.println("HX711 LoadCell not ready.");
|
||||
}
|
||||
|
||||
// Disable Power
|
||||
|
|
@ -955,29 +938,29 @@ cCommandStream::CommandStatus cmdGetScale2(cCommandStream *pThis, void *pContext
|
|||
return cCommandStream::CommandStatus::kSuccess;
|
||||
}
|
||||
|
||||
cCommandStream::CommandStatus cmdCalibrateZeroScale1(cCommandStream *pThis, void *pContext, int argc, char **argv)
|
||||
cCommandStream::CommandStatus cmdCalibrateZeroScaleA(cCommandStream *pThis, void *pContext, int argc, char **argv)
|
||||
{
|
||||
ReadSensors(false, true);
|
||||
config_data.cal_w1_0 = last_sensor_reading.weight1;
|
||||
gCatena.getFram()->saveField(cFramStorage::kBme680Cal, (const uint8_t *)&config_data, sizeof(config_data));
|
||||
|
||||
pThis->printf("{ \"msg\": \"calibrate_zero_scale1 was successful\" }\n");
|
||||
pThis->printf("{ \"msg\": \"calibrate_zero_scale_a was successful\" }\n");
|
||||
|
||||
return cCommandStream::CommandStatus::kSuccess;
|
||||
}
|
||||
|
||||
cCommandStream::CommandStatus cmdCalibrateZeroScale2(cCommandStream *pThis, void *pContext, int argc, char **argv)
|
||||
cCommandStream::CommandStatus cmdCalibrateZeroScaleB(cCommandStream *pThis, void *pContext, int argc, char **argv)
|
||||
{
|
||||
ReadSensors(false, true);
|
||||
config_data.cal_w2_0 = last_sensor_reading.weight2;
|
||||
gCatena.getFram()->saveField(cFramStorage::kBme680Cal, (const uint8_t *)&config_data, sizeof(config_data));
|
||||
|
||||
pThis->printf("{ \"msg\": \"calibrate_zero_scale2 was successful\" }\n");
|
||||
pThis->printf("{ \"msg\": \"calibrate_zero_scale_b was successful\" }\n");
|
||||
|
||||
return cCommandStream::CommandStatus::kSuccess;
|
||||
}
|
||||
|
||||
cCommandStream::CommandStatus cmdCalibrateScale1(cCommandStream *pThis, void *pContext, int argc, char **argv)
|
||||
cCommandStream::CommandStatus cmdCalibrateScaleA(cCommandStream *pThis, void *pContext, int argc, char **argv)
|
||||
{
|
||||
ReadSensors(false, true);
|
||||
|
||||
|
|
@ -992,12 +975,12 @@ cCommandStream::CommandStatus cmdCalibrateScale1(cCommandStream *pThis, void *pC
|
|||
gCatena.SafePrintf("w1_gramm (float): %d\n", (int)w1_gramm.toFloat());
|
||||
gCatena.SafePrintf("config_data.cal_w1_factor: %d\n", (int)config_data.cal_w1_factor);
|
||||
|
||||
pThis->printf("{ \"msg\": \"calibrate_scale1 was successful\" }\n");
|
||||
pThis->printf("{ \"msg\": \"calibrate_scale_a was successful\" }\n");
|
||||
|
||||
return cCommandStream::CommandStatus::kSuccess;
|
||||
}
|
||||
|
||||
cCommandStream::CommandStatus cmdCalibrateScale2(cCommandStream *pThis, void *pContext, int argc, char **argv)
|
||||
cCommandStream::CommandStatus cmdCalibrateScaleB(cCommandStream *pThis, void *pContext, int argc, char **argv)
|
||||
{
|
||||
ReadSensors(false, true);
|
||||
|
||||
|
|
@ -1006,7 +989,7 @@ cCommandStream::CommandStatus cmdCalibrateScale2(cCommandStream *pThis, void *pC
|
|||
|
||||
gCatena.getFram()->saveField(cFramStorage::kBme680Cal, (const uint8_t *)&config_data, sizeof(config_data));
|
||||
|
||||
pThis->printf("{ \"msg\": \"calibrate_scale2 was successful\" }\n");
|
||||
pThis->printf("{ \"msg\": \"calibrate_scale_b was successful\" }\n");
|
||||
|
||||
return cCommandStream::CommandStatus::kSuccess;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue