scaleBasicRegisters static method

Map<String, double> scaleBasicRegisters(
  1. List<int> raw
)

Scale 3 raw register values (basic sensor: moisture, temp, conductivity).

Implementation

static Map<String, double> scaleBasicRegisters(List<int> raw) {
  assert(raw.length >= 3);
  int rawTemp = raw[1];
  if (rawTemp & 0x8000 != 0) rawTemp -= 0x10000;
  return {
    'moisture': raw[0] / 10.0,
    'temperature': rawTemp / 10.0,
    'conductivity': raw[2].toDouble(),
  };
}