|
| 1 | +//Control the messages that get logged to SD |
| 2 | +//Control max logging time (limit to a certain number of minutes) |
| 3 | +//The main use case is the setup for a base station to log RAW sentences that then get post processed |
| 4 | +void menuLog() |
| 5 | +{ |
| 6 | + while (1) |
| 7 | + { |
| 8 | + Serial.println(); |
| 9 | + Serial.println(F("Menu: Logging Menu")); |
| 10 | + |
| 11 | + if (settings.enableSD && online.microSD) |
| 12 | + Serial.println(F("microSD card is online")); |
| 13 | + else |
| 14 | + { |
| 15 | + beginSD(); //Test if SD is present |
| 16 | + if (online.microSD == true) |
| 17 | + Serial.println(F("microSD card online")); |
| 18 | + else |
| 19 | + Serial.println(F("No microSD card is detected")); |
| 20 | + } |
| 21 | + |
| 22 | + Serial.print(F("1) Log to microSD: ")); |
| 23 | + if (settings.enableLogging == true) Serial.println(F("Enabled")); |
| 24 | + else Serial.println(F("Disabled")); |
| 25 | + |
| 26 | + if (settings.enableLogging == true) |
| 27 | + { |
| 28 | + Serial.print(F("2) Set max logging time: ")); |
| 29 | + Serial.print(settings.maxLogTime_minutes); |
| 30 | + Serial.println(F(" minutes")); |
| 31 | + } |
| 32 | + |
| 33 | + Serial.println(F("x) Exit")); |
| 34 | + |
| 35 | + byte incoming = getByteChoice(30); //Timeout after x seconds |
| 36 | + |
| 37 | + if (incoming == '1') |
| 38 | + { |
| 39 | + settings.enableLogging ^= 1; |
| 40 | + } |
| 41 | + else if (settings.enableLogging == true) |
| 42 | + { |
| 43 | + if (incoming == '2') |
| 44 | + { |
| 45 | + Serial.print(F("Enter max minutes to log data: ")); |
| 46 | + int maxMinutes = getNumber(menuTimeout); //Timeout after x seconds |
| 47 | + if (maxMinutes < 0 || maxMinutes > 60 * 48) //Arbitrary 48 hour limit |
| 48 | + { |
| 49 | + Serial.println(F("Error: max minutes out of range")); |
| 50 | + } |
| 51 | + else |
| 52 | + { |
| 53 | + settings.maxLogTime_minutes = maxMinutes; //Recorded to NVM and file at main menu exit |
| 54 | + } |
| 55 | + } |
| 56 | + else if (incoming == 'x') |
| 57 | + break; |
| 58 | + else if (incoming == STATUS_GETBYTE_TIMEOUT) |
| 59 | + break; |
| 60 | + else |
| 61 | + printUnknown(incoming); |
| 62 | + } |
| 63 | + else if (incoming == 'x') |
| 64 | + break; |
| 65 | + else if (incoming == STATUS_GETBYTE_TIMEOUT) |
| 66 | + { |
| 67 | + break; |
| 68 | + } |
| 69 | + else |
| 70 | + printUnknown(incoming); |
| 71 | + } |
| 72 | + |
| 73 | + while (Serial.available()) Serial.read(); //Empty buffer of any newline chars |
| 74 | +} |
| 75 | + |
1 | 76 | //Control the messages that get broadcast over Bluetooth and logged (if enabled) |
2 | 77 | void menuMessages() |
3 | 78 | { |
|
0 commit comments