reset sonde info if configuration is changed

pull/153/head^2
Hansi, dl9rdz 2021-09-05 17:06:01 +02:00
rodzic 7e5b04e56e
commit a3ab8b4371
1 zmienionych plików z 9 dodań i 0 usunięć

Wyświetl plik

@ -122,6 +122,11 @@ void Sonde::defaultConfig() {
#define BM8563_ADDRESS 0x51
Wire.beginTransmission(BM8563_ADDRESS);
byte err = Wire.endTransmission();
if(err) { // try again
delay(400);
Wire.beginTransmission(BM8563_ADDRESS);
err = Wire.endTransmission();
}
if(err==0) {
Serial.println("M5stack Core2 board detected\n");
config.type = TYPE_M5_CORE2;
@ -447,6 +452,10 @@ void Sonde::addSonde(float frequency, SondeType type, int active, char *launchsi
return;
}
Serial.printf("Adding %f - %d - %d - %s\n", frequency, type, active, launchsite);
// reset all data if type or frequency has changed
if(type != sondeList[nSonde].type || frequency != sondeList[nSonde].frequency) {
memset(sondeList[nSonde], 0, sizeof(SondeInfo));
}
sondeList[nSonde].type = type;
sondeList[nSonde].typestr[0] = 0;
sondeList[nSonde].freq = frequency;