|
| 1 | +//Set the baud rates for the radio and data ports |
| 2 | +void menuPorts() |
| 3 | +{ |
| 4 | + while (1) |
| 5 | + { |
| 6 | + Serial.println(); |
| 7 | + Serial.println(F("Menu: Port Menu")); |
| 8 | + |
| 9 | + Serial.print(F("1) Set serial baud rate for Radio Port: ")); |
| 10 | + Serial.print(getSerialRate(COM_PORT_UART2)); |
| 11 | + Serial.println(F(" bps")); |
| 12 | + |
| 13 | + Serial.print(F("2) Set serial baud rate for Data Port: ")); |
| 14 | + Serial.print(getSerialRate(COM_PORT_UART1)); |
| 15 | + Serial.println(F(" bps")); |
| 16 | + |
| 17 | + Serial.println(F("x) Exit")); |
| 18 | + |
| 19 | + byte incoming = getByteChoice(30); //Timeout after x seconds |
| 20 | + |
| 21 | + if (incoming == '1') |
| 22 | + { |
| 23 | + Serial.print(F("Enter baud rate (4800 to 921600) for Radio Port: ")); |
| 24 | + int newBaud = getNumber(menuTimeout); //Timeout after x seconds |
| 25 | + if (newBaud < 4800 || newBaud > 921600) |
| 26 | + { |
| 27 | + Serial.println(F("Error: baud rate out of range")); |
| 28 | + } |
| 29 | + else |
| 30 | + { |
| 31 | + settings.radioPortBaud = newBaud; |
| 32 | + myGPS.setSerialRate(newBaud, COM_PORT_UART2); //Set Radio Port |
| 33 | + } |
| 34 | + } |
| 35 | + else if (incoming == '2') |
| 36 | + { |
| 37 | + Serial.print(F("Enter baud rate (4800 to 921600) for Data Port: ")); |
| 38 | + int newBaud = getNumber(menuTimeout); //Timeout after x seconds |
| 39 | + if (newBaud < 4800 || newBaud > 921600) |
| 40 | + { |
| 41 | + Serial.println(F("Error: baud rate out of range")); |
| 42 | + } |
| 43 | + else |
| 44 | + { |
| 45 | + settings.dataPortBaud = newBaud; |
| 46 | + myGPS.setSerialRate(newBaud, COM_PORT_UART1); //Set Data Port |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + else if (incoming == 'x') |
| 51 | + break; |
| 52 | + else if (incoming == STATUS_GETBYTE_TIMEOUT) |
| 53 | + break; |
| 54 | + else |
| 55 | + printUnknown(incoming); |
| 56 | + } |
| 57 | + |
| 58 | + while (Serial.available()) Serial.read(); //Empty buffer of any newline chars |
| 59 | +} |
0 commit comments