diff --git a/CHANGELOG.md b/CHANGELOG.md index f98b954bb..983ab1d2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. - Support for daisy chaining MAX7219 displays (#15345) - Command ``EnergyExportActive`` to (p)reset energy export active for supported devices. Currently ADE7880 only (#13515) - Sonoff SPM delayed SetPowerOnState (#13447) +- Command ``SetOption139 0/1`` to switch between pressure unit "mmHg" (0) or "inHg" (1) when ``SO24 1`` (#15350) ### Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index a435c2722..3bd937aae 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -106,6 +106,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo ## Changelog v11.1.0.1 ### Added +- Command ``SetOption139 0/1`` to switch between pressure unit "mmHg" (0) or "inHg" (1) when ``SO24 1`` [#15350](https://github.com/arendst/Tasmota/issues/15350) - Command ``EnergyExportActive`` to (p)reset energy export active for supported devices. Currently ADE7880 only [#13515](https://github.com/arendst/Tasmota/issues/13515) - Support for Sonoff MS01 soil moisture sensor [#15335](https://github.com/arendst/Tasmota/issues/15335) - Support for daisy chaining MAX7219 displays [#15345](https://github.com/arendst/Tasmota/issues/15345) diff --git a/tasmota/settings.h b/tasmota/settings.h index e2b5be2ac..f8b961527 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -168,7 +168,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t tuyasns_no_immediate : 1; // bit 22 (v11.0.0.4) - SetOption136 - (TuyaSNS) When ON disable publish single SNS value on Tuya Receive (keep Teleperiod) uint32_t tuya_exclude_from_mqtt : 1; // bit 23 (v11.0.0.5) - SetOption137 - (Tuya) When Set, avoid the (MQTT-) publish of defined Tuya CMDs (see xdrv_16_tuyamcu.ino) if SetOption66 is active uint32_t gui_table_align : 1; // bit 24 (v11.0.0.7) - SetOption138 - (GUI) Align (energy) table values left (0) or right (1) - uint32_t spare25 : 1; // bit 25 + uint32_t mm_vs_inch : 1; // bit 25 (v11.1.0.1) - SetOption139 - (Pressure) Switch between mmHg (0) or inHg (1) when SO24 1 uint32_t spare26 : 1; // bit 26 uint32_t spare27 : 1; // bit 27 uint32_t spare28 : 1; // bit 28 diff --git a/tasmota/support.ino b/tasmota/support.ino index 2ee1a71b3..97a4f9221 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -735,9 +735,9 @@ float ConvertTempToFahrenheit(float c) { float result = c; if (!isnan(c) && Settings->flag.temperature_conversion) { // SetOption8 - Switch between Celsius or Fahrenheit - result = c * 1.8 + 32; // Fahrenheit + result = c * 1.8f + 32; // Fahrenheit } - result = result + (0.1 * Settings->temp_comp); + result = result + (0.1f * Settings->temp_comp); return result; } @@ -745,9 +745,9 @@ float ConvertTempToCelsius(float c) { float result = c; if (!isnan(c) && !Settings->flag.temperature_conversion) { // SetOption8 - Switch between Celsius or Fahrenheit - result = (c - 32) / 1.8; // Celsius + result = (c - 32) / 1.8f; // Celsius } - result = result + (0.1 * Settings->temp_comp); + result = result + (0.1f * Settings->temp_comp); return result; } @@ -762,65 +762,66 @@ float ConvertTemp(float c) { return ConvertTempToFahrenheit(c); } -char TempUnit(void) -{ +char TempUnit(void) { // SetOption8 - Switch between Celsius or Fahrenheit return (Settings->flag.temperature_conversion) ? D_UNIT_FAHRENHEIT[0] : D_UNIT_CELSIUS[0]; } -float ConvertHumidity(float h) -{ +float ConvertHumidity(float h) { float result = h; TasmotaGlobal.global_update = TasmotaGlobal.uptime; TasmotaGlobal.humidity = h; - result = result + (0.1 * Settings->hum_comp); + result = result + (0.1f * Settings->hum_comp); return result; } -float CalcTempHumToDew(float t, float h) -{ +float CalcTempHumToDew(float t, float h) { if (isnan(h) || isnan(t)) { return NAN; } if (Settings->flag.temperature_conversion) { // SetOption8 - Switch between Celsius or Fahrenheit - t = (t - 32) / 1.8; // Celsius + t = (t - 32) / 1.8f; // Celsius } - float gamma = TaylorLog(h / 100) + 17.62 * t / (243.5 + t); - float result = (243.5 * gamma / (17.62 - gamma)); + float gamma = TaylorLog(h / 100) + 17.62f * t / (243.5f + t); + float result = (243.5f * gamma / (17.62f - gamma)); if (Settings->flag.temperature_conversion) { // SetOption8 - Switch between Celsius or Fahrenheit - result = result * 1.8 + 32; // Fahrenheit + result = result * 1.8f + 32; // Fahrenheit } return result; } -float ConvertPressure(float p) -{ +float ConvertPressure(float p) { float result = p; TasmotaGlobal.global_update = TasmotaGlobal.uptime; TasmotaGlobal.pressure_hpa = p; - if (!isnan(p) && Settings->flag.pressure_conversion) { // SetOption24 - Switch between hPa or mmHg pressure unit - result = p * 0.75006375541921; // mmHg + if (!isnan(p) && Settings->flag.pressure_conversion) { // SetOption24 - Switch between hPa or mmHg pressure unit + if (Settings->flag5.mm_vs_inch) { // SetOption139 - Switch between mmHg or inHg pressure unit +// result = p * 0.02952998016471; // inHg + result = p * 0.0295299f; // inHg (double to float saves 16 bytes!) + } else { +// result = p * 0.75006375541921; // mmHg + result = p * 0.7500637f; // mmHg (double to float saves 16 bytes!) + } } return result; } -float ConvertPressureForSeaLevel(float pressure) -{ - if (pressure == 0.0f) +float ConvertPressureForSeaLevel(float pressure) { + if (pressure == 0.0f) { return pressure; - - return ConvertPressure((pressure / FastPrecisePow(1.0 - ((float)Settings->altitude / 44330.0f), 5.255f)) - 21.6f); + } + return ConvertPressure((pressure / FastPrecisePow(1.0f - ((float)Settings->altitude / 44330.0f), 5.255f)) - 21.6f); } String PressureUnit(void) { - return (Settings->flag.pressure_conversion) ? String(F(D_UNIT_MILLIMETER_MERCURY)) : String(F(D_UNIT_PRESSURE)); + return (Settings->flag.pressure_conversion) ? (Settings->flag5.mm_vs_inch) ? String(F(D_UNIT_INCH_MERCURY)) : String(F(D_UNIT_MILLIMETER_MERCURY)) : String(F(D_UNIT_PRESSURE)); } float ConvertSpeed(float s) diff --git a/tools/decode-status.py b/tools/decode-status.py index e079eb5d4..3227e8a39 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -192,7 +192,9 @@ a_setoption = [[ "(Display & LVGL) force disabling default splash screen", "(TuyaSNS) When ON disable publish single SNS value on Tuya Receive (keep Teleperiod)", "(Tuya) When Set, avoid the (mqtt-) publish of Tuya MCU Heartbeat response if SetOption66 is active", - "","","","", + "(GUI) Align (energy) table values left (0) or right (1)", + "(Pressure) Switch between mmHg (0) or inHg (1) when SO24 1", + "","", "","","","" ]] @@ -295,7 +297,7 @@ else: obj = json.load(fp) def StartDecode(): - print ("\n*** decode-status.py v11.0.0.5 by Theo Arends and Jacek Ziolkowski ***") + print ("\n*** decode-status.py v11.1.0.1 by Theo Arends and Jacek Ziolkowski ***") # print("Decoding\n{}".format(obj))