From f02380a0b41e3ab01d521fb3f4f902c0533a96ad Mon Sep 17 00:00:00 2001 From: acidvegas Date: Wed, 8 May 2024 19:34:42 -0400 Subject: [PATCH] Fixed ram/psram display. memGet.h wasnt needed as we can call this directly from ESP --- docs/FIRMWARE.md | 8 ++++---- meshmqtt.py | 14 +++++++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/FIRMWARE.md b/docs/FIRMWARE.md index 20af0f7..2bdb8fd 100644 --- a/docs/FIRMWARE.md +++ b/docs/FIRMWARE.md @@ -43,14 +43,14 @@ And place the follow code AFTER the above lines: ```cpp // Display memory usage using the MemGet class -uint32_t freeHeap = memGet.getFreeHeap(); -uint32_t totalHeap = memGet.getHeapSize(); +uint32_t freeHeap = ESP.getFreeHeap(); +uint32_t totalHeap = ESP.getHeapSize(); uint32_t usedHeap = totalHeap - freeHeap; display->drawString(x, y + FONT_HEIGHT_SMALL * 4, "Heap: " + String(usedHeap / 1024) + "/" + String(totalHeap / 1024) + " KB"); // Display PSRAM usage using the MemGet class -uint32_t freePsram = memGet.getFreePsram(); -uint32_t totalPsram = memGet.getPsramSize(); +uint32_t freePsram = ESP.getFreePsram(); +uint32_t totalPsram = ESP.getPsramSize(); uint32_t usedPsram = totalPsram - freePsram; display->drawString(x, y + FONT_HEIGHT_SMALL * 5, "PSRAM: " + String(usedPsram / 1024) + "/" + String(totalPsram / 1024) + " KB"); ``` diff --git a/meshmqtt.py b/meshmqtt.py index 9ae877e..8ed06bf 100644 --- a/meshmqtt.py +++ b/meshmqtt.py @@ -305,9 +305,17 @@ class MeshtasticMQTT(object): data.ParseFromString(message_packet.decoded.payload) logging.info('Received telemetry:') - data_dict = {key: value for key, value in data} - print(data_dict) - + data_dict = {} + for field, value in data.ListFields(): + if field.name == 'device_metrics': + text = clean_dict({item.name: getattr(value, item.name) for item in value.DESCRIPTOR.fields if hasattr(value, item.name)}) + if text: + logging.info(text) + else: + data_dict[field.name] = value + + logging.info(data_dict) + if getattr(data, 'device_metrics'): text = { 'battery_level' : getattr(data.device_metrics, 'battery_level'),