1
0
mirror of https://github.com/esphome/esphome.git synced 2025-01-18 20:10:55 +00:00

[psram] Improve total PSRAM display in logs by using rounded KB values (#8008)

Co-authored-by: Djordje Mandic <6750655+DjordjeMandic@users.noreply.github.com>
This commit is contained in:
Edward Firmo 2025-01-13 05:11:48 +01:00 committed by GitHub
parent fef50afef8
commit 528d3672b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 12 additions and 1 deletions

View File

@ -21,7 +21,14 @@ void PsramComponent::dump_config() {
ESP_LOGCONFIG(TAG, " Available: %s", YESNO(available)); ESP_LOGCONFIG(TAG, " Available: %s", YESNO(available));
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 1, 0) #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 1, 0)
if (available) { if (available) {
ESP_LOGCONFIG(TAG, " Size: %d KB", heap_caps_get_total_size(MALLOC_CAP_SPIRAM) / 1024); const size_t psram_total_size_bytes = heap_caps_get_total_size(MALLOC_CAP_SPIRAM);
const float psram_total_size_kb = psram_total_size_bytes / 1024.0f;
if (abs(std::round(psram_total_size_kb) - psram_total_size_kb) < 0.05f) {
ESP_LOGCONFIG(TAG, " Size: %.0f KB", psram_total_size_kb);
} else {
ESP_LOGCONFIG(TAG, " Size: %zu bytes", psram_total_size_bytes);
}
} }
#endif #endif
} }

View File

@ -0,0 +1 @@
<<: !include common.yaml

View File

@ -0,0 +1 @@
<<: !include common.yaml

View File

@ -0,0 +1 @@
<<: !include common.yaml

View File

@ -0,0 +1 @@
<<: !include common.yaml