Skip to content

Commit a470519

Browse files
authored
Merge pull request #127 from LeeLeahy2/heap-sparkfun
Add reportHeapNow function and report free space during state changes
2 parents 9ea3482 + dad7cc1 commit a470519

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Firmware/RTK_Surveyor/States.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,7 @@ void requestChangeState(SystemState requestedState)
13861386
//Change states and print the new state
13871387
void changeState(SystemState newState)
13881388
{
1389+
reportHeapNow();
13891390
systemState = newState;
13901391

13911392
//Debug print

Firmware/RTK_Surveyor/System.ino

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ void startBluetooth()
6060
#endif
6161

6262
btState = BT_NOTCONNECTED;
63+
reportHeapNow();
6364
}
6465

6566
}
@@ -80,6 +81,7 @@ void stopBluetooth()
8081
log_d("Bluetooth turned off");
8182

8283
btState = BT_OFF;
84+
reportHeapNow();
8385
}
8486
}
8587

@@ -93,6 +95,7 @@ void startWiFi(char* ssid, char* pw)
9395
#endif
9496

9597
wifiState = WIFI_NOTCONNECTED;
98+
reportHeapNow();
9699
}
97100
}
98101

@@ -109,6 +112,7 @@ void stopWiFi()
109112

110113
log_d("WiFi Stopped");
111114
wifiState = WIFI_OFF;
115+
reportHeapNow();
112116
}
113117
}
114118

@@ -576,15 +580,24 @@ bool createTestFile()
576580
return (false);
577581
}
578582

583+
//If debug option is on, print available heap
584+
void reportHeapNow()
585+
{
586+
if (settings.enableHeapReport == true)
587+
{
588+
lastHeapReport = millis();
589+
Serial.printf("FreeHeap: %d / HeapLowestPoint: %d / LargestBlock: %d\n\r", ESP.getFreeHeap(), xPortGetMinimumEverFreeHeapSize(), heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
590+
}
591+
}
592+
579593
//If debug option is on, print available heap
580594
void reportHeap()
581595
{
582596
if (settings.enableHeapReport == true)
583597
{
584598
if (millis() - lastHeapReport > 1000)
585599
{
586-
lastHeapReport = millis();
587-
Serial.printf("FreeHeap: %d / HeapLowestPoint: %d / LargestBlock: %d\n\r", ESP.getFreeHeap(), xPortGetMinimumEverFreeHeapSize(), heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
600+
reportHeapNow();
588601
}
589602
}
590603
}

0 commit comments

Comments
 (0)