[opentherm][nau7802] Use direct format specifiers instead of to_string().c_str() (#13019)

This commit is contained in:
J. Nick Koston
2026-01-06 07:32:43 -10:00
committed by GitHub
parent a94eef3a60
commit a8a26f4ea8
2 changed files with 6 additions and 8 deletions
+3 -3
View File
@@ -131,9 +131,9 @@ void NAU7802Sensor::dump_config() {
}
// Note these may differ from the values on the device if calbration has been run
ESP_LOGCONFIG(TAG,
" Offset Calibration: %s\n"
" Offset Calibration: %" PRId32 "\n"
" Gain Calibration: %f",
to_string(this->offset_calibration_).c_str(), this->gain_calibration_);
this->offset_calibration_, this->gain_calibration_);
std::string voltage = "unknown";
switch (this->ldo_) {
@@ -289,7 +289,7 @@ void NAU7802Sensor::loop() {
this->status_clear_error();
int32_t ocal = this->read_value_(OCAL1_B2_REG, 3);
ESP_LOGI(TAG, "New Offset: %s", to_string(ocal).c_str());
ESP_LOGI(TAG, "New Offset: %" PRId32, ocal);
uint32_t gcal = this->read_value_(GCAL1_B3_REG, 4);
float gcal_f = ((float) gcal / (float) (1 << GCAL1_FRACTIONAL));
ESP_LOGI(TAG, "New Gain: %f", gcal_f);
+3 -5
View File
@@ -21,7 +21,6 @@ namespace esphome {
namespace opentherm {
using std::string;
using std::to_string;
static const char *const TAG = "opentherm";
@@ -564,10 +563,9 @@ const char *OpenTherm::message_id_to_str(MessageId id) {
void OpenTherm::debug_data(OpenthermData &data) {
ESP_LOGD(TAG, "%s %s %s %s", format_bin(data.type).c_str(), format_bin(data.id).c_str(),
format_bin(data.valueHB).c_str(), format_bin(data.valueLB).c_str());
ESP_LOGD(TAG, "type: %s; id: %s; HB: %s; LB: %s; uint_16: %s; float: %s",
this->message_type_to_str((MessageType) data.type), to_string(data.id).c_str(),
to_string(data.valueHB).c_str(), to_string(data.valueLB).c_str(), to_string(data.u16()).c_str(),
to_string(data.f88()).c_str());
ESP_LOGD(TAG, "type: %s; id: %u; HB: %u; LB: %u; uint_16: %u; float: %f",
this->message_type_to_str((MessageType) data.type), data.id, data.valueHB, data.valueLB, data.u16(),
data.f88());
}
void OpenTherm::debug_error(OpenThermError &error) const {
ESP_LOGD(TAG, "data: 0x%08" PRIx32 "; clock: %u; capture: 0x%08" PRIx32 "; bit_pos: %u", error.data, this->clock_,