From 433c6866cb3fac690d4f9bbb37ab3468a31e37c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Poczkodi?= Date: Mon, 4 Nov 2024 22:19:38 +0100 Subject: [PATCH] cse7766: Shave off 200k from the firmware when you log the raw measurement data, #include includes everything not just the kitchen sink. I tried debugging my smart plug (somehow only reports voltage), and with a barebone config, debug level none, the firmware is over half the flash size with this. --- esphome/components/cse7766/cse7766.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/esphome/components/cse7766/cse7766.cpp b/esphome/components/cse7766/cse7766.cpp index 48240464b3..83b8269b97 100644 --- a/esphome/components/cse7766/cse7766.cpp +++ b/esphome/components/cse7766/cse7766.cpp @@ -1,7 +1,6 @@ #include "cse7766.h" #include "esphome/core/log.h" #include -#include #include namespace esphome { @@ -72,12 +71,13 @@ bool CSE7766Component::check_byte_() { void CSE7766Component::parse_data_() { #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERY_VERBOSE { - std::stringstream ss; - ss << "Raw data:" << std::hex << std::uppercase << std::setfill('0'); - for (uint8_t i = 0; i < 23; i++) { - ss << ' ' << std::setw(2) << static_cast(this->raw_data_[i]); - } - ESP_LOGVV(TAG, "%s", ss.str().c_str()); + std::string s = "Raw data:"; + char buff[4] = {0}; + for (uint8_t i = 0; i <= 23; i++) { + snprintf(buff, sizeof(buff), " %02X", this->raw_data_[i]); + s += buff; + } + ESP_LOGVV(TAG, "%s", s.c_str()); } #endif