parse launch-site correctly even if frequency has more or less digits

This commit is contained in:
Hansi, dl9rdz 2019-05-22 22:35:36 +02:00
parent e84a5872b5
commit 49b3d771d1
1 changed files with 8 additions and 9 deletions

View File

@ -117,7 +117,7 @@ void setupChannelList() {
return; return;
} }
int i = 0; int i = 0;
char launchsite[17]; char launchsite[17]=" ";
sonde.clearSonde(); sonde.clearSonde();
Serial.println("Reading channel config:"); Serial.println("Reading channel config:");
while (file.available()) { while (file.available()) {
@ -142,16 +142,13 @@ void setupChannelList() {
else continue; else continue;
int active = space[3] == '+' ? 1 : 0; int active = space[3] == '+' ? 1 : 0;
if (space[4] == ' ') { if (space[4] == ' ') {
sitename = line.substring(12) + " "; // Don't change start of substr(12) !!!! memset(launchsite, ' ', 16);
int str_len = sitename.length() + 1; int str_len = strlen(space+5);
sitename.toCharArray(launchsite, 17); strncpy(launchsite, space+5, str_len>16?16:str_len);
if (sonde.config.debug == 1) { if (sonde.config.debug == 1) {
Serial.printf("Add %f - sondetype: %d (on/off: %d) - site #%d - name: %s\n ", freq, type, active, i, launchsite); Serial.printf("Add %f - sondetype: %d (on/off: %d) - site #%d - name: %s\n ", freq, type, active, i, launchsite);
//Serial.println(sitename);
} }
} }
sonde.addSonde(freq, type, active, launchsite); sonde.addSonde(freq, type, active, launchsite);
i++; i++;
} }
@ -950,13 +947,15 @@ void setup()
} }
void enterMode(int mode) { void enterMode(int mode) {
Serial.printf("enterMode(%d)\n", mode);
mainState = (MainState)mode; mainState = (MainState)mode;
if (mainState == ST_SPECTRUM) { if (mainState == ST_SPECTRUM) {
sonde.clearDisplay(); sonde.clearDisplay();
u8x8->setFont(u8x8_font_chroma48medium8_r); u8x8->setFont(u8x8_font_chroma48medium8_r);
specTimer = millis(); specTimer = millis();
} else {
sonde.clearDisplay();
} }
sonde.clearDisplay();
} }
void loopDecoder() { void loopDecoder() {
@ -1044,7 +1043,7 @@ void loopSpectrum() {
return; return;
case KP_DOUBLE: case KP_DOUBLE:
enterMode(ST_SCANNER); enterMode(ST_SCANNER);
break; return;
default: break; default: break;
} }