diff --git a/src/driver/drv_sht3x.c b/src/driver/drv_sht3x.c index 668998f3c..c8f101375 100644 --- a/src/driver/drv_sht3x.c +++ b/src/driver/drv_sht3x.c @@ -135,15 +135,16 @@ void SHT3X_MeasurePercmd() { g_temp = 175 * ((th * 256 + tl) / 65535.0) - 45.0; g_humid = 100 * ((hh * 256 + hl) / 65535.0); #endif - g_temp = g_temp + g_caltemp; - g_humid = g_humid + g_calhum; + + g_temp = (int)((g_temp + g_caltemp) * 10.0) / 10.0f; + g_humid = (int)(g_humid + g_calhum); channel_temp = g_cfg.pins.channels[g_i2c_pin_data]; channel_humid = g_cfg.pins.channels2[g_i2c_pin_data]; CHANNEL_Set(channel_temp, (int)(g_temp * 10), 0); CHANNEL_Set(channel_humid, (int)(g_humid), 0); - addLogAdv(LOG_INFO, LOG_FEATURE_SENSOR, "SHT3X_Measure: Period Temperature:%fC Humidity:%f%%", g_temp, g_humid); + addLogAdv(LOG_INFO, LOG_FEATURE_SENSOR, "SHT3X_Measure: Period Temperature:%.2fC Humidity:%.0f%%", g_temp, g_humid); } commandResult_t SHT3X_MeasurePer(const void* context, const char* cmd, const char* args, int cmdFlags) { @@ -182,15 +183,15 @@ void SHT3X_Measurecmd() { g_humid = 100 * ((hh * 256 + hl) / 65535.0); #endif - g_temp = g_temp + g_caltemp; - g_humid = g_humid + g_calhum; + g_temp = (int)((g_temp + g_caltemp) * 10.0) / 10.0f; + g_humid = (int)(g_humid + g_calhum); channel_temp = g_cfg.pins.channels[g_i2c_pin_data]; channel_humid = g_cfg.pins.channels2[g_i2c_pin_data]; CHANNEL_Set(channel_temp, (int)(g_temp * 10), 0); CHANNEL_Set(channel_humid, (int)(g_humid), 0); - addLogAdv(LOG_INFO, LOG_FEATURE_SENSOR, "SHT3X_Measure: Temperature:%fC Humidity:%f%%", g_temp, g_humid); + addLogAdv(LOG_INFO, LOG_FEATURE_SENSOR, "SHT3X_Measure: Temperature:%.1fC Humidity:%.0f%%", g_temp, g_humid); } @@ -516,7 +517,7 @@ void SHT3X_OnEverySecond() void SHT3X_AppendInformationToHTTPIndexPage(http_request_t* request) { - hprintf255(request, "

SHT3X Temperature=%f, Humidity=%f

", g_temp, g_humid); + hprintf255(request, "

SHT3X Temperature=%.1f°c, Humidity=%.0f%

", g_temp, g_humid); if (channel_humid == channel_temp) { hprintf255(request, "WARNING: You don't have configured target channels for temp and humid results, set the first and second channel index in Pins!"); } diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c index 625d4924c..f0331bcb2 100644 --- a/src/httpserver/http_fns.c +++ b/src/httpserver/http_fns.c @@ -2262,7 +2262,7 @@ const char* g_obk_flagNames[] = { "[MQTT] Apply channel type multiplier on (if any) on channel value before publishing it", "[MQTT] In HA discovery, add relays as lights", "[HASS] Deactivate avty_t flag for sensor when publishing to HASS (permit to keep value)", - "error", + "[DRV] Deactivate Autostart of all drivers", "error", "error", "error", diff --git a/src/new_pins.h b/src/new_pins.h index a9ced8416..3c0be4a8b 100644 --- a/src/new_pins.h +++ b/src/new_pins.h @@ -257,8 +257,9 @@ typedef struct pinsState_s { #define OBK_FLAG_PUBLISH_MULTIPLIED_VALUES 33 #define OBK_FLAG_MQTT_HASS_ADD_RELAYS_AS_LIGHTS 34 #define OBK_FLAG_NOT_PUBLISH_AVAILABILITY_SENSOR 35 +#define OBK_FLAG_DRV_DISABLE_AUTOSTART 36 -#define OBK_TOTAL_FLAGS 36 +#define OBK_TOTAL_FLAGS 37 #define CGF_MQTT_CLIENT_ID_SIZE 64 diff --git a/src/user_main.c b/src/user_main.c index dad64473f..9ee68c92e 100644 --- a/src/user_main.c +++ b/src/user_main.c @@ -877,53 +877,54 @@ void Main_Init_BeforeDelay_Unsafe(bool bAutoRunScripts) { if (bAutoRunScripts) { CMD_ExecuteCommand("exec early.bat", COMMAND_FLAG_SOURCE_SCRIPT); - - // autostart drivers - if (PIN_FindPinIndexForRole(IOR_SM2135_CLK, -1) != -1 && PIN_FindPinIndexForRole(IOR_SM2135_DAT, -1) != -1) - { + if (!CFG_HasFlag(OBK_FLAG_DRV_DISABLE_AUTOSTART)) { + // autostart drivers + if (PIN_FindPinIndexForRole(IOR_SM2135_CLK, -1) != -1 && PIN_FindPinIndexForRole(IOR_SM2135_DAT, -1) != -1) + { #ifndef OBK_DISABLE_ALL_DRIVERS - DRV_StartDriver("SM2135"); + DRV_StartDriver("SM2135"); #endif - } - if (PIN_FindPinIndexForRole(IOR_SM2235_CLK, -1) != -1 && PIN_FindPinIndexForRole(IOR_SM2235_DAT, -1) != -1) - { + } + if (PIN_FindPinIndexForRole(IOR_SM2235_CLK, -1) != -1 && PIN_FindPinIndexForRole(IOR_SM2235_DAT, -1) != -1) + { #ifndef OBK_DISABLE_ALL_DRIVERS - DRV_StartDriver("SM2235"); + DRV_StartDriver("SM2235"); #endif - } - if (PIN_FindPinIndexForRole(IOR_BP5758D_CLK, -1) != -1 && PIN_FindPinIndexForRole(IOR_BP5758D_DAT, -1) != -1) - { + } + if (PIN_FindPinIndexForRole(IOR_BP5758D_CLK, -1) != -1 && PIN_FindPinIndexForRole(IOR_BP5758D_DAT, -1) != -1) + { #ifndef OBK_DISABLE_ALL_DRIVERS - DRV_StartDriver("BP5758D"); + DRV_StartDriver("BP5758D"); #endif - } - if (PIN_FindPinIndexForRole(IOR_BP1658CJ_CLK, -1) != -1 && PIN_FindPinIndexForRole(IOR_BP1658CJ_DAT, -1) != -1) { + } + if (PIN_FindPinIndexForRole(IOR_BP1658CJ_CLK, -1) != -1 && PIN_FindPinIndexForRole(IOR_BP1658CJ_DAT, -1) != -1) { #ifndef OBK_DISABLE_ALL_DRIVERS - DRV_StartDriver("BP1658CJ"); + DRV_StartDriver("BP1658CJ"); #endif - } - if (PIN_FindPinIndexForRole(IOR_BL0937_CF, -1) != -1 && PIN_FindPinIndexForRole(IOR_BL0937_CF1, -1) != -1 && PIN_FindPinIndexForRole(IOR_BL0937_SEL, -1) != -1) { + } + if (PIN_FindPinIndexForRole(IOR_BL0937_CF, -1) != -1 && PIN_FindPinIndexForRole(IOR_BL0937_CF1, -1) != -1 && PIN_FindPinIndexForRole(IOR_BL0937_SEL, -1) != -1) { #ifndef OBK_DISABLE_ALL_DRIVERS - DRV_StartDriver("BL0937"); + DRV_StartDriver("BL0937"); #endif - } - if ((PIN_FindPinIndexForRole(IOR_BridgeForward, -1) != -1) && (PIN_FindPinIndexForRole(IOR_BridgeReverse, -1) != -1)) - { + } + if ((PIN_FindPinIndexForRole(IOR_BridgeForward, -1) != -1) && (PIN_FindPinIndexForRole(IOR_BridgeReverse, -1) != -1)) + { #ifndef OBK_DISABLE_ALL_DRIVERS - DRV_StartDriver("Bridge"); + DRV_StartDriver("Bridge"); #endif - } - if ((PIN_FindPinIndexForRole(IOR_DoorSensorWithDeepSleep, -1) != -1) || - (PIN_FindPinIndexForRole(IOR_DoorSensorWithDeepSleep_NoPup, -1) != -1)) - { + } + if ((PIN_FindPinIndexForRole(IOR_DoorSensorWithDeepSleep, -1) != -1) || + (PIN_FindPinIndexForRole(IOR_DoorSensorWithDeepSleep_NoPup, -1) != -1)) + { #ifndef OBK_DISABLE_ALL_DRIVERS - DRV_StartDriver("DoorSensor"); + DRV_StartDriver("DoorSensor"); #endif - } - if (PIN_FindPinIndexForRole(IOR_SHT3X_CLK, -1) != -1 && PIN_FindPinIndexForRole(IOR_SHT3X_DAT, -1) != -1) { + } + if (PIN_FindPinIndexForRole(IOR_SHT3X_CLK, -1) != -1 && PIN_FindPinIndexForRole(IOR_SHT3X_DAT, -1) != -1) { #ifndef OBK_DISABLE_ALL_DRIVERS - DRV_StartDriver("SHT3X"); + DRV_StartDriver("SHT3X"); #endif + } } }