diff --git a/tasmota/tasmota_xsns_sensor/xsns_33_qmc5883l.ino b/tasmota/tasmota_xsns_sensor/xsns_33_qmc5883l.ino index e64a3cc30..1122a389f 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_33_qmc5883l.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_33_qmc5883l.ino @@ -220,15 +220,12 @@ struct QMC5883L_s int16_t MX, MY, MZ; int16_t temp; uint16_t scalar; - bool ready; } *QMC5883L = nullptr; // Initialise the device void QMC5883L_Init() { - QMC5883L = (QMC5883L_s *)calloc(1, sizeof(struct QMC5883L_s)); - QMC5883L->ready = false; if (!I2cSetDevice(QMC5883L_ADDR)) { return; @@ -242,7 +239,7 @@ void QMC5883L_Init() // write config if (I2cWrite8(QMC5883L_ADDR, QMC5883L_CONFIG, QMC5883L_CONFIG_OS256 | QMC5883L_CONFIG_8GAUSS | QMC5883L_CONFIG_100HZ | QMC5883L_CONFIG_CONT) == false) return; - QMC5883L->ready = true; + QMC5883L = (QMC5883L_s *)calloc(1, sizeof(struct QMC5883L_s)); } //Read the magnetic data @@ -308,7 +305,7 @@ bool Xsns33(byte function) { QMC5883L_Init(); } - else if (QMC5883L->ready == true) + else if (QMC5883L != nullptr) { switch (function) {