From caa63f437c4e70913e95a44538abc62defc21ed1 Mon Sep 17 00:00:00 2001 From: vtHydroponics <132159689+vtHydroponics@users.noreply.github.com> Date: Mon, 11 Nov 2024 11:24:18 -0500 Subject: [PATCH] MS5837 console calibration options and code cleanup (#22466) * Finalized gain/integration adjustment trees * Fixed the bugs * works but polishing code * need to debug pressure in bmp * updated temp to change via setoption8 command from tasmota * sensor table working, value reporting working, need to update dependency on sensor duality * working * updated file name for ms5837 xsns file * final working with renamed for current updates (128->116) * resolved PR comments for extra spaces, xi2c_96 * removed extra spaces, added unit for inches across languages * removed inches as a unit from language files * removed extra code, commented debug lines * rebased with dev branch, fixed sensor116 command --- .../BlueRobotics_MS5837_Library/MS5837.cpp | 2 +- tasmota/tasmota_xsns_sensor/xsns_116_ms5837.ino | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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;