Skip to content

Add reportHeapNow function and report free space during state changes #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Firmware/RTK_Surveyor/States.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,7 @@ void requestChangeState(SystemState requestedState)
//Change states and print the new state
void changeState(SystemState newState)
{
reportHeapNow();
systemState = newState;

//Debug print
Expand Down
17 changes: 15 additions & 2 deletions Firmware/RTK_Surveyor/System.ino
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void startBluetooth()
#endif

btState = BT_NOTCONNECTED;
reportHeapNow();
}

}
Expand All @@ -80,6 +81,7 @@ void stopBluetooth()
log_d("Bluetooth turned off");

btState = BT_OFF;
reportHeapNow();
}
}

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

wifiState = WIFI_NOTCONNECTED;
reportHeapNow();
}
}

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

log_d("WiFi Stopped");
wifiState = WIFI_OFF;
reportHeapNow();
}
}

Expand Down Expand Up @@ -576,15 +580,24 @@ bool createTestFile()
return (false);
}

//If debug option is on, print available heap
void reportHeapNow()
{
if (settings.enableHeapReport == true)
{
lastHeapReport = millis();
Serial.printf("FreeHeap: %d / HeapLowestPoint: %d / LargestBlock: %d\n\r", ESP.getFreeHeap(), xPortGetMinimumEverFreeHeapSize(), heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
}
}

//If debug option is on, print available heap
void reportHeap()
{
if (settings.enableHeapReport == true)
{
if (millis() - lastHeapReport > 1000)
{
lastHeapReport = millis();
Serial.printf("FreeHeap: %d / HeapLowestPoint: %d / LargestBlock: %d\n\r", ESP.getFreeHeap(), xPortGetMinimumEverFreeHeapSize(), heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
reportHeapNow();
}
}
}
Expand Down