From 82f729216ed9b2dfe93b41baa6dfe2892741d176 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 16 Aug 2024 21:41:13 +0300 Subject: [PATCH] mapping constrain fix & more mbus relability --- lighthub/itemCmd.cpp | 3 ++- lighthub/modules/out_modbus.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lighthub/itemCmd.cpp b/lighthub/itemCmd.cpp index 7db7d71..575d19c 100644 --- a/lighthub/itemCmd.cpp +++ b/lighthub/itemCmd.cpp @@ -1455,7 +1455,8 @@ if (valMapping && valMapping->type == aJson_Array && aJson.getArraySize(valMappi if (getInt()valueint) return itemCmd().Int((uint32_t) 0); int diff = ((b-a)/(d-c))/2; //return itemCmd().Int((uint32_t) constrain(map(getInt(),c,d,a,b)+diff,0,255)); - return itemCmd().Int((uint32_t) map(getInt(),c,d,a,b)+diff); + return itemCmd().Int((uint32_t) constrain(map(getInt(),c,d,a,b)+diff,0,b)); + //return itemCmd().Int((uint32_t) map(getInt(),c,d,a,b)+diff); } if (valMapping && valMapping->type == aJson_NULL) return itemCmd(); return *this; diff --git a/lighthub/modules/out_modbus.cpp b/lighthub/modules/out_modbus.cpp index 1df7a42..78481c7 100644 --- a/lighthub/modules/out_modbus.cpp +++ b/lighthub/modules/out_modbus.cpp @@ -731,7 +731,7 @@ if (itemParametersObj && itemParametersObj->type ==aJson_Object) debugSerial<<"MBUS: SEND "<itemArr->name<<" "; sendRes = sendModbus(execObj->name,outValue); needResend = (savedValue != outValue->valueint); - //while(needResend && mbusSlenceTimer && !isTimeOver(mbusSlenceTimer,millis(),100)) modbusIdle(); + while(needResend && mbusSlenceTimer && !isTimeOver(mbusSlenceTimer,millis(),100)) modbusIdle(); } while (needResend); //repeat sending if target value changed while we're waited for mbus responce