1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 08:41:59 +00:00

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

This commit is contained in:
J. Nick Koston
2026-01-05 22:50:51 -10:00
parent 22cb0da903
commit efbd14c15c
2 changed files with 6 additions and 7 deletions

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);

View File

@@ -564,10 +564,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_,