Reduce code size

This commit is contained in:
Stephan Hadinger 2021-02-03 20:46:20 +01:00
parent ca82ed07c9
commit bf26ba3427
4 changed files with 11 additions and 3 deletions

View File

@ -477,7 +477,7 @@ void CmndStatus(void)
}
if ((0 == payload) || (4 == payload)) {
float freeMem = ((float)ESP_getFreeHeap()) / 1024;
float freeMem = ESP_getFreeHeap1024();
Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS4_MEMORY "\":{\"" D_JSON_PROGRAMSIZE "\":%d,\"" D_JSON_FREEMEMORY "\":%d,\"" D_JSON_HEAPSIZE "\":%1_f,\""
#ifdef ESP32
D_JSON_PSRMAXMEMORY "\":%d,\"" D_JSON_PSRFREEMEMORY "\":%d,\""

View File

@ -47,6 +47,10 @@ uint32_t ESP_getFreeHeap(void) {
return ESP.getFreeHeap();
}
float ESP_getFreeHeap1024(void) {
return ((float)ESP_getFreeHeap()) / 1024;
}
void ESP_Restart(void) {
// ESP.restart(); // This results in exception 3 on restarts on core 2.3.0
ESP.reset();
@ -411,6 +415,10 @@ uint32_t ESP_getFreeHeap(void) {
return ESP.getFreeHeap();
}
float ESP_getFreeHeap1024(void) {
return ((float)ESP_getFreeHeap()) / 1024;
}
uint32_t ESP_getMaxAllocHeap(void) {
// largest block of heap that can be allocated at once
uint32_t free_block_size = ESP.getMaxAllocHeap();

View File

@ -658,7 +658,7 @@ void MqttShowPWMState(void)
void MqttShowState(void)
{
char stemp1[TOPSZ];
float freeMem = ((float)ESP_getFreeHeap()) / 1024;
float freeMem = ESP_getFreeHeap1024();
ResponseAppendTime();
ResponseAppend_P(PSTR(",\"" D_JSON_UPTIME "\":\"%s\",\"UptimeSec\":%u"), GetUptime().c_str(), UpTime());

View File

@ -2063,7 +2063,7 @@ void HandleInformation(void)
char stopic[TOPSZ];
float freeMem = ((float)ESP_getFreeHeap()) / 1024;
float freeMem = ESP_getFreeHeap1024();
WSContentStart_P(PSTR(D_INFORMATION));
// Save 1k of code space replacing table html with javascript replace codes