From 92b6bad1e429db389419be46bd608ea37829f123 Mon Sep 17 00:00:00 2001 From: Suraj151 <32166791+Suraj151@users.noreply.github.com> Date: Mon, 16 Oct 2017 01:47:53 +0530 Subject: [PATCH] Swap reading y and z values (#2133) As per hmc5883l datasheet 2nd and 3rd bytes are of z axis rather than y. --- app/modules/hmc5883l.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/modules/hmc5883l.c b/app/modules/hmc5883l.c index ec602966..f1f69982 100644 --- a/app/modules/hmc5883l.c +++ b/app/modules/hmc5883l.c @@ -44,7 +44,6 @@ static int hmc5883_setup(lua_State* L) { if ((devid_a != 0x48) || (devid_b != 0x34) || (devid_c != 0x33)) { return luaL_error(L, "device not found"); } - // 8 sample average, 15 Hz update rate, normal measurement w8u(hmc5883_i2c_id, 0x00, 0x70); @@ -58,7 +57,6 @@ static int hmc5883_setup(lua_State* L) { } static int hmc5883_init(lua_State* L) { - uint32_t sda; uint32_t scl; @@ -96,8 +94,8 @@ static int hmc5883_read(lua_State* L) { platform_i2c_send_stop(hmc5883_i2c_id); x = (int16_t) ((data[0] << 8) | data[1]); - y = (int16_t) ((data[2] << 8) | data[3]); - z = (int16_t) ((data[4] << 8) | data[5]); + z = (int16_t) ((data[2] << 8) | data[3]); + y = (int16_t) ((data[4] << 8) | data[5]); lua_pushinteger(L, x); lua_pushinteger(L, y);