cse7766: Shave off 200k from the firmware when you log the raw measurement data, #include <iomanip> 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.

This commit is contained in:
Gábor Poczkodi 2024-11-04 22:19:38 +01:00
parent 01497c891d
commit 433c6866cb

View file

@ -1,7 +1,6 @@
#include "cse7766.h" #include "cse7766.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include <cinttypes> #include <cinttypes>
#include <iomanip>
#include <sstream> #include <sstream>
namespace esphome { namespace esphome {
@ -72,12 +71,13 @@ bool CSE7766Component::check_byte_() {
void CSE7766Component::parse_data_() { void CSE7766Component::parse_data_() {
#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERY_VERBOSE #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERY_VERBOSE
{ {
std::stringstream ss; std::string s = "Raw data:";
ss << "Raw data:" << std::hex << std::uppercase << std::setfill('0'); char buff[4] = {0};
for (uint8_t i = 0; i < 23; i++) { for (uint8_t i = 0; i <= 23; i++) {
ss << ' ' << std::setw(2) << static_cast<unsigned>(this->raw_data_[i]); snprintf(buff, sizeof(buff), " %02X", this->raw_data_[i]);
} s += buff;
ESP_LOGVV(TAG, "%s", ss.str().c_str()); }
ESP_LOGVV(TAG, "%s", s.c_str());
} }
#endif #endif