use standard fixed length types

This commit is contained in:
Nicu Hodos 2025-10-08 17:14:06 +02:00
parent 98fbf2a55e
commit 9093996ec9
2 changed files with 15 additions and 15 deletions

View File

@ -22,7 +22,7 @@ namespace HaESP {
ESP.getHeapStats(&hfree, &hmax, &hfrag);
char value[128];
snprintf_P(value, sizeof(value), PSTR("{\"fragmentation\":%d,\"heap\":{\"Heap free\":\"%d B\",\"Heap max free block\":\"%d B\"}}"), hfrag, hfree, hmax);
snprintf_P(value, sizeof(value), PSTR("{\"fragmentation\":%lu,\"heap\":{\"Heap free\":\"%lu B\",\"Heap max free block\":\"%u B\"}}"), hfrag, hfree, hmax);
GenericSensor::mapSensors["heap_fragmentation"]->updateState(value);
GenericSensor::mapSensors["heap_free"]->updateState(to_string(hfree).c_str());
GenericSensor::mapSensors["heap_max_free_block"]->updateState(to_string(hmax).c_str());

View File

@ -258,14 +258,14 @@ namespace Ha {
};
struct Number : Component, StatefulCommand {
unsigned int min = 1;
unsigned int max = 100;
unsigned int step = 1;
uint16_t min = 1;
uint16_t max = 100;
uint16_t step = 1;
const char* unitMeasure = nullptr;
Number(const char* name, const char* id, onMessage f) : Component(id, name, "number"), StatefulCommand(this, f) {}
void updateState(unsigned int value) {
void updateState(uint16_t value) {
State::updateState(to_string(value).c_str());
}
@ -280,13 +280,13 @@ namespace Ha {
};
struct Text : Component, StatefulCommand {
unsigned int min = 1;
unsigned int max = 100;
uint16_t min = 1;
uint16_t max = 100;
const char* pattern = nullptr;
Text(const char* name, const char* id, onMessage f) : Component(id, name, "text"), StatefulCommand(this, f) {}
void updateState(unsigned int value) {
void updateState(uint16_t value) {
State::updateState(to_string(value).c_str());
}
@ -315,7 +315,7 @@ namespace Ha {
};
struct BinarySensor : GenericSensor {
unsigned int off_delay_seconds = 0;
uint16_t off_delay_seconds = 0;
BinarySensor(const char* id, const char* name = nullptr) : GenericSensor(id, name, "binary_sensor") {}
@ -327,7 +327,7 @@ namespace Ha {
struct Sensor : GenericSensor {
const char* unitMeasure = nullptr;
unsigned int precision = 2;
uint16_t precision = 2;
SensorStateClass sensorStateClass;
Sensor(const char* name, const char* id) : GenericSensor(id, name, "sensor") {}
@ -419,7 +419,7 @@ namespace Ha {
return *this;
}
Builder& withPrecision(unsigned int value) {
Builder& withPrecision(uint16_t value) {
cmp->precision = value;
return *this;
}
@ -429,22 +429,22 @@ namespace Ha {
return *this;
}
Builder& withMin(unsigned int value) {
Builder& withMin(uint16_t value) {
cmp->min = value;
return *this;
}
Builder& withMax(unsigned int value) {
Builder& withMax(uint16_t value) {
cmp->max = value;
return *this;
}
Builder& withStep(unsigned int value) {
Builder& withStep(uint16_t value) {
cmp->step = value;
return *this;
}
Builder& withOffDelaySeconds(unsigned int value) {
Builder& withOffDelaySeconds(uint16_t value) {
cmp->off_delay_seconds = value;
return *this;
}