update version, save calibration values

This commit is contained in:
Joerg Lehmann 2019-10-03 20:41:05 +02:00
parent 58de0909b3
commit df2178e6e0
1 changed files with 15 additions and 3 deletions

View File

@ -129,7 +129,7 @@ sMyExtraCommands_top(
| |
\****************************************************************************/ \****************************************************************************/
static const int32_t fwVersion = 20190926; static const int32_t fwVersion = 20191003;
static const byte MAX_VALUES_TO_SEND = 8; static const byte MAX_VALUES_TO_SEND = 8;
static const uint8_t LORA_DATA_VERSION = 1; static const uint8_t LORA_DATA_VERSION = 1;
static const uint8_t LORA_DATA_VERSION_FIRST_PACKAGE = 129; static const uint8_t LORA_DATA_VERSION_FIRST_PACKAGE = 129;
@ -936,14 +936,26 @@ static void receiveMessage(void *pContext, uint8_t port, const uint8_t *pMessage
if (port == 1 && nMessage == 1) { if (port == 1 && nMessage == 1) {
if (pMessage[0] == 0) { if (pMessage[0] == 0) {
gCatena.SafePrintf("reset both scales to zero\n"); if (config_data.debug_level > 0) {
gCatena.SafePrintf("reset both scales to zero\n");
}
ReadSensors(false, true);
config_data.cal_w1_0 = last_sensor_reading.weight1;
config_data.cal_w2_0 = last_sensor_reading.weight2;
gCatena.getFram()->saveField(cFramStorage::kBme680Cal, (const uint8_t *)&config_data, sizeof(config_data));
} }
} }
if (port == 1 && nMessage == 9) { if (port == 1 && nMessage == 9) {
if (pMessage[0] == 1) { if (pMessage[0] == 1) {
memcpy(bytearray.buf, pMessage, 9); memcpy(bytearray.buf, pMessage, 9);
gCatena.SafePrintf("tare scales, A: %d, B: %d\n", bytearray.value.gram_A, bytearray.value.gram_A); if (config_data.debug_level > 0) {
gCatena.SafePrintf("tare scales, A: %d, B: %d\n", bytearray.value.gram_A, bytearray.value.gram_B);
}
ReadSensors(false, true);
config_data.cal_w1_factor = (((float)last_sensor_reading.weight1 - config_data.cal_w1_0) / bytearray.value.gram_A);
config_data.cal_w2_factor = (((float)last_sensor_reading.weight2 - config_data.cal_w2_0) / bytearray.value.gram_B);
gCatena.getFram()->saveField(cFramStorage::kBme680Cal, (const uint8_t *)&config_data, sizeof(config_data));
} }
} }