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
1462d00e
Commit
1462d00e
authored
Dec 19, 2015
by
Terry Ellison
Browse files
Merge pull request #842 from jmattsson/module-ltr-cleanup
Cleanup: LTR module registration
parents
4708b2ac
9003d3e8
Changes
48
Show whitespace changes
Inline
Side-by-side
app/modules/u8g.c
View file @
1462d00e
// Module for U8glib
#include "
lualib
.h"
#include "
module
.h"
#include "lauxlib.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#include "c_stdlib.h"
...
...
@@ -1027,11 +1025,7 @@ U8G_DISPLAY_TABLE_SPI
// Module function map
#define MIN_OPT_LEVEL 2
#include "lrodefs.h"
static
const
LUA_REG_TYPE
lu8g_display_map
[]
=
{
static
const
LUA_REG_TYPE
lu8g_display_map
[]
=
{
{
LSTRKEY
(
"begin"
),
LFUNCVAL
(
lu8g_begin
)
},
{
LSTRKEY
(
"drawBitmap"
),
LFUNCVAL
(
lu8g_drawBitmap
)
},
{
LSTRKEY
(
"drawBox"
),
LFUNCVAL
(
lu8g_drawBox
)
},
...
...
@@ -1083,82 +1077,38 @@ static const LUA_REG_TYPE lu8g_display_map[] =
{
LSTRKEY
(
"undoRotation"
),
LFUNCVAL
(
lu8g_undoRotation
)
},
{
LSTRKEY
(
"undoScale"
),
LFUNCVAL
(
lu8g_undoScale
)
},
{
LSTRKEY
(
"__gc"
),
LFUNCVAL
(
lu8g_close_display
)
},
#if LUA_OPTIMIZE_MEMORY > 0
{
LSTRKEY
(
"__index"
),
LROVAL
(
lu8g_display_map
)
},
#endif
{
LSTRKEY
(
"__index"
),
LROVAL
(
lu8g_display_map
)
},
{
LNILKEY
,
LNILVAL
}
};
const
LUA_REG_TYPE
lu8g_map
[]
=
{
#undef U8G_DISPLAY_TABLE_ENTRY
#define U8G_DISPLAY_TABLE_ENTRY(device) { LSTRKEY( #device ), LFUNCVAL ( lu8g_ ##device ) },
#undef U8G_FONT_TABLE_ENTRY
static
const
LUA_REG_TYPE
lu8g_map
[]
=
{
#define U8G_DISPLAY_TABLE_ENTRY(device) \
{ LSTRKEY( #device ), LFUNCVAL ( lu8g_ ##device ) },
U8G_DISPLAY_TABLE_I2C
U8G_DISPLAY_TABLE_SPI
#if LUA_OPTIMIZE_MEMORY > 0
// Register fonts
#undef U8G_FONT_TABLE_ENTRY
#define U8G_FONT_TABLE_ENTRY(font) { LSTRKEY( #font ), LUDATA( (void *)(u8g_ ## font) ) },
// Register fonts
#define U8G_FONT_TABLE_ENTRY(font) \
{ LSTRKEY( #font ), LUDATA( (void *)(u8g_ ## font) ) },
U8G_FONT_TABLE
// Options for circle/ ellipse drawing
{
LSTRKEY
(
"DRAW_UPPER_RIGHT"
),
LNUMVAL
(
U8G_DRAW_UPPER_RIGHT
)
},
{
LSTRKEY
(
"DRAW_UPPER_LEFT"
),
LNUMVAL
(
U8G_DRAW_UPPER_LEFT
)
},
{
LSTRKEY
(
"DRAW_LOWER_RIGHT"
),
LNUMVAL
(
U8G_DRAW_LOWER_RIGHT
)
},
{
LSTRKEY
(
"DRAW_LOWER_LEFT"
),
LNUMVAL
(
U8G_DRAW_LOWER_LEFT
)
},
{
LSTRKEY
(
"DRAW_ALL"
),
LNUMVAL
(
U8G_DRAW_ALL
)
},
// Display modes
{
LSTRKEY
(
"MODE_BW"
),
LNUMVAL
(
U8G_MODE_BW
)
},
{
LSTRKEY
(
"MODE_GRAY2BIT"
),
LNUMVAL
(
U8G_MODE_GRAY2BIT
)
},
{
LSTRKEY
(
"__metatable"
),
LROVAL
(
lu8g_map
)
},
#endif
{
LNILKEY
,
LNILVAL
}
};
LUALIB_API
int
luaopen_u8g
(
lua_State
*
L
)
{
#if LUA_OPTIMIZE_MEMORY > 0
int
luaopen_u8g
(
lua_State
*
L
)
{
luaL_rometatable
(
L
,
"u8g.display"
,
(
void
*
)
lu8g_display_map
);
// create metatable
return
0
;
#else // #if LUA_OPTIMIZE_MEMORY > 0
int
n
;
luaL_register
(
L
,
AUXLIB_U8G
,
lu8g_map
);
// Set it as its own metatable
lua_pushvalue
(
L
,
-
1
);
lua_setmetatable
(
L
,
-
2
);
// Module constants
// Register fonts
#undef U8G_FONT_TABLE_ENTRY
#define U8G_FONT_TABLE_ENTRY(font) MOD_REG_LUDATA( L, #font, (void *)(u8g_ ## font) );
U8G_FONT_TABLE
// Options for circle/ ellipse drawing
MOD_REG_NUMBER
(
L
,
"DRAW_UPPER_RIGHT"
,
U8G_DRAW_UPPER_RIGHT
);
MOD_REG_NUMBER
(
L
,
"DRAW_UPPER_LEFT"
,
U8G_DRAW_UPPER_LEFT
);
MOD_REG_NUMBER
(
L
,
"DRAW_LOWER_RIGHT"
,
U8G_DRAW_LOWER_RIGHT
);
MOD_REG_NUMBER
(
L
,
"DRAW_LOWER_LEFT"
,
U8G_DRAW_LOWER_LEFT
);
MOD_REG_NUMBER
(
L
,
"DRAW_ALL"
,
U8G_DRAW_ALL
);
// Display modes
MOD_REG_NUMBER
(
L
,
"MODE_BW"
,
U8G_MODE_BW
);
MOD_REG_NUMBER
(
L
,
"MODE_GRAY2BIT"
,
U8G_MODE_GRAY2BIT
);
// create metatable
luaL_newmetatable
(
L
,
"u8g.display"
);
// metatable.__index = metatable
lua_pushliteral
(
L
,
"__index"
);
lua_pushvalue
(
L
,
-
2
);
lua_rawset
(
L
,
-
3
);
// Setup the methods inside metatable
luaL_register
(
L
,
NULL
,
u8g_display_map
);
return
1
;
#endif // #if LUA_OPTIMIZE_MEMORY > 0
}
NODEMCU_MODULE
(
U8G
,
"u8g"
,
lu8g_map
,
luaopen_u8g
);
app/modules/uart.c
View file @
1462d00e
// Module for interfacing with serial
//#include "lua.h"
#include "lualib.h"
#include "module.h"
#include "lauxlib.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#include "c_types.h"
#include "c_string.h"
...
...
@@ -158,29 +155,12 @@ static int uart_write( lua_State* L )
}
// Module function map
#define MIN_OPT_LEVEL 2
#include "lrodefs.h"
const
LUA_REG_TYPE
uart_map
[]
=
{
static
const
LUA_REG_TYPE
uart_map
[]
=
{
{
LSTRKEY
(
"setup"
),
LFUNCVAL
(
uart_setup
)
},
{
LSTRKEY
(
"write"
),
LFUNCVAL
(
uart_write
)
},
{
LSTRKEY
(
"on"
),
LFUNCVAL
(
uart_on
)
},
{
LSTRKEY
(
"alt"
),
LFUNCVAL
(
uart_alt
)
},
#if LUA_OPTIMIZE_MEMORY > 0
#endif
{
LNILKEY
,
LNILVAL
}
};
LUALIB_API
int
luaopen_uart
(
lua_State
*
L
)
{
#if LUA_OPTIMIZE_MEMORY > 0
return
0
;
#else // #if LUA_OPTIMIZE_MEMORY > 0
luaL_register
(
L
,
AUXLIB_UART
,
uart_map
);
// Add constants
return
1
;
#endif // #if LUA_OPTIMIZE_MEMORY > 0
}
NODEMCU_MODULE
(
UART
,
"uart"
,
uart_map
,
NULL
);
app/modules/ucg.c
View file @
1462d00e
// Module for Ucglib
#include "
lualib
.h"
#include "
module
.h"
#include "lauxlib.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#include "c_stdlib.h"
...
...
@@ -876,9 +874,6 @@ UCG_DISPLAY_TABLE
// Module function map
#define MIN_OPT_LEVEL 2
#include "lrodefs.h"
static
const
LUA_REG_TYPE
lucg_display_map
[]
=
{
{
LSTRKEY
(
"begin"
),
LFUNCVAL
(
lucg_begin
)
},
...
...
@@ -926,20 +921,16 @@ static const LUA_REG_TYPE lucg_display_map[] =
{
LSTRKEY
(
"undoScale"
),
LFUNCVAL
(
lucg_undoScale
)
},
{
LSTRKEY
(
"__gc"
),
LFUNCVAL
(
lucg_close_display
)
},
#if LUA_OPTIMIZE_MEMORY > 0
{
LSTRKEY
(
"__index"
),
LROVAL
(
lucg_display_map
)
},
#endif
{
LNILKEY
,
LNILVAL
}
};
const
LUA_REG_TYPE
lucg_map
[]
=
static
const
LUA_REG_TYPE
lucg_map
[]
=
{
#undef UCG_DISPLAY_TABLE_ENTRY
#define UCG_DISPLAY_TABLE_ENTRY(binding, device, extension) { LSTRKEY( #binding ), LFUNCVAL ( lucg_ ##binding ) },
UCG_DISPLAY_TABLE
#if LUA_OPTIMIZE_MEMORY > 0
// Register fonts
#undef UCG_FONT_TABLE_ENTRY
#define UCG_FONT_TABLE_ENTRY(font) { LSTRKEY( #font ), LUDATA( (void *)(ucg_ ## font) ) },
...
...
@@ -957,50 +948,13 @@ const LUA_REG_TYPE lucg_map[] =
{
LSTRKEY
(
"DRAW_ALL"
),
LNUMVAL
(
UCG_DRAW_ALL
)
},
{
LSTRKEY
(
"__metatable"
),
LROVAL
(
lucg_map
)
},
#endif
{
LNILKEY
,
LNILVAL
}
};
LUALIB_API
int
luaopen_ucg
(
lua_State
*
L
)
int
luaopen_ucg
(
lua_State
*
L
)
{
#if LUA_OPTIMIZE_MEMORY > 0
luaL_rometatable
(
L
,
"ucg.display"
,
(
void
*
)
lucg_display_map
);
// create metatable
return
0
;
#else // #if LUA_OPTIMIZE_MEMORY > 0
int
n
;
luaL_register
(
L
,
AUXLIB_UCG
,
lucg_map
);
// Set it as its own metatable
lua_pushvalue
(
L
,
-
1
);
lua_setmetatable
(
L
,
-
2
);
// Module constants
// Register fonts
#undef UCG_FONT_TABLE_ENTRY
#define UCG_FONT_TABLE_ENTRY(font) MOD_REG_LUDATA( L, #font, (void *)(ucg_ ## font) );
UCG_FONT_TABLE
// Font modes
MOD_REG_NUMBER
(
L
,
"FONT_MODE_TRANSPARENT"
,
UCG_FONT_MODE_TRANSPARENT
);
MOD_REG_NUMBER
(
L
,
"FONT_MODE_SOLID"
,
UCG_FONT_MODE_SOLID
);
// Options for circle/ disc drawing
MOD_REG_NUMBER
(
L
,
"DRAW_UPPER_RIGHT"
,
UCG_DRAW_UPPER_RIGHT
);
MOD_REG_NUMBER
(
L
,
"DRAW_UPPER_LEFT"
,
UCG_DRAW_UPPER_LEFT
);
MOD_REG_NUMBER
(
L
,
"DRAW_LOWER_RIGHT"
,
UCG_DRAW_LOWER_RIGHT
);
MOD_REG_NUMBER
(
L
,
"DRAW_LOWER_LEFT"
,
UCG_DRAW_LOWER_LEFT
);
MOD_REG_NUMBER
(
L
,
"DRAW_ALL"
,
UCG_DRAW_ALL
);
// create metatable
luaL_newmetatable
(
L
,
"ucg.display"
);
// metatable.__index = metatable
lua_pushliteral
(
L
,
"__index"
);
lua_pushvalue
(
L
,
-
2
);
lua_rawset
(
L
,
-
3
);
// Setup the methods inside metatable
luaL_register
(
L
,
NULL
,
lucg_display_map
);
return
1
;
#endif // #if LUA_OPTIMIZE_MEMORY > 0
}
NODEMCU_MODULE
(
UCG
,
"ucg"
,
lucg_map
,
luaopen_ucg
);
app/modules/wifi.c
View file @
1462d00e
// Module for interfacing with WIFI
//#include "lua.h"
#include "lualib.h"
#include "module.h"
#include "lauxlib.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#include "c_string.h"
#include "c_stdlib.h"
...
...
@@ -1340,56 +1337,47 @@ static int wifi_ap_dhcp_stop( lua_State* L )
}
// Module function map
#define MIN_OPT_LEVEL 2
#include "lrodefs.h"
static
const
LUA_REG_TYPE
wifi_station_map
[]
=
{
{
LSTRKEY
(
"getconfig"
),
LFUNCVAL
(
wifi_station_getconfig
)
},
{
LSTRKEY
(
"config"
),
LFUNCVAL
(
wifi_station_config
)
},
{
LSTRKEY
(
"connect"
),
LFUNCVAL
(
wifi_station_connect4lua
)
},
{
LSTRKEY
(
"disconnect"
),
LFUNCVAL
(
wifi_station_disconnect4lua
)
},
{
LSTRKEY
(
"autoconnect"
),
LFUNCVAL
(
wifi_station_setauto
)
},
{
LSTRKEY
(
"getip"
),
LFUNCVAL
(
wifi_station_getip
)
},
{
LSTRKEY
(
"setip"
),
LFUNCVAL
(
wifi_station_setip
)
},
{
LSTRKEY
(
"getbroadcast"
),
LFUNCVAL
(
wifi_station_getbroadcast
)
},
{
LSTRKEY
(
"getmac"
),
LFUNCVAL
(
wifi_station_getmac
)
},
{
LSTRKEY
(
"setmac"
),
LFUNCVAL
(
wifi_station_setmac
)
},
{
LSTRKEY
(
"getap"
),
LFUNCVAL
(
wifi_station_listap
)
},
{
LSTRKEY
(
"status"
),
LFUNCVAL
(
wifi_station_status
)
},
{
LSTRKEY
(
"eventMonReg"
),
LFUNCVAL
(
wifi_station_event_mon_reg
)
},
{
LSTRKEY
(
"eventMonStart"
),
LFUNCVAL
(
wifi_station_event_mon_start
)
},
{
LSTRKEY
(
"eventMonStop"
),
LFUNCVAL
(
wifi_station_event_mon_stop
)
},
static
const
LUA_REG_TYPE
wifi_station_map
[]
=
{
{
LSTRKEY
(
"getconfig"
),
LFUNCVAL
(
wifi_station_getconfig
)
},
{
LSTRKEY
(
"config"
),
LFUNCVAL
(
wifi_station_config
)
},
{
LSTRKEY
(
"connect"
),
LFUNCVAL
(
wifi_station_connect4lua
)
},
{
LSTRKEY
(
"disconnect"
),
LFUNCVAL
(
wifi_station_disconnect4lua
)
},
{
LSTRKEY
(
"autoconnect"
),
LFUNCVAL
(
wifi_station_setauto
)
},
{
LSTRKEY
(
"getip"
),
LFUNCVAL
(
wifi_station_getip
)
},
{
LSTRKEY
(
"setip"
),
LFUNCVAL
(
wifi_station_setip
)
},
{
LSTRKEY
(
"getbroadcast"
),
LFUNCVAL
(
wifi_station_getbroadcast
)
},
{
LSTRKEY
(
"getmac"
),
LFUNCVAL
(
wifi_station_getmac
)
},
{
LSTRKEY
(
"setmac"
),
LFUNCVAL
(
wifi_station_setmac
)
},
{
LSTRKEY
(
"getap"
),
LFUNCVAL
(
wifi_station_listap
)
},
{
LSTRKEY
(
"status"
),
LFUNCVAL
(
wifi_station_status
)
},
{
LSTRKEY
(
"eventMonReg"
),
LFUNCVAL
(
wifi_station_event_mon_reg
)
},
{
LSTRKEY
(
"eventMonStart"
),
LFUNCVAL
(
wifi_station_event_mon_start
)
},
{
LSTRKEY
(
"eventMonStop"
),
LFUNCVAL
(
wifi_station_event_mon_stop
)
},
{
LNILKEY
,
LNILVAL
}
};
static
const
LUA_REG_TYPE
wifi_ap_dhcp_map
[]
=
{
static
const
LUA_REG_TYPE
wifi_ap_dhcp_map
[]
=
{
{
LSTRKEY
(
"config"
),
LFUNCVAL
(
wifi_ap_dhcp_config
)
},
{
LSTRKEY
(
"start"
),
LFUNCVAL
(
wifi_ap_dhcp_start
)
},
{
LSTRKEY
(
"stop"
),
LFUNCVAL
(
wifi_ap_dhcp_stop
)
},
{
LNILKEY
,
LNILVAL
}
};
static
const
LUA_REG_TYPE
wifi_ap_map
[]
=
{
static
const
LUA_REG_TYPE
wifi_ap_map
[]
=
{
{
LSTRKEY
(
"config"
),
LFUNCVAL
(
wifi_ap_config
)
},
{
LSTRKEY
(
"getip"
),
LFUNCVAL
(
wifi_ap_getip
)
},
{
LSTRKEY
(
"setip"
),
LFUNCVAL
(
wifi_ap_setip
)
},
{
LSTRKEY
(
"getbroadcast"
),
LFUNCVAL
(
wifi_ap_getbroadcast
)
},
{
LSTRKEY
(
"getmac"
),
LFUNCVAL
(
wifi_ap_getmac
)
},
{
LSTRKEY
(
"setmac"
),
LFUNCVAL
(
wifi_ap_setmac
)
},
{
LSTRKEY
(
"getclient"
),
LFUNCVAL
(
wifi_ap_listclient
)
},
{
LSTRKEY
(
"getip"
),
LFUNCVAL
(
wifi_ap_getip
)
},
{
LSTRKEY
(
"setip"
),
LFUNCVAL
(
wifi_ap_setip
)
},
{
LSTRKEY
(
"getbroadcast"
),
LFUNCVAL
(
wifi_ap_getbroadcast
)
},
{
LSTRKEY
(
"getmac"
),
LFUNCVAL
(
wifi_ap_getmac
)
},
{
LSTRKEY
(
"setmac"
),
LFUNCVAL
(
wifi_ap_setmac
)
},
{
LSTRKEY
(
"getclient"
),
LFUNCVAL
(
wifi_ap_listclient
)
},
{
LSTRKEY
(
"getconfig"
),
LFUNCVAL
(
wifi_ap_getconfig
)
},
#if LUA_OPTIMIZE_MEMORY > 0
{
LSTRKEY
(
"dhcp"
),
LROVAL
(
wifi_ap_dhcp_map
)
},
// { LSTRKEY( "__metatable" ), LROVAL( wifi_ap_map ) },
#endif
//{ LSTRKEY( "__metatable" ), LROVAL( wifi_ap_map ) },
{
LNILKEY
,
LNILVAL
}
};
const
LUA_REG_TYPE
wifi_map
[]
=
{
static
const
LUA_REG_TYPE
wifi_map
[]
=
{
{
LSTRKEY
(
"setmode"
),
LFUNCVAL
(
wifi_setmode
)
},
{
LSTRKEY
(
"getmode"
),
LFUNCVAL
(
wifi_getmode
)
},
{
LSTRKEY
(
"getchannel"
),
LFUNCVAL
(
wifi_getchannel
)
},
...
...
@@ -1399,7 +1387,7 @@ const LUA_REG_TYPE wifi_map[] =
{
LSTRKEY
(
"startsmart"
),
LFUNCVAL
(
wifi_start_smart
)
},
{
LSTRKEY
(
"stopsmart"
),
LFUNCVAL
(
wifi_exit_smart
)
},
{
LSTRKEY
(
"sleeptype"
),
LFUNCVAL
(
wifi_sleeptype
)
},
#if LUA_OPTIMIZE_MEMORY > 0
{
LSTRKEY
(
"sta"
),
LROVAL
(
wifi_station_map
)
},
{
LSTRKEY
(
"ap"
),
LROVAL
(
wifi_ap_map
)
},
...
...
@@ -1417,7 +1405,7 @@ const LUA_REG_TYPE wifi_map[] =
{
LSTRKEY
(
"MODEM_SLEEP"
),
LNUMVAL
(
MODEM_SLEEP_T
)
},
{
LSTRKEY
(
"OPEN"
),
LNUMVAL
(
AUTH_OPEN
)
},
//
{ LSTRKEY( "WEP" ), LNUMVAL( AUTH_WEP ) },
//{ LSTRKEY( "WEP" ),
LNUMVAL( AUTH_WEP ) },
{
LSTRKEY
(
"WPA_PSK"
),
LNUMVAL
(
AUTH_WPA_PSK
)
},
{
LSTRKEY
(
"WPA2_PSK"
),
LNUMVAL
(
AUTH_WPA2_PSK
)
},
{
LSTRKEY
(
"WPA_WPA2_PSK"
),
LNUMVAL
(
AUTH_WPA_WPA2_PSK
)
},
...
...
@@ -1430,58 +1418,7 @@ const LUA_REG_TYPE wifi_map[] =
{
LSTRKEY
(
"STA_GOTIP"
),
LNUMVAL
(
STATION_GOT_IP
)
},
{
LSTRKEY
(
"__metatable"
),
LROVAL
(
wifi_map
)
},
#endif
{
LNILKEY
,
LNILVAL
}
};
LUALIB_API
int
luaopen_wifi
(
lua_State
*
L
)
{
#if LUA_OPTIMIZE_MEMORY > 0
return
0
;
#else // #if LUA_OPTIMIZE_MEMORY > 0
luaL_register
(
L
,
AUXLIB_WIFI
,
wifi_map
);
// Set it as its own metatable
lua_pushvalue
(
L
,
-
1
);
lua_setmetatable
(
L
,
-
2
);
// Module constants
// MOD_REG_NUMBER( L, "NULLMODE", NULL_MODE );
MOD_REG_NUMBER
(
L
,
"STATION"
,
STATION_MODE
);
MOD_REG_NUMBER
(
L
,
"SOFTAP"
,
SOFTAP_MODE
);
MOD_REG_NUMBER
(
L
,
"STATIONAP"
,
STATIONAP_MODE
);
MOD_REG_NUMBER
(
L
,
"NONE_SLEEP"
,
NONE_SLEEP_T
);
MOD_REG_NUMBER
(
L
,
"LIGHT_SLEEP"
,
LIGHT_SLEEP_T
);
MOD_REG_NUMBER
(
L
,
"MODEM_SLEEP"
,
MODEM_SLEEP_T
);
MOD_REG_NUMBER
(
L
,
"OPEN"
,
AUTH_OPEN
);
// MOD_REG_NUMBER( L, "WEP", AUTH_WEP );
MOD_REG_NUMBER
(
L
,
"WPA_PSK"
,
AUTH_WPA_PSK
);
MOD_REG_NUMBER
(
L
,
"WPA2_PSK"
,
AUTH_WPA2_PSK
);
MOD_REG_NUMBER
(
L
,
"WPA_WPA2_PSK"
,
AUTH_WPA_WPA2_PSK
);
// MOD_REG_NUMBER( L, "STA_IDLE", STATION_IDLE );
// MOD_REG_NUMBER( L, "STA_CONNECTING", STATION_CONNECTING );
// MOD_REG_NUMBER( L, "STA_WRONGPWD", STATION_WRONG_PASSWORD );
// MOD_REG_NUMBER( L, "STA_APNOTFOUND", STATION_NO_AP_FOUND );
// MOD_REG_NUMBER( L, "STA_FAIL", STATION_CONNECT_FAIL );
// MOD_REG_NUMBER( L, "STA_GOTIP", STATION_GOT_IP );
// Setup the new tables (station and ap) inside wifi
lua_newtable
(
L
);
luaL_register
(
L
,
NULL
,
wifi_station_map
);
lua_setfield
(
L
,
-
2
,
"sta"
);
lua_newtable
(
L
);
luaL_register
(
L
,
NULL
,
wifi_ap_map
);
lua_setfield
(
L
,
-
2
,
"ap"
);
// Setup the new table (dhcp) inside ap
lua_newtable
(
L
);
luaL_register
(
L
,
NULL
,
wifi_ap_dhcp_map
);
lua_setfield
(
L
,
-
1
,
"dhcp"
);
return
1
;
#endif // #if LUA_OPTIMIZE_MEMORY > 0
}
NODEMCU_MODULE
(
WIFI
,
"wifi"
,
wifi_map
,
NULL
);
app/modules/ws2801.c
View file @
1462d00e
#include "
lualib
.h"
#include "
module
.h"
#include "lauxlib.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#include "c_stdlib.h"
#include "c_string.h"
...
...
@@ -124,17 +122,11 @@ static int ICACHE_FLASH_ATTR ws2801_writergb(lua_State* L) {
return
0
;
}
#define MIN_OPT_LEVEL 2
#include "lrodefs.h"
const
LUA_REG_TYPE
ws2801_map
[]
=
static
const
LUA_REG_TYPE
ws2801_map
[]
=
{
{
LSTRKEY
(
"write"
),
LFUNCVAL
(
ws2801_writergb
)},
{
LSTRKEY
(
"init"
),
LFUNCVAL
(
ws2801_init_lua
)},
{
LNILKEY
,
LNILVAL
}
};
LUALIB_API
int
luaopen_ws2801
(
lua_State
*
L
)
{
LREGISTER
(
L
,
"ws2801"
,
ws2801_map
);
return
1
;
}
NODEMCU_MODULE
(
WS2801
,
"ws2801"
,
ws2801_map
,
NULL
);
app/modules/ws2812.c
View file @
1462d00e
#include "
lualib
.h"
#include "
module
.h"
#include "lauxlib.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#include "c_stdlib.h"
#include "c_string.h"
#include "user_interface.h"
...
...
@@ -127,17 +125,16 @@ static int ICACHE_FLASH_ATTR ws2812_writegrb(lua_State* L) {
return
0
;
}
#define MIN_OPT_LEVEL 2
#include "lrodefs.h"
const
LUA_REG_TYPE
ws2812_map
[]
=
static
const
LUA_REG_TYPE
ws2812_map
[]
=
{
{
LSTRKEY
(
"writergb"
),
LFUNCVAL
(
ws2812_writergb
)},
{
LSTRKEY
(
"write"
),
LFUNCVAL
(
ws2812_writegrb
)},
{
LNILKEY
,
LNILVAL
}
};
LUALIB_API
int
luaopen_ws2812
(
lua_State
*
L
)
{
int
luaopen_ws2812
(
lua_State
*
L
)
{
// TODO: Make sure that the GPIO system is initialized
LREGISTER
(
L
,
"ws2812"
,
ws2812_map
);
return
1
;
return
0
;
}
NODEMCU_MODULE
(
WS2812
,
"ws2812"
,
ws2812_map
,
luaopen_ws2812
);
app/platform/platform.h
View file @
1462d00e
...
...
@@ -253,4 +253,20 @@ uint32_t platform_flash_mapped2phys (uint32_t mapped_addr);
void
*
platform_get_first_free_ram
(
unsigned
id
);
void
*
platform_get_last_free_ram
(
unsigned
id
);
// *****************************************************************************
// Helper macros
#define MOD_CHECK_ID( mod, id )\
if( !platform_ ## mod ## _exists( id ) )\
return luaL_error( L, #mod" %d does not exist", ( unsigned )id )
#define MOD_CHECK_TIMER( id )\
if( id == PLATFORM_TIMER_SYS_ID && !platform_timer_sys_available() )\
return luaL_error( L, "the system timer is not available on this platform" );\
if( !platform_timer_exists( id ) )\
return luaL_error( L, "timer %d does not exist", ( unsigned )id )\
#define MOD_CHECK_RES_ID( mod, id, resmod, resid )\
if( !platform_ ## mod ## _check_ ## resmod ## _id( id, resid ) )\
return luaL_error( L, #resmod" %d not valid with " #mod " %d", ( unsigned )resid, ( unsigned )id )
#endif
ld/nodemcu.ld
View file @
1462d00e
...
...
@@ -79,6 +79,16 @@ SECTIONS
*(.rodata*)
*(.sdk.version)
/* Link-time arrays containing the defs for the included modules */
. = ALIGN(4);
lua_libs = ABSOLUTE(.);
/* Allow either empty define or defined-to-1 to include the module */
KEEP(*(.lua_libs))
LONG(0) LONG(0) /* Null-terminate the array */
lua_rotable = ABSOLUTE(.);
KEEP(*(.lua_rotable))
LONG(0) LONG(0) /* Null-terminate the array */
/* These are *only* pulled in by Lua, and therefore safe to put in flash */
*/libc.a:lib_a-isalnum.o(.text* .literal*)
*/libc.a:lib_a-isalpha.o(.text* .literal*)
...
...
Prev
1
2
3
Next
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