Speed up ESP32 GUI information partition display

This commit is contained in:
Theo Arends 2022-05-15 11:40:24 +02:00
parent 56209b3fe4
commit 8c2658bb3f
2 changed files with 27 additions and 18 deletions

View File

@ -319,19 +319,6 @@ extern "C" {
#include "rom/spi_flash.h" #include "rom/spi_flash.h"
#endif #endif
/*
void EspDumpPartitionTable(void) {
esp_partition_iterator_t it = esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL);
uint32_t count = 0;
for (; it != NULL; it = esp_partition_next(it)) {
++count;
const esp_partition_t *partition = esp_partition_get(it);
AddLog(LOG_LEVEL_DEBUG, PSTR("Partition #%d, name %s, type %d, subtype %d, size %d"), count, partition->label, partition->type, partition->subtype, partition->size);
}
esp_partition_iterator_release(it);
}
*/
uint32_t EspProgramSize(const char *label) { uint32_t EspProgramSize(const char *label) {
const esp_partition_t *part = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_ANY, label); const esp_partition_t *part = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_ANY, label);
if (!part) { if (!part) {

View File

@ -2472,14 +2472,36 @@ void HandleInformation(void)
esp_partition_iterator_t it = esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL); esp_partition_iterator_t it = esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL);
for (; it != NULL; it = esp_partition_next(it)) { for (; it != NULL; it = esp_partition_next(it)) {
const esp_partition_t *part = esp_partition_get(it); const esp_partition_t *part = esp_partition_get(it);
// AddLog(LOG_LEVEL_DEBUG, PSTR("Partition type %d, subtype %d, name %s, size %d"), part->type, part->subtype, part->label, part->size);
AddLog(LOG_LEVEL_DEBUG, PSTR("PRT: Type %d, Subtype %d, Name %s, Size %d"), part->type, part->subtype, part->label, part->size);
uint32_t part_size = part->size / 1024; uint32_t part_size = part->size / 1024;
if (0 == part->type) { // app if (ESP_PARTITION_TYPE_APP == part->type) {
uint32_t prog_size = EspProgramSize(part->label);
uint32_t cur_part = ESP_PARTITION_SUBTYPE_APP_FACTORY;
const esp_partition_t *running_ota = esp_ota_get_running_partition();
if (running_ota) {
cur_part = running_ota->subtype;
}
uint32_t prog_size = 0; // No active ota partition
if (part->subtype == ESP_PARTITION_SUBTYPE_APP_FACTORY) {
prog_size = EspProgramSize(part->label); // safeboot partition
}
else if ((part->subtype >= ESP_PARTITION_SUBTYPE_APP_OTA_MIN) && (part->subtype <= ESP_PARTITION_SUBTYPE_APP_OTA_MAX)) {
if (running_ota->subtype == part->subtype) {
prog_size = ESP_getSketchSize(); // Active running ota partition
}
}
char running[2] = { 0 };
if (part->subtype == cur_part) {
running[0] = '*';
}
uint32_t part_used = ((prog_size / 1024) * 100) / part_size; uint32_t part_used = ((prog_size / 1024) * 100) / part_size;
WSContentSend_PD(PSTR("}1" D_PARTITION " %s}2%d kB (" D_USED " %d%%)"), part->label, part_size, part_used); WSContentSend_PD(PSTR("}1" D_PARTITION " %s%s}2%d kB (" D_USED " %d%%)"), part->label, running, part_size, part_used);
} }
if ((1 == part->type) && (130 == part->subtype)) { // data and fs if ((ESP_PARTITION_TYPE_DATA == part->type) && (ESP_PARTITION_SUBTYPE_DATA_SPIFFS == part->subtype)) {
WSContentSend_PD(PSTR("}1" D_PARTITION " fs}2%d kB"), part_size); WSContentSend_PD(PSTR("}1" D_PARTITION " fs}2%d kB"), part_size);
} }
} }