Add command `SetOption139 0/1`

- Add command ``SetOption139 0/1`` to switch between pressure unit "mmHg" (0) or "inHg" (1) when ``SO24 1`` (#15350)
- Change double constants to float constants saving 200 bytes
This commit is contained in:
Theo Arends 2022-04-19 14:45:26 +02:00
parent 79b19ea62c
commit d71c1711f2
5 changed files with 33 additions and 28 deletions

View File

@ -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<phase>`` 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

View File

@ -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<phase>`` 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)

View File

@ -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

View File

@ -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)

View File

@ -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))