mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-11-30 18:23:03 +05:00
fix: normalize floating-point settings before validation
This commit is contained in:
1 parent
ff07bdcdca
commit
7c6e85b3f6
2 files changed
+49
-44
No files matched your search
+3
-3
@@ -173,11 +173,11 @@ static void collectMqttChanges() {
|
||||
template <typename Structure, typename Field, typename Publish>
|
||||
static bool publishField(
|
||||
StructSnapshot<Structure>& snapshot, const Field* field,
|
||||
unsigned long intervalMs, Publish publish
|
||||
unsigned long intervalMs, Publish publish, float tolerance = 0.0001f
|
||||
) {
|
||||
const unsigned long now = millis();
|
||||
unsigned long& lastPublishAt = mqttPublishTimes.get(field);
|
||||
if (lastPublishAt != 0 && now - lastPublishAt < intervalMs && snapshot.equals(field)) {
|
||||
if (lastPublishAt != 0 && now - lastPublishAt < intervalMs && snapshot.equals(field, tolerance)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ static bool publishPidSettings(unsigned long intervalMs) {
|
||||
published = publishField(
|
||||
settingsSnapshot, &settings.pid.i_factor, intervalMs, [](float value) {
|
||||
return publishValue(mqttTopic("settings/pid/i_factor"), value, 4);
|
||||
}
|
||||
}, 0.00005f
|
||||
);
|
||||
if (published) {
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user