Skip to content

Commit

Permalink
Addition of gpio.pulse functions (nodemcu#2190)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjsg authored and marcelstoer committed Jan 10, 2018
1 parent dbd06c8 commit a9f41d7
Show file tree
Hide file tree
Showing 4 changed files with 611 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/include/user_modules.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#define LUA_USE_MODULES_FILE
//#define LUA_USE_MODULES_GDBSTUB
#define LUA_USE_MODULES_GPIO
//#define LUA_USE_MODULES_GPIO_PULSE
//#define LUA_USE_MODULES_HDC1080
//#define LUA_USE_MODULES_HMC5883L
//#define LUA_USE_MODULES_HTTP
Expand Down
11 changes: 11 additions & 0 deletions app/modules/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,20 @@ static int lgpio_serout( lua_State* L )
}
#undef DELAY_TABLE_MAX_LEN

#ifdef LUA_USE_MODULES_GPIO_PULSE
extern const LUA_REG_TYPE gpio_pulse_map[];
extern int gpio_pulse_init(lua_State *);
#endif

// Module function map
static const LUA_REG_TYPE gpio_map[] = {
{ LSTRKEY( "mode" ), LFUNCVAL( lgpio_mode ) },
{ LSTRKEY( "read" ), LFUNCVAL( lgpio_read ) },
{ LSTRKEY( "write" ), LFUNCVAL( lgpio_write ) },
{ LSTRKEY( "serout" ), LFUNCVAL( lgpio_serout ) },
#ifdef LUA_USE_MODULES_GPIO_PULSE
{ LSTRKEY( "pulse" ), LROVAL( gpio_pulse_map ) }, //declared in gpio_pulse.c
#endif
#ifdef GPIO_INTERRUPT_ENABLE
{ LSTRKEY( "trig" ), LFUNCVAL( lgpio_trig ) },
{ LSTRKEY( "INT" ), LNUMVAL( INTERRUPT ) },
Expand All @@ -336,6 +344,9 @@ static const LUA_REG_TYPE gpio_map[] = {
};

int luaopen_gpio( lua_State *L ) {
#ifdef LUA_USE_MODULES_GPIO_PULSE
gpio_pulse_init(L);
#endif
#ifdef GPIO_INTERRUPT_ENABLE
int i;
for(i=0;i<GPIO_PIN_NUM;i++){
Expand Down
Loading

0 comments on commit a9f41d7

Please sign in to comment.