File tree Expand file tree Collapse file tree 7 files changed +68
-19
lines changed Expand file tree Collapse file tree 7 files changed +68
-19
lines changed Original file line number Diff line number Diff line change @@ -309,18 +309,14 @@ void loop()
309309
310310 updateLogs (); // Record any new data. Create or close files as needed.
311311
312+ reportHeap (); // If debug enabled, report free heap
313+
312314 // Menu system via ESP32 USB connection
313315 if (Serial.available ()) menuMain (); // Present user menu
314316
315317 // Convert current system time to minutes. This is used in F9PSerialReadTask()/updateLogs() to see if we are within max log window.
316318 systemTime_minutes = millis () / 1000L / 60 ;
317319
318- if (millis () - lastHeapReport > 1000 )
319- {
320- lastHeapReport = millis ();
321- Serial.printf (" freeHeap: %d\n\r " , ESP.getFreeHeap ());
322- }
323-
324320 delay (10 ); // A small delay prevents panic if no other I2C or functions are called
325321}
326322
Original file line number Diff line number Diff line change @@ -751,3 +751,16 @@ bool logUBXMessages()
751751 return (true );
752752 return (false );
753753}
754+
755+ // If debug option is on, print available heap
756+ void reportHeap ()
757+ {
758+ if (settings.enableHeapReport == true )
759+ {
760+ if (millis () - lastHeapReport > 1000 )
761+ {
762+ lastHeapReport = millis ();
763+ Serial.printf (" freeHeap: %d\n\r " , ESP.getFreeHeap ());
764+ }
765+ }
766+ }
Original file line number Diff line number Diff line change 1+ // Toggle control of heap reports and I2C GNSS debug
2+ void menuDebug ()
3+ {
4+ while (1 )
5+ {
6+ Serial.println ();
7+ Serial.println (F (" Menu: Debug Menu" ));
8+
9+ Serial.print (F (" 1) Toggle I2C Debugging Output: " ));
10+ if (settings.enableI2Cdebug == true ) Serial.println (F (" Enabled" ));
11+ else Serial.println (F (" Disabled" ));
12+
13+ Serial.print (F (" 2) Toggle Heap Reporting: " ));
14+ if (settings.enableHeapReport == true ) Serial.println (F (" Enabled" ));
15+ else Serial.println (F (" Disabled" ));
16+
17+ Serial.println (F (" x) Exit" ));
18+
19+ byte incoming = getByteChoice (30 ); // Timeout after x seconds
20+
21+ if (incoming == ' 1' )
22+ {
23+ settings.enableI2Cdebug ^= 1 ;
24+
25+ if (settings.enableI2Cdebug )
26+ i2cGNSS.enableDebugging (Serial, true ); // Enable only the critical debug messages over Serial
27+ else
28+ i2cGNSS.disableDebugging ();
29+ }
30+ else if (incoming == ' 2' )
31+ {
32+ settings.enableHeapReport ^= 1 ;
33+ }
34+ else if (incoming == ' x' )
35+ break ;
36+ else if (incoming == STATUS_GETBYTE_TIMEOUT)
37+ {
38+ break ;
39+ }
40+ else
41+ printUnknown (incoming);
42+ }
43+
44+ while (Serial.available ()) Serial.read (); // Empty buffer of any newline chars
45+ }
Original file line number Diff line number Diff line change @@ -20,10 +20,6 @@ void menuGNSS()
2020 if (getSBAS () == true ) Serial.println (F (" Enabled" ));
2121 else Serial.println (F (" Disabled" ));
2222
23- Serial.print (F (" 4) Toggle I2C Debugging Output: " ));
24- if (settings.enableI2Cdebug == true ) Serial.println (F (" Enabled" ));
25- else Serial.println (F (" Disabled" ));
26-
2723 Serial.println (F (" x) Exit" ));
2824
2925 int incoming = getNumber (30 ); // Timeout after x seconds
@@ -71,15 +67,6 @@ void menuGNSS()
7167 settings.enableSBAS = true ;
7268 }
7369 }
74- else if (incoming == 4 )
75- {
76- settings.enableI2Cdebug ^= 1 ;
77-
78- if (settings.enableI2Cdebug )
79- i2cGNSS.enableDebugging (Serial, true ); // Enable only the critical debug messages over Serial
80- else
81- i2cGNSS.disableDebugging ();
82- }
8370 else if (incoming == STATUS_PRESSED_X)
8471 break ;
8572 else if (incoming == STATUS_GETNUMBER_TIMEOUT)
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ void menuMain()
2525
2626 Serial.println (F (" 5) Configure Ports" ));
2727
28+ Serial.println (F (" d) Configure Debug" ));
29+
2830 Serial.println (F (" r) Reset all settings to default" ));
2931
3032 if (binCount > 0 )
@@ -46,6 +48,8 @@ void menuMain()
4648 menuBase ();
4749 else if (incoming == ' 5' )
4850 menuPorts ();
51+ else if (incoming == ' d' )
52+ menuDebug ();
4953 else if (incoming == ' r' )
5054 {
5155 Serial.println (F (" \r\n Resetting to factory defaults. Press 'y' to confirm:" ));
Original file line number Diff line number Diff line change @@ -133,6 +133,7 @@ void recordSystemSettingsToFile()
133133 settingsFile.println (" log.rawx=" + (String)settings.log .rawx );
134134 settingsFile.println (" log.sfrbx=" + (String)settings.log .sfrbx );
135135 settingsFile.println (" enableI2Cdebug=" + (String)settings.enableI2Cdebug );
136+ settingsFile.println (" enableHeapReport=" + (String)settings.enableHeapReport );
136137
137138 if (online.gnss )
138139 updateDataFileAccess (&settingsFile); // Update the file access time & date
@@ -364,6 +365,8 @@ bool parseLine(char* str) {
364365 settings.log .sfrbx = d;
365366 else if (strcmp (settingName, " enableI2Cdebug" ) == 0 )
366367 settings.enableI2Cdebug = d;
368+ else if (strcmp (settingName, " enableHeapReport" ) == 0 )
369+ settings.enableHeapReport = d;
367370
368371 else
369372 Serial.printf (" Unknown setting %s on line: %s\r\n " , settingName, str);
Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ struct struct_settings {
109109 gnssMessages broadcast ;
110110 gnssMessages log ;
111111 bool enableI2Cdebug = false; //Turn on to display GNSS library debug messages
112+ bool enableHeapReport = false; //Turn on to display free heap
112113} settings ;
113114
114115//These are the devices on board RTK Surveyor that may be on or offline.
You can’t perform that action at this time.
0 commit comments