mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 03:39:49 +03:00
mapping constrain fix & more mbus relability
This commit is contained in:
@@ -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);
|
if (getInt()<aJson.getArrayItem(valMapping,2)->valueint) return itemCmd().Int((uint32_t) 0);
|
||||||
int diff = ((b-a)/(d-c))/2;
|
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) 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();
|
if (valMapping && valMapping->type == aJson_NULL) return itemCmd();
|
||||||
return *this;
|
return *this;
|
||||||
|
|||||||
@@ -731,7 +731,7 @@ if (itemParametersObj && itemParametersObj->type ==aJson_Object)
|
|||||||
debugSerial<<"MBUS: SEND "<<item->itemArr->name<<" ";
|
debugSerial<<"MBUS: SEND "<<item->itemArr->name<<" ";
|
||||||
sendRes = sendModbus(execObj->name,outValue);
|
sendRes = sendModbus(execObj->name,outValue);
|
||||||
needResend = (savedValue != outValue->valueint);
|
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
|
while (needResend); //repeat sending if target value changed while we're waited for mbus responce
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user