Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: QMC5883L.cpp
- Revision:
- 49:76fcaffb92ef
- Parent:
- 47:c74d09a252d4
diff -r 77009dca23a8 -r 76fcaffb92ef QMC5883L.cpp
--- a/QMC5883L.cpp Thu Jun 02 10:55:04 2022 +0200
+++ b/QMC5883L.cpp Thu Jun 02 09:42:26 2022 +0000
@@ -4,29 +4,29 @@
{
init();
}
-
+
void QMC5883L::readMag()
{
getMagValue(OUT_Y_LSB, OUT_Y_MSB, m_mag_val[0]); // x and y are swapped
getMagValue(OUT_X_LSB, OUT_X_MSB, m_mag_val[1]);
getMagValue(OUT_Z_LSB, OUT_Z_MSB, m_mag_val[2]);
}
-
+
float QMC5883L::magX()
{
return m_scale * static_cast<float>(m_mag_val[0]);
}
-
+
float QMC5883L::magY()
{
return m_scale * static_cast<float>(m_mag_val[1]);
}
-
+
float QMC5883L::magZ()
{
return m_scale * static_cast<float>(m_mag_val[2]);
}
-
+
void QMC5883L::init()
{
// 31.05.2022, based on experiment so it fits the former mag scaling (norm approx. 0.31)
@@ -70,7 +70,7 @@
}
}
}
-
+
bool QMC5883L::ReadByte(const uint8_t& reg, uint8_t& data)
{
static char data_out[1], data_in[1];
@@ -84,7 +84,7 @@
}
return !nack;
}
-
+
bool QMC5883L::WriteByte(const uint8_t& reg, const uint8_t& data)
{
static char data_out[2];
@@ -92,4 +92,4 @@
data_out[1] = data;
bool nack = i2c.write(QMC5883L_ADDRESS, data_out, 2, 0);
return !nack;
-}
+}
\ No newline at end of file