mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 23:48:11 +01:00
cse7766: remove all sstream
This commit is contained in:
parent
41f03a91b7
commit
88cfc82ed4
1 changed files with 13 additions and 16 deletions
|
@ -1,7 +1,5 @@
|
||||||
#include "cse7766.h"
|
#include "cse7766.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include <cinttypes>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace cse7766 {
|
namespace cse7766 {
|
||||||
|
@ -71,13 +69,8 @@ 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::string s = "Raw data:";
|
std::string s = format_hex_pretty(this->raw_data_, sizeof(this->raw_data_));
|
||||||
char buff[4] = {0};
|
ESP_LOGVV(TAG, "Raw data: %s", s.c_str());
|
||||||
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
|
#endif
|
||||||
|
|
||||||
|
@ -211,21 +204,25 @@ 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 = "Parsed:";
|
||||||
ss << "Parsed:";
|
char buff[64] = {0};
|
||||||
if (have_voltage) {
|
if (have_voltage) {
|
||||||
ss << " V=" << voltage << "V";
|
snprintf(buff, sizeof(buff), " V=%.2fV", voltage);
|
||||||
|
s += buff;
|
||||||
}
|
}
|
||||||
if (have_current) {
|
if (have_current) {
|
||||||
ss << " I=" << current * 1000.0f << "mA (~" << calculated_current * 1000.0f << "mA)";
|
snprintf(buff, sizeof(buff), " I=%.2fmA (~%fmA)", current * 1000.0f, calculated_current * 1000.0f);
|
||||||
|
s += buff;
|
||||||
}
|
}
|
||||||
if (have_power) {
|
if (have_power) {
|
||||||
ss << " P=" << power << "W";
|
snprintf(buff, sizeof(buff), " P=%.2fW", power);
|
||||||
|
s += buff;
|
||||||
}
|
}
|
||||||
if (energy != 0.0f) {
|
if (energy != 0.0f) {
|
||||||
ss << " E=" << energy << "kWh (" << cf_pulses << ")";
|
snprintf(buff, sizeof(buff), " E=%dkWh", cf_pulses);
|
||||||
|
s += buff;
|
||||||
}
|
}
|
||||||
ESP_LOGVV(TAG, "%s", ss.str().c_str());
|
ESP_LOGVV(TAG, "%s", s.c_str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue