From 9ab215b6fd152898eb4aa26d8e99b30d60412212 Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Wed, 19 Nov 2014 11:57:35 +0000 Subject: [PATCH] hmc5883l: use int16_t as coordinate type throughout Signed-off-by: Brendan Le Foll --- examples/hmc5883l.cxx | 2 +- src/hmc5883l/hmc5883l.cxx | 8 ++++---- src/hmc5883l/hmc5883l.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/hmc5883l.cxx b/examples/hmc5883l.cxx index 138b25ca..a06f06f9 100644 --- a/examples/hmc5883l.cxx +++ b/examples/hmc5883l.cxx @@ -31,7 +31,7 @@ main(int argc, char **argv) { //! [Interesting] upm::Hmc5883l* compass = new upm::Hmc5883l(0); - int *pos; + int16_t *pos; compass->set_declination(0.2749); // Set your declination from true north in radians diff --git a/src/hmc5883l/hmc5883l.cxx b/src/hmc5883l/hmc5883l.cxx index 5bb11c6a..153f638f 100644 --- a/src/hmc5883l/hmc5883l.cxx +++ b/src/hmc5883l/hmc5883l.cxx @@ -105,11 +105,11 @@ Hmc5883l::update(void) mraa_i2c_read(m_i2c, m_rx_tx_buf, DATA_REG_SIZE); // x - m_coor[0] = (int16_t)((m_rx_tx_buf[HMC5883L_X_MSB_REG] << 8 ) | m_rx_tx_buf[HMC5883L_X_LSB_REG]); + m_coor[0] = (m_rx_tx_buf[HMC5883L_X_MSB_REG] << 8 ) | m_rx_tx_buf[HMC5883L_X_LSB_REG]; // z - m_coor[2] = (int16_t)((m_rx_tx_buf[HMC5883L_Z_MSB_REG] << 8 ) | m_rx_tx_buf[HMC5883L_Z_LSB_REG]); + m_coor[2] = (m_rx_tx_buf[HMC5883L_Z_MSB_REG] << 8 ) | m_rx_tx_buf[HMC5883L_Z_LSB_REG]; // y - m_coor[1] = (int16_t)((m_rx_tx_buf[HMC5883L_Y_MSB_REG] << 8 ) | m_rx_tx_buf[HMC5883L_Y_LSB_REG]); + m_coor[1] = (m_rx_tx_buf[HMC5883L_Y_MSB_REG] << 8 ) | m_rx_tx_buf[HMC5883L_Y_LSB_REG]; return MRAA_SUCCESS; } @@ -130,7 +130,7 @@ Hmc5883l::heading(void) return dir; } -int* +int16_t* Hmc5883l::coordinates(void) { return &m_coor[0]; diff --git a/src/hmc5883l/hmc5883l.h b/src/hmc5883l/hmc5883l.h index fb604290..f04e6b29 100644 --- a/src/hmc5883l/hmc5883l.h +++ b/src/hmc5883l/hmc5883l.h @@ -72,7 +72,7 @@ public: * * @return *int to an int[3] */ - int* coordinates(); + int16_t* coordinates(); /** * Updates the values by reading from i2c @@ -93,7 +93,7 @@ public: */ float get_declination(); private: - int m_coor[3]; + int16_t m_coor[3]; float m_declination; uint8_t m_rx_tx_buf[MAX_BUFFER_LENGTH]; mraa_i2c_context m_i2c;