mapping constrain fix & more mbus relability

This commit is contained in:
2024-08-16 21:41:13 +03:00
parent dc6e310b10
commit 82f729216e
2 changed files with 3 additions and 2 deletions

View File

@@ -1455,7 +1455,8 @@ if (valMapping && valMapping->type == aJson_Array && aJson.getArraySize(valMappi
if (getInt()<aJson.getArrayItem(valMapping,2)->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;

View File

@@ -731,7 +731,7 @@ if (itemParametersObj && itemParametersObj->type ==aJson_Object)
debugSerial<<"MBUS: SEND "<<item->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