Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
92b6bad1
Commit
92b6bad1
authored
Oct 16, 2017
by
Suraj151
Committed by
Marcel Stör
Oct 15, 2017
Browse files
Swap reading y and z values (#2133)
As per hmc5883l datasheet 2nd and 3rd bytes are of z axis rather than y.
parent
2e67ff5a
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/hmc5883l.c
View file @
92b6bad1
...
@@ -44,7 +44,6 @@ static int hmc5883_setup(lua_State* L) {
...
@@ -44,7 +44,6 @@ static int hmc5883_setup(lua_State* L) {
if
((
devid_a
!=
0x48
)
||
(
devid_b
!=
0x34
)
||
(
devid_c
!=
0x33
))
{
if
((
devid_a
!=
0x48
)
||
(
devid_b
!=
0x34
)
||
(
devid_c
!=
0x33
))
{
return
luaL_error
(
L
,
"device not found"
);
return
luaL_error
(
L
,
"device not found"
);
}
}
// 8 sample average, 15 Hz update rate, normal measurement
// 8 sample average, 15 Hz update rate, normal measurement
w8u
(
hmc5883_i2c_id
,
0x00
,
0x70
);
w8u
(
hmc5883_i2c_id
,
0x00
,
0x70
);
...
@@ -58,7 +57,6 @@ static int hmc5883_setup(lua_State* L) {
...
@@ -58,7 +57,6 @@ static int hmc5883_setup(lua_State* L) {
}
}
static
int
hmc5883_init
(
lua_State
*
L
)
{
static
int
hmc5883_init
(
lua_State
*
L
)
{
uint32_t
sda
;
uint32_t
sda
;
uint32_t
scl
;
uint32_t
scl
;
...
@@ -96,8 +94,8 @@ static int hmc5883_read(lua_State* L) {
...
@@ -96,8 +94,8 @@ static int hmc5883_read(lua_State* L) {
platform_i2c_send_stop
(
hmc5883_i2c_id
);
platform_i2c_send_stop
(
hmc5883_i2c_id
);
x
=
(
int16_t
)
((
data
[
0
]
<<
8
)
|
data
[
1
]);
x
=
(
int16_t
)
((
data
[
0
]
<<
8
)
|
data
[
1
]);
y
=
(
int16_t
)
((
data
[
2
]
<<
8
)
|
data
[
3
]);
z
=
(
int16_t
)
((
data
[
2
]
<<
8
)
|
data
[
3
]);
z
=
(
int16_t
)
((
data
[
4
]
<<
8
)
|
data
[
5
]);
y
=
(
int16_t
)
((
data
[
4
]
<<
8
)
|
data
[
5
]);
lua_pushinteger
(
L
,
x
);
lua_pushinteger
(
L
,
x
);
lua_pushinteger
(
L
,
y
);
lua_pushinteger
(
L
,
y
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment