enhance calibration code
This commit is contained in:
parent
9830316e0d
commit
2a1e647fc2
|
|
@ -52,6 +52,7 @@ cCommandStream::CommandFn cmdCalibrateScaleA;
|
|||
cCommandStream::CommandFn cmdCalibrateScaleB;
|
||||
cCommandStream::CommandFn cmdSetDebugLevel;
|
||||
cCommandStream::CommandFn cmdGetDebugLevel;
|
||||
cCommandStream::CommandFn cmdStopIterations;
|
||||
|
||||
// the individual commmands are put in this table
|
||||
static const cCommandStream::cEntry sMyExtraCommmands[] =
|
||||
|
|
@ -65,6 +66,7 @@ static const cCommandStream::cEntry sMyExtraCommmands[] =
|
|||
{ "calibrate_scale_b", cmdCalibrateScaleB },
|
||||
{ "set_debug_level", cmdSetDebugLevel },
|
||||
{ "get_debug_level", cmdGetDebugLevel },
|
||||
{ "stop_iterations", cmdStopIterations },
|
||||
// other commands go here....
|
||||
};
|
||||
|
||||
|
|
@ -95,6 +97,7 @@ SENSOR_data last_sensor_reading;
|
|||
long iteration = 0; // what iteration number do we have, starts with 0
|
||||
long package_counter = 0; // sent package counter
|
||||
bool send_in_progress = false;
|
||||
bool stop_iterations = false;
|
||||
bool next_package_is_init_package = true;
|
||||
|
||||
// generic timer
|
||||
|
|
@ -706,9 +709,9 @@ void StartNewIteration() {
|
|||
if (config_data.debug_level > 0) {
|
||||
gCatena.SafePrintf("%010d - startSendingUplink(), my_position: %d, iteration: %d, package_counter: %d\n", millis(), my_position, iteration, package_counter);
|
||||
}
|
||||
// the first 5 packets are "Init-Packets" or each INIT_PACKAGE_INTERVAL ...
|
||||
// the first 12 packets are "Init-Packets" or each INIT_PACKAGE_INTERVAL ...
|
||||
startSendingUplink(next_package_is_init_package);
|
||||
next_package_is_init_package = ((iteration < 5) || ((package_counter % INIT_PACKAGE_INTERVAL) == 0));
|
||||
next_package_is_init_package = ((iteration < 12) || ((package_counter % INIT_PACKAGE_INTERVAL) == 0));
|
||||
|
||||
if (config_data.debug_level > 1) {
|
||||
gLed.Set(LedPattern::TwoShort);
|
||||
|
|
@ -743,8 +746,8 @@ void StartNewIteration() {
|
|||
sleep_time_sec = 5;
|
||||
}
|
||||
|
||||
// for the first 5 iterations, we set the sleep time to 10 seconds only...
|
||||
if (iteration <= 5) {
|
||||
// for the first 12 iterations, we set the sleep time to 10 seconds only...
|
||||
if (iteration <= 12) {
|
||||
sleep_time_sec = 10;
|
||||
}
|
||||
|
||||
|
|
@ -816,6 +819,7 @@ void startSendingUplink(bool firstTime)
|
|||
gLoRaWAN.SendBuffer((uint8_t*)&lora_data, sizeof(LORA_data), sendBufferDoneCb, NULL, fConfirmed, kUplinkPort);
|
||||
package_counter++;
|
||||
}
|
||||
|
||||
ClearLoraData();
|
||||
}
|
||||
|
||||
|
|
@ -879,6 +883,8 @@ static void settleDoneCb(
|
|||
gCatena.SafePrintf("LMIC.dn2Dr: %i\n", LMIC.dn2Dr);
|
||||
gCatena.SafePrintf("LMIC.dn2Freq: %i\n", LMIC.dn2Freq);
|
||||
gCatena.SafePrintf("LMIC.rx1DrOffset: %i\n", LMIC.rx1DrOffset);
|
||||
gCatena.SafePrintf("LMIC.adrAckReq: %i\n", LMIC.adrAckReq);
|
||||
gCatena.SafePrintf("LMIC.adrEnabled: %i\n", LMIC.adrEnabled);
|
||||
// Terry ^^
|
||||
}
|
||||
|
||||
|
|
@ -915,7 +921,9 @@ static void startNewIterationCb(osjob_t* pJob)
|
|||
gCatena.SafePrintf("%010d - startNewIterationCb\n", millis());
|
||||
}
|
||||
|
||||
StartNewIteration();
|
||||
if (! stop_iterations) {
|
||||
StartNewIteration();
|
||||
}
|
||||
}
|
||||
|
||||
static void receiveMessage(void *pContext, uint8_t port, const uint8_t *pMessage, size_t nMessage)
|
||||
|
|
@ -977,18 +985,6 @@ static void receiveMessage(void *pContext, uint8_t port, const uint8_t *pMessage
|
|||
|
||||
}
|
||||
|
||||
if (port == 1 && nMessage == 1) {
|
||||
if (pMessage[0] == 0) {
|
||||
if (config_data.debug_level > 0) {
|
||||
gCatena.SafePrintf("reset both scales to zero\n");
|
||||
}
|
||||
ReadSensors(temp_sensor_data);
|
||||
config_data.cal_w1_0 = temp_sensor_data.weight1;
|
||||
config_data.cal_w2_0 = temp_sensor_data.weight2;
|
||||
gCatena.getFram()->saveField(cFramStorage::kBme680Cal, (const uint8_t *)&config_data, sizeof(config_data));
|
||||
}
|
||||
}
|
||||
|
||||
if (port == 1 && nMessage == 17) {
|
||||
cal_w1_0 = 0;
|
||||
cal_w1_0 += (long)pMessage[1] << 24;
|
||||
|
|
@ -1173,3 +1169,9 @@ cCommandStream::CommandStatus cmdGetDebugLevel(cCommandStream *pThis, void *pCon
|
|||
|
||||
return cCommandStream::CommandStatus::kSuccess;
|
||||
}
|
||||
|
||||
cCommandStream::CommandStatus cmdStopIterations(cCommandStream *pThis, void *pContext, int argc, char **argv)
|
||||
{
|
||||
stop_iterations = true;
|
||||
return cCommandStream::CommandStatus::kSuccess;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ enum {
|
|||
|
|
||||
\****************************************************************************/
|
||||
|
||||
static const int32_t fwVersion = 20191214;
|
||||
static const int32_t fwVersion = 20191220;
|
||||
|
||||
// wait between samples
|
||||
// 3 sec is a good delay so that load cell did not warm up
|
||||
|
|
|
|||
Loading…
Reference in New Issue