From 3b81e8348d1e7b1274d94f717d41acd073e6d096 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 9 Mar 2019 13:57:03 -0600 Subject: [PATCH] Only handle most characters in cmdstate 0 Otherwise, "T1s" didn't set time (period) of 1 second, because the "s" was interpreted to mean "save". --- RFout1MHzV1_06/RFout1MHzV1_06.ino | 43 +++++++++++++++---------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/RFout1MHzV1_06/RFout1MHzV1_06.ino b/RFout1MHzV1_06/RFout1MHzV1_06.ino index 06cffbe..791d71c 100644 --- a/RFout1MHzV1_06/RFout1MHzV1_06.ino +++ b/RFout1MHzV1_06/RFout1MHzV1_06.ino @@ -122,26 +122,27 @@ void setup() // Handle serial commands void handle_serial() { int c = Serial.read(); - if(c == 'P' || c=='p') { - Serial.println(F("Entering passthrough mode -- reset microcontroller to return to normal mode\n")); - passthrough = true; - } - else if(c == 'S' || c == 's') { - SaveToEPROM (); - Serial.println(F("Time pulse setting was saved")); - } - else if(c == 'H' || c == 'h') { - HelpText (); - } - else if(c == 'F' || c == 'f') { - Serial.print(F("Frequency?")); - cmdstate = 1; freq = period = 0; - } - else if(c == 'T' || c == 't') { - Serial.print(F("Period?")); - cmdstate = 2; freq = period = 0; - } - else if(cmdstate == 1) { + if(cmdstate == 0) { + if(c == 'P' || c=='p') { + Serial.println(F("Entering passthrough mode -- reset microcontroller to return to normal mode\n")); + passthrough = true; + } + else if(c == 'S' || c == 's') { + SaveToEPROM (); + Serial.println(F("Time pulse setting was saved")); + } + else if(c == 'H' || c == 'h') { + HelpText (); + } + else if(c == 'F' || c == 'f') { + Serial.print(F("Frequency?")); + cmdstate = 1; freq = period = 0; + } + else if(c == 'T' || c == 't') { + Serial.print(F("Period?")); + cmdstate = 2; freq = period = 0; + } + } else if(cmdstate == 1) { if(c >= '0' && c <= '9') { Serial.write(c); freq = freq * 10 + c - '0'; @@ -177,8 +178,6 @@ void handle_serial() { } else if (c == 'M' || c == 'm') { Serial.write(c); period *= 1000lu; - } else if (c == 'U' || c == 'u') { - period *= 1000lu; } else if (c == '\n' || c == '\r') { Serial.println(F("")); if (setGPS_OutputPeriod(period)) {