mirror of
https://github.com/esphome/esphome.git
synced 2026-01-17 07:24:53 -07:00
Compare commits
3 Commits
rc522_spi_
...
statsd_sta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5934b88d2e | ||
|
|
5ce4b0c445 | ||
|
|
0ea5d7abff |
@@ -1,5 +1,4 @@
|
||||
#include "rc522_spi.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
// Based on:
|
||||
@@ -71,7 +70,7 @@ void RC522Spi::pcd_read_register(PcdRegister reg, ///< The register to read fro
|
||||
index++;
|
||||
|
||||
#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
|
||||
buf_append_printf(cstrb, sizeof(cstrb), 0, " %x", values[0]);
|
||||
sprintf(cstrb, " %x", values[0]);
|
||||
buf.append(cstrb);
|
||||
#endif
|
||||
}
|
||||
@@ -79,7 +78,7 @@ void RC522Spi::pcd_read_register(PcdRegister reg, ///< The register to read fro
|
||||
values[index] = transfer_byte(address); // Read value and tell that we want to read the same address again.
|
||||
|
||||
#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
|
||||
buf_append_printf(cstrb, sizeof(cstrb), 0, " %x", values[index]);
|
||||
sprintf(cstrb, " %x", values[index]);
|
||||
buf.append(cstrb);
|
||||
#endif
|
||||
|
||||
@@ -89,7 +88,7 @@ void RC522Spi::pcd_read_register(PcdRegister reg, ///< The register to read fro
|
||||
|
||||
#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
|
||||
buf = buf + " ";
|
||||
buf_append_printf(cstrb, sizeof(cstrb), 0, "%x", values[index]);
|
||||
sprintf(cstrb, "%x", values[index]);
|
||||
buf.append(cstrb);
|
||||
|
||||
ESP_LOGVV(TAG, "read_register_array_(%x, %d, , %d) -> %s", reg, count, rx_align, buf.c_str());
|
||||
@@ -128,7 +127,7 @@ void RC522Spi::pcd_write_register(PcdRegister reg, ///< The register to write t
|
||||
transfer_byte(values[index]);
|
||||
|
||||
#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
|
||||
buf_append_printf(cstrb, sizeof(cstrb), 0, " %x", values[index]);
|
||||
sprintf(cstrb, " %x", values[index]);
|
||||
buf.append(cstrb);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -114,14 +114,23 @@ void StatsdComponent::update() {
|
||||
// This implies you can't explicitly set a gauge to a negative number without first setting it to zero.
|
||||
if (val < 0) {
|
||||
if (this->prefix_) {
|
||||
out.append(str_sprintf("%s.", this->prefix_));
|
||||
out.append(this->prefix_);
|
||||
out.append(".");
|
||||
}
|
||||
out.append(str_sprintf("%s:0|g\n", s.name));
|
||||
out.append(s.name);
|
||||
out.append(":0|g\n");
|
||||
}
|
||||
if (this->prefix_) {
|
||||
out.append(str_sprintf("%s.", this->prefix_));
|
||||
out.append(this->prefix_);
|
||||
out.append(".");
|
||||
}
|
||||
out.append(str_sprintf("%s:%f|g\n", s.name, val));
|
||||
out.append(s.name);
|
||||
// Buffer for ":" + value + "|g\n".
|
||||
// %g uses max 13 chars for value (sign + 6 significant digits + e+xxx)
|
||||
// Total: 1 + 13 + 4 = 18 chars + null, use 24 for safety
|
||||
char val_buf[24];
|
||||
buf_append_printf(val_buf, sizeof(val_buf), 0, ":%g|g\n", val);
|
||||
out.append(val_buf);
|
||||
|
||||
if (out.length() > SEND_THRESHOLD) {
|
||||
this->send_(&out);
|
||||
|
||||
Reference in New Issue
Block a user