Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
6674a7d7
Commit
6674a7d7
authored
Nov 19, 2015
by
Marcel Stör
Browse files
Add reference to HX711 documentation to source
parent
c047d344
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/hx711.c
View file @
6674a7d7
// Module for HX711 load cell amplifier
// https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide
#include "lualib.h"
#include "lauxlib.h"
#include "platform.h"
...
...
@@ -32,7 +35,7 @@ static int ICACHE_FLASH_ATTR hx711_read(lua_State* L) {
//wakeup hx711
platform_gpio_write
(
clk_pin
,
0
);
//wait for data ready. or time out.
//TODO: set pin inturrupt and come back to it. This may take up to 1/10 sec
// or maybe just make an async version too and have both available.
...
...
@@ -40,7 +43,7 @@ static int ICACHE_FLASH_ATTR hx711_read(lua_State* L) {
for
(
i
=
0
;
i
<
HX711_MAX_WAIT
&&
platform_gpio_read
(
data_pin
)
==
1
;
i
++
){
asm
(
"nop"
);
}
//Handle timeout error
if
(
i
>=
HX711_MAX_WAIT
)
{
return
luaL_error
(
L
,
"ADC timeout!"
,
(
unsigned
)
0
);
...
...
@@ -54,14 +57,14 @@ static int ICACHE_FLASH_ATTR hx711_read(lua_State* L) {
data
=
i
==
0
?
-
1
:
data
|
1
;
//signextend the first bit
}
}
//add 25th clock pulse to prevent protocol error (probably not needed
//add 25th clock pulse to prevent protocol error (probably not needed
// since we'll go to sleep immediately after and reset on wakeup.)
platform_gpio_write
(
clk_pin
,
1
);
platform_gpio_write
(
clk_pin
,
0
);
//sleep
platform_gpio_write
(
clk_pin
,
1
);
lua_pushinteger
(
L
,
data
);
return
1
;
return
1
;
}
#define MIN_OPT_LEVEL 2
...
...
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