mirror of
https://github.com/esphome/esphome.git
synced 2025-10-07 04:13:47 +01:00
Merge branch 'webserver_string_construction_reduce' into integration
This commit is contained in:
@@ -366,7 +366,9 @@ std::string value_accuracy_to_string(float value, int8_t accuracy_decimals) {
|
|||||||
|
|
||||||
std::string value_accuracy_with_uom_to_string(float value, int8_t accuracy_decimals, StringRef unit_of_measurement) {
|
std::string value_accuracy_with_uom_to_string(float value, int8_t accuracy_decimals, StringRef unit_of_measurement) {
|
||||||
normalize_accuracy_decimals(value, accuracy_decimals);
|
normalize_accuracy_decimals(value, accuracy_decimals);
|
||||||
char tmp[64]; // Increased to accommodate unit of measurement
|
// Buffer sized for float (up to ~15 chars) + space + typical UOM (usually <20 chars like "μS/cm")
|
||||||
|
// snprintf truncates safely if exceeded, though ESPHome UOMs are typically short
|
||||||
|
char tmp[64];
|
||||||
if (unit_of_measurement.empty()) {
|
if (unit_of_measurement.empty()) {
|
||||||
snprintf(tmp, sizeof(tmp), "%.*f", accuracy_decimals, value);
|
snprintf(tmp, sizeof(tmp), "%.*f", accuracy_decimals, value);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -14,10 +14,6 @@
|
|||||||
|
|
||||||
#include "esphome/core/optional.h"
|
#include "esphome/core/optional.h"
|
||||||
|
|
||||||
namespace esphome {
|
|
||||||
class StringRef;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USE_ESP8266
|
#ifdef USE_ESP8266
|
||||||
#include <Esp.h>
|
#include <Esp.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -49,6 +45,9 @@ class StringRef;
|
|||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
|
||||||
|
// Forward declaration to avoid circular dependency with string_ref.h
|
||||||
|
class StringRef;
|
||||||
|
|
||||||
/// @name STL backports
|
/// @name STL backports
|
||||||
///@{
|
///@{
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user