diff --git a/tasmota/xsns_46_MLX90614.ino b/tasmota/xsns_46_MLX90614.ino index 9a17ac9c0..3cc304f1f 100644 --- a/tasmota/xsns_46_MLX90614.ino +++ b/tasmota/xsns_46_MLX90614.ino @@ -71,8 +71,6 @@ uint16_t read_irtmp(uint8_t flag) void MLX90614_Every_Second(void) { - if (!mlx_ready) { return; } - uint16_t uval = read_irtmp(1); if (uval & 0x8000) { obj_temp = -999; @@ -95,8 +93,6 @@ void MLX90614_Every_Second(void) void MLX90614_Show(uint8_t json) { - if (!mlx_ready) { return; } - char obj_tstr[16]; dtostrfd(obj_temp, Settings.flag2.temperature_resolution, obj_tstr); char amb_tstr[16]; @@ -121,21 +117,23 @@ bool Xsns46(byte function) bool result = false; - switch (function) { - case FUNC_EVERY_SECOND: - MLX90614_Every_Second(); - break; - case FUNC_JSON_APPEND: - MLX90614_Show(1); - break; + if (FUNC_INIT == function) { + MLX90614_Init(); + } + else if (mlx_ready) { + switch (function) { + case FUNC_EVERY_SECOND: + MLX90614_Every_Second(); + break; + case FUNC_JSON_APPEND: + MLX90614_Show(1); + break; #ifdef USE_WEBSERVER - case FUNC_WEB_SENSOR: - MLX90614_Show(0); - break; + case FUNC_WEB_SENSOR: + MLX90614_Show(0); + break; #endif // USE_WEBSERVER - case FUNC_INIT: - MLX90614_Init(); - break; + } } return result; } diff --git a/tasmota/xsns_50_paj7620.ino b/tasmota/xsns_50_paj7620.ino index fdf5da48b..d9f5c98fc 100644 --- a/tasmota/xsns_50_paj7620.ino +++ b/tasmota/xsns_50_paj7620.ino @@ -309,7 +309,6 @@ void PAJ7620ReadGesture(void) void PAJ7620Detect(void) { - PAJ7620_next_job = 255; // do not loop if (I2cActive(PAJ7620_ADDR)) { return; } PAJ7620SelectBank(0); @@ -351,13 +350,8 @@ void PAJ7620Init(void) void PAJ7620Loop(void) { - if (255 == PAJ7620_next_job) { return; } - if (0 == PAJ7620_timeout_counter) { switch (PAJ7620_next_job) { - case 0: - PAJ7620Detect(); - break; case 1: PAJ7620Init(); break; @@ -376,8 +370,6 @@ void PAJ7620Loop(void) void PAJ7620Show(bool json) { - if (255 == PAJ7620_next_job) { return; } - if (json) { if (PAJ7620_currentGestureName[0] != '\0' ) { ResponseAppend_P(PSTR(",\"%s\":{\"%s\":%u}"), PAJ7620_name, PAJ7620_currentGestureName, PAJ7620_gesture.same); @@ -436,18 +428,23 @@ bool Xsns50(uint8_t function) bool result = false; - switch (function) { - case FUNC_COMMAND_SENSOR: - if (XSNS_50 == XdrvMailbox.index){ - result = PAJ7620CommandSensor(); - } - break; - case FUNC_EVERY_100_MSECOND: - PAJ7620Loop(); - break; - case FUNC_JSON_APPEND: - PAJ7620Show(1); - break; + if (FUNC_INIT == function) { + PAJ7620Detect(); + } + else if (PAJ7620_next_job) { + switch (function) { + case FUNC_COMMAND_SENSOR: + if (XSNS_50 == XdrvMailbox.index){ + result = PAJ7620CommandSensor(); + } + break; + case FUNC_EVERY_100_MSECOND: + PAJ7620Loop(); + break; + case FUNC_JSON_APPEND: + PAJ7620Show(1); + break; + } } return result; }