From d5bc687844948760526c3842cc4e355a253a1d5b Mon Sep 17 00:00:00 2001 From: Helge Date: Tue, 4 Oct 2022 07:43:34 +0200 Subject: [PATCH] Update xsns_33_qmc5883l.ino --- tasmota/tasmota_xsns_sensor/xsns_33_qmc5883l.ino | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tasmota/tasmota_xsns_sensor/xsns_33_qmc5883l.ino b/tasmota/tasmota_xsns_sensor/xsns_33_qmc5883l.ino index d3efaa80e..5f8878860 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_33_qmc5883l.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_33_qmc5883l.ino @@ -264,12 +264,15 @@ void QMC5883L_read_data(void) //QMC5883L.MY = Wire.read() | (Wire.read() << 8); //QMC5883L.MZ = Wire.read() | (Wire.read() << 8); - if (I2cValidReadS16(&QMC5883L.MX, QMC5883L.i2c_address, QMC5883L_X_LSB) == false) return; // read error, select LSB register - if (I2cValidReadS16(&QMC5883L.MY, QMC5883L.i2c_address, QMC5883L_Y_LSB) == false) return; // read error, select LSB register + int16_t x = 0; + int16_t y = 0; + + if (I2cValidReadS16(&x, QMC5883L.i2c_address, QMC5883L_X_LSB) == false) return; // read error, select LSB register + if (I2cValidReadS16(&y, QMC5883L.i2c_address, QMC5883L_Y_LSB) == false) return; // read error, select LSB register if (I2cValidReadS16(&QMC5883L.MZ, QMC5883L.i2c_address, QMC5883L_Z_LSB) == false) return; // read error, select LSB register - int16_t x = QMC5883L.MX; - int16_t y = QMC5883L.MY; + QMC5883L.MX = x; + QMC5883L.MY = y; // calculate azimut, heading if(x < QMC5883L.xlow) QMC5883L.xlow = x;