scaleExtendedRegisters static method
Scale 7 raw register values into physical quantities.
Register order: moisture, temperature, conductivity, pH, N, P, K
Implementation
static Map<String, double> scaleExtendedRegisters(List<int> raw) {
assert(raw.length >= 7);
// Temperature is INT16 — apply two's complement if high bit set.
int rawTemp = raw[1];
if (rawTemp & 0x8000 != 0) rawTemp -= 0x10000;
return {
'moisture': raw[0] / 10.0,
'temperature': rawTemp / 10.0,
'conductivity': raw[2].toDouble(),
'ph': raw[3] / 10.0,
'nitrogen': raw[4].toDouble(),
'phosphorus': raw[5].toDouble(),
'potassium': raw[6].toDouble(),
};
}