mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
optional calibration offset
This commit is contained in:
parent
fb829a58a3
commit
89527287f9
@ -1665,6 +1665,23 @@ uint32_t vbus_get_septet(uint8_t *cp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *skip_double(char *cp) {
|
||||||
|
if (*cp == '+' || *cp == '-') {
|
||||||
|
cp++;
|
||||||
|
}
|
||||||
|
while (*cp) {
|
||||||
|
if (*cp == '.') {
|
||||||
|
cp++;
|
||||||
|
}
|
||||||
|
if (!isdigit(*cp)) {
|
||||||
|
return cp;
|
||||||
|
}
|
||||||
|
cp++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SML_Decode(uint8_t index) {
|
void SML_Decode(uint8_t index) {
|
||||||
const char *mp=(const char*)meter_p;
|
const char *mp=(const char*)meter_p;
|
||||||
int8_t mindex;
|
int8_t mindex;
|
||||||
@ -2168,6 +2185,12 @@ void SML_Decode(uint8_t index) {
|
|||||||
//AddLog(LOG_LEVEL_INFO, PSTR(">> %s"),mp);
|
//AddLog(LOG_LEVEL_INFO, PSTR(">> %s"),mp);
|
||||||
// get scaling factor
|
// get scaling factor
|
||||||
double fac = CharToDouble((char*)mp);
|
double fac = CharToDouble((char*)mp);
|
||||||
|
// get optional offset to calibrate meter
|
||||||
|
char *cp = skip_double((char*)mp);
|
||||||
|
if (cp && (*cp == '+' || *cp == '-')) {
|
||||||
|
double offset = CharToDouble(cp);
|
||||||
|
meter_vars[vindex] += offset;
|
||||||
|
}
|
||||||
meter_vars[vindex] /= fac;
|
meter_vars[vindex] /= fac;
|
||||||
SML_Immediate_MQTT((const char*)mp, vindex, mindex);
|
SML_Immediate_MQTT((const char*)mp, vindex, mindex);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user