mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-04 16:35:46 +00:00
tuyamcu calib if non zero
This commit is contained in:
@ -1589,6 +1589,8 @@ void TuyaMCU_PublishDPToBerry(const byte *data, int ofs) {
|
||||
|
||||
}
|
||||
}
|
||||
#define CALIB_IF_NONZERO(x,d) if(x) { x += d; }
|
||||
|
||||
void TuyaMCU_ParseStateMessage(const byte* data, int len) {
|
||||
tuyaMCUMapping_t* mapping;
|
||||
int ofs;
|
||||
@ -1693,9 +1695,9 @@ void TuyaMCU_ParseStateMessage(const byte* data, int len) {
|
||||
iC = (data[ofs + 6] << 16) | (data[ofs + 7] << 8) | data[ofs + 8];
|
||||
iP = (data[ofs + 9] << 16) | (data[ofs + 10] << 8) | data[ofs + 11];
|
||||
// calibration
|
||||
iV += mapping->delta;
|
||||
iC += mapping->delta2;
|
||||
iP += mapping->delta3;
|
||||
CALIB_IF_NONZERO(iV, mapping->delta);
|
||||
CALIB_IF_NONZERO(iC, mapping->delta2);
|
||||
CALIB_IF_NONZERO(iP, mapping->delta3);
|
||||
if (mapping->channel < 0) {
|
||||
CHANNEL_SetFirstChannelByType(ChType_Voltage_div10, iV);
|
||||
CHANNEL_SetFirstChannelByType(ChType_Current_div1000, iC);
|
||||
@ -1727,9 +1729,9 @@ void TuyaMCU_ParseStateMessage(const byte* data, int len) {
|
||||
// freq
|
||||
iF = data[ofs + 13 + 4] << 8 | data[ofs + 14 + 4];
|
||||
// calibration
|
||||
iV += mapping->delta;
|
||||
iC += mapping->delta2;
|
||||
iP += mapping->delta3;
|
||||
CALIB_IF_NONZERO(iV, mapping->delta);
|
||||
CALIB_IF_NONZERO(iC, mapping->delta2);
|
||||
CALIB_IF_NONZERO(iP, mapping->delta3);
|
||||
if (mapping->channel < 0) {
|
||||
CHANNEL_SetFirstChannelByType(ChType_Voltage_div10, iV);
|
||||
CHANNEL_SetFirstChannelByType(ChType_Current_div1000, iC);
|
||||
@ -1761,9 +1763,9 @@ void TuyaMCU_ParseStateMessage(const byte* data, int len) {
|
||||
// power
|
||||
iP = data[ofs + 6 + 4] << 8 | data[ofs + 7 + 4];
|
||||
// calibration
|
||||
iV += mapping->delta;
|
||||
iC += mapping->delta2;
|
||||
iP += mapping->delta3;
|
||||
CALIB_IF_NONZERO(iV, mapping->delta);
|
||||
CALIB_IF_NONZERO(iC, mapping->delta2);
|
||||
CALIB_IF_NONZERO(iP, mapping->delta3);
|
||||
if (mapping->channel < 0) {
|
||||
CHANNEL_SetFirstChannelByType(ChType_Voltage_div10, iV);
|
||||
CHANNEL_SetFirstChannelByType(ChType_Current_div1000, iC);
|
||||
|
||||
Reference in New Issue
Block a user