diff --git a/lib/lib_i2c/BlueRobotics_MS5837_Library/MS5837.cpp b/lib/lib_i2c/BlueRobotics_MS5837_Library/MS5837.cpp index b36a99e0b..a8e33284e 100644 --- a/lib/lib_i2c/BlueRobotics_MS5837_Library/MS5837.cpp +++ b/lib/lib_i2c/BlueRobotics_MS5837_Library/MS5837.cpp @@ -255,4 +255,4 @@ uint8_t MS5837::crc4(uint16_t n_prom[]) { n_rem = ((n_rem >> 12) & 0x000F); return n_rem ^ 0x00; -} +} \ No newline at end of file diff --git a/tasmota/tasmota_xsns_sensor/xsns_116_ms5837.ino b/tasmota/tasmota_xsns_sensor/xsns_116_ms5837.ino index 49bc8db10..403b1c3f9 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_116_ms5837.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_116_ms5837.ino @@ -108,12 +108,27 @@ void MS5837Show(bool json) { bool ms5837CommandSensor() { bool serviced = true; + char argument[XdrvMailbox.data_len]; + long value = 0; + + for (uint32_t ca = 0; ca < XdrvMailbox.data_len; ca++) { + if ((' ' == XdrvMailbox.data[ca]) || ('=' == XdrvMailbox.data[ca])) { XdrvMailbox.data[ca] = ','; } + } + + bool any_value = (strchr(XdrvMailbox.data, ',') != nullptr); + if (any_value) { value = strtol(ArgV(argument, 2), nullptr, 10); } + switch (XdrvMailbox.payload) { case 0: MS5837Show(0); #ifdef USE_BMP ms5837_pressure_offset = bmp_sensors[0].bmp_pressure - ms5837_sensor.pressure(); #endif // USE_BMP + Response_P(PSTR("Set MS5837 pressure offset to %f"),ms5837_pressure_offset); + break; + case 1: + ms5837_pressure_offset = value; + Response_P(PSTR("Set MS5837 pressure offset to %f"),ms5837_pressure_offset); break; } return serviced;