Major cleanup of module registration pass 2.
carrying on Johny's edits as per my comments on #810
This commit is contained in:
parent
6b6456be47
commit
b773290b8c
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "auxmods.h"
|
|
||||||
#include "lrodefs.h"
|
#include "lrodefs.h"
|
||||||
|
|
||||||
#include "c_types.h"
|
#include "c_types.h"
|
||||||
|
@ -26,14 +25,16 @@ static int adc_readvdd33( lua_State* L )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
const LUA_REG_TYPE adc_map[] =
|
const LUA_REG_TYPE adc_map[] = {
|
||||||
{
|
{ LSTRKEY( "read" ), LFUNCVAL( adc_sample ) },
|
||||||
{ LSTRKEY( "read" ), LFUNCVAL( adc_sample ) },
|
|
||||||
{ LSTRKEY( "readvdd33" ), LFUNCVAL( adc_readvdd33) },
|
{ LSTRKEY( "readvdd33" ), LFUNCVAL( adc_readvdd33) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_adc( lua_State *L )
|
LUALIB_API int luaopen_adc( lua_State *L ) {
|
||||||
{
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
// Auxiliary Lua modules. All of them are declared here, then each platform
|
|
||||||
// decides what module(s) to register in the src/platform/xxxxx/platform_conf.h file
|
|
||||||
// FIXME: no longer platform_conf.h - either CPU header file, or board file
|
|
||||||
|
|
||||||
#ifndef __AUXMODS_H__
|
|
||||||
#define __AUXMODS_H__
|
|
||||||
|
|
||||||
// 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
|
|
|
@ -136,5 +136,9 @@ const LUA_REG_TYPE bit_map[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_bit (lua_State *L) {
|
LUALIB_API int luaopen_bit (lua_State *L) {
|
||||||
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,16 +183,18 @@ static int ICACHE_FLASH_ATTR bmp085_lua_pressure(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LUA_REG_TYPE bmp085_map[] =
|
const LUA_REG_TYPE bmp085_map[] = {
|
||||||
{
|
{ LSTRKEY( "temperature" ), LFUNCVAL( bmp085_lua_temperature )},
|
||||||
{ LSTRKEY( "temperature" ), LFUNCVAL( bmp085_lua_temperature )},
|
{ LSTRKEY( "pressure" ), LFUNCVAL( bmp085_lua_pressure )},
|
||||||
{ LSTRKEY( "pressure" ), LFUNCVAL( bmp085_lua_pressure )},
|
|
||||||
{ LSTRKEY( "pressure_raw" ), LFUNCVAL( bmp085_lua_pressure_raw )},
|
{ LSTRKEY( "pressure_raw" ), LFUNCVAL( bmp085_lua_pressure_raw )},
|
||||||
{ LSTRKEY( "init" ), LFUNCVAL( bmp085_init )},
|
{ LSTRKEY( "init" ), LFUNCVAL( bmp085_init )},
|
||||||
{ LNILKEY, LNILVAL}
|
{ LNILKEY, LNILVAL}
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_bmp085(lua_State *L) {
|
LUALIB_API int luaopen_bmp085(lua_State *L) {
|
||||||
return 0;
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1528,37 +1528,7 @@ static int json_protect_conversion(lua_State *l)
|
||||||
* errors are memory related */
|
* errors are memory related */
|
||||||
return luaL_error(l, "Memory allocation error in CJSON protected call");
|
return luaL_error(l, "Memory allocation error in CJSON protected call");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Module function map
|
|
||||||
const LUA_REG_TYPE cjson_map[] =
|
|
||||||
{
|
|
||||||
{ LSTRKEY( "encode" ), LFUNCVAL( json_encode ) },
|
|
||||||
{ LSTRKEY( "decode" ), LFUNCVAL( json_decode ) },
|
|
||||||
// { LSTRKEY( "encode_sparse_array" ), LFUNCVAL( json_cfg_encode_sparse_array ) },
|
|
||||||
// { LSTRKEY( "encode_max_depth" ), LFUNCVAL( json_cfg_encode_max_depth ) },
|
|
||||||
// { LSTRKEY( "decode_max_depth" ), LFUNCVAL( json_cfg_decode_max_depth ) },
|
|
||||||
// { LSTRKEY( "encode_number_precision" ), LFUNCVAL( json_cfg_encode_number_precision ) },
|
|
||||||
// { LSTRKEY( "encode_keep_buffer" ), LFUNCVAL( json_cfg_encode_keep_buffer ) },
|
|
||||||
// { LSTRKEY( "encode_invalid_numbers" ), LFUNCVAL( json_cfg_encode_invalid_numbers ) },
|
|
||||||
// { LSTRKEY( "decode_invalid_numbers" ), LFUNCVAL( json_cfg_decode_invalid_numbers ) },
|
|
||||||
// { LSTRKEY( "new" ), LFUNCVAL( lua_cjson_new ) },
|
|
||||||
{ LNILKEY, LNILVAL }
|
|
||||||
};
|
|
||||||
|
|
||||||
LUALIB_API int luaopen_cjson( lua_State *L )
|
|
||||||
{
|
|
||||||
cjson_mem_setlua (L);
|
|
||||||
|
|
||||||
/* Initialise number conversions */
|
|
||||||
// fpconv_init(); // not needed for a specific cpu.
|
|
||||||
if(-1==cfg_init(&_cfg)){
|
|
||||||
return luaL_error(L, "BUG: Unable to init config for cjson");;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Return cjson module table */
|
/* Return cjson module table */
|
||||||
static int lua_cjson_new(lua_State *l)
|
static int lua_cjson_new(lua_State *l)
|
||||||
{
|
{
|
||||||
|
@ -1628,5 +1598,36 @@ int luaopen_cjson_safe(lua_State *l)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Module function map
|
||||||
|
const LUA_REG_TYPE cjson_map[] = {
|
||||||
|
{ LSTRKEY( "encode" ), LFUNCVAL( json_encode ) },
|
||||||
|
{ LSTRKEY( "decode" ), LFUNCVAL( json_decode ) },
|
||||||
|
//{ LSTRKEY( "encode_sparse_array" ), LFUNCVAL( json_cfg_encode_sparse_array ) },
|
||||||
|
//{ LSTRKEY( "encode_max_depth" ), LFUNCVAL( json_cfg_encode_max_depth ) },
|
||||||
|
//{ LSTRKEY( "decode_max_depth" ), LFUNCVAL( json_cfg_decode_max_depth ) },
|
||||||
|
//{ LSTRKEY( "encode_number_precision" ), LFUNCVAL( json_cfg_encode_number_precision ) },
|
||||||
|
//{ LSTRKEY( "encode_keep_buffer" ), LFUNCVAL( json_cfg_encode_keep_buffer ) },
|
||||||
|
//{ LSTRKEY( "encode_invalid_numbers" ), LFUNCVAL( json_cfg_encode_invalid_numbers ) },
|
||||||
|
//{ LSTRKEY( "decode_invalid_numbers" ), LFUNCVAL( json_cfg_decode_invalid_numbers ) },
|
||||||
|
//{ LSTRKEY( "new" ), LFUNCVAL( lua_cjson_new ) },
|
||||||
|
{ LNILKEY, LNILVAL }
|
||||||
|
};
|
||||||
|
|
||||||
|
LUALIB_API int luaopen_cjson( lua_State *L )
|
||||||
|
{
|
||||||
|
cjson_mem_setlua (L);
|
||||||
|
|
||||||
|
/* Initialise number conversions */
|
||||||
|
// fpconv_init(); // not needed for a specific cpu.
|
||||||
|
if(-1==cfg_init(&_cfg)){
|
||||||
|
return luaL_error(L, "BUG: Unable to init config for cjson");;
|
||||||
|
}
|
||||||
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
|
}
|
||||||
/* vi:ai et sw=4 ts=4:
|
/* vi:ai et sw=4 ts=4:
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -558,41 +558,38 @@ static int coap_client_delete( lua_State* L )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
static const LUA_REG_TYPE coap_server_map[] =
|
static const LUA_REG_TYPE coap_server_map[] = {
|
||||||
{
|
{ LSTRKEY( "listen" ), LFUNCVAL( coap_server_listen ) },
|
||||||
{ LSTRKEY( "listen" ), LFUNCVAL ( coap_server_listen ) },
|
{ LSTRKEY( "close" ), LFUNCVAL( coap_server_close ) },
|
||||||
{ LSTRKEY( "close" ), LFUNCVAL ( coap_server_close ) },
|
{ LSTRKEY( "var" ), LFUNCVAL( coap_server_var ) },
|
||||||
{ LSTRKEY( "var" ), LFUNCVAL ( coap_server_var ) },
|
{ LSTRKEY( "func" ), LFUNCVAL( coap_server_func ) },
|
||||||
{ LSTRKEY( "func" ), LFUNCVAL ( coap_server_func ) },
|
{ LSTRKEY( "__gc" ), LFUNCVAL( coap_server_delete ) },
|
||||||
{ LSTRKEY( "__gc" ), LFUNCVAL ( coap_server_delete ) },
|
{ LSTRKEY( "__index" ), LROVAL( coap_server_map ) },
|
||||||
{ LSTRKEY( "__index" ), LROVAL ( coap_server_map ) },
|
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const LUA_REG_TYPE coap_client_map[] =
|
static const LUA_REG_TYPE coap_client_map[] = {
|
||||||
{
|
{ LSTRKEY( "get" ), LFUNCVAL( coap_client_get ) },
|
||||||
{ LSTRKEY( "get" ), LFUNCVAL ( coap_client_get ) },
|
{ LSTRKEY( "post" ), LFUNCVAL( coap_client_post ) },
|
||||||
{ LSTRKEY( "post" ), LFUNCVAL ( coap_client_post ) },
|
{ LSTRKEY( "put" ), LFUNCVAL( coap_client_put ) },
|
||||||
{ LSTRKEY( "put" ), LFUNCVAL ( coap_client_put ) },
|
{ LSTRKEY( "delete" ), LFUNCVAL( coap_client_delete ) },
|
||||||
{ LSTRKEY( "delete" ), LFUNCVAL ( coap_client_delete ) },
|
{ LSTRKEY( "__gc" ), LFUNCVAL( coap_client_gcdelete ) },
|
||||||
{ LSTRKEY( "__gc" ), LFUNCVAL ( coap_client_gcdelete ) },
|
{ LSTRKEY( "__index" ), LROVAL( coap_client_map ) },
|
||||||
{ LSTRKEY( "__index" ), LROVAL ( coap_client_map ) },
|
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
const LUA_REG_TYPE coap_map[] =
|
const LUA_REG_TYPE coap_map[] =
|
||||||
{
|
{
|
||||||
{ LSTRKEY( "Server" ), LFUNCVAL ( coap_createServer ) },
|
{ LSTRKEY( "Server" ), LFUNCVAL( coap_createServer ) },
|
||||||
{ LSTRKEY( "Client" ), LFUNCVAL ( coap_createClient ) },
|
{ LSTRKEY( "Client" ), LFUNCVAL( coap_createClient ) },
|
||||||
{ LSTRKEY( "CON" ), LNUMVAL( COAP_TYPE_CON ) },
|
{ LSTRKEY( "CON" ), LNUMVAL( COAP_TYPE_CON ) },
|
||||||
{ LSTRKEY( "NON" ), LNUMVAL( COAP_TYPE_NONCON ) },
|
{ LSTRKEY( "NON" ), LNUMVAL( COAP_TYPE_NONCON ) },
|
||||||
{ LSTRKEY( "TEXT_PLAIN"), LNUMVAL( COAP_CONTENTTYPE_TEXT_PLAIN ) },
|
{ LSTRKEY( "TEXT_PLAIN"), LNUMVAL( COAP_CONTENTTYPE_TEXT_PLAIN ) },
|
||||||
{ LSTRKEY( "LINKFORMAT"), LNUMVAL( COAP_CONTENTTYPE_APPLICATION_LINKFORMAT ) },
|
{ LSTRKEY( "LINKFORMAT"), LNUMVAL( COAP_CONTENTTYPE_APPLICATION_LINKFORMAT ) },
|
||||||
{ LSTRKEY( "XML"), LNUMVAL( COAP_CONTENTTYPE_APPLICATION_XML ) },
|
{ LSTRKEY( "XML"), LNUMVAL( COAP_CONTENTTYPE_APPLICATION_XML ) },
|
||||||
{ LSTRKEY( "OCTET_STREAM"), LNUMVAL( COAP_CONTENTTYPE_APPLICATION_OCTET_STREAM ) },
|
{ LSTRKEY( "OCTET_STREAM"), LNUMVAL( COAP_CONTENTTYPE_APPLICATION_OCTET_STREAM ) },
|
||||||
{ LSTRKEY( "EXI"), LNUMVAL( COAP_CONTENTTYPE_APPLICATION_EXI ) },
|
{ LSTRKEY( "EXI"), LNUMVAL( COAP_CONTENTTYPE_APPLICATION_EXI ) },
|
||||||
{ LSTRKEY( "JSON"), LNUMVAL( COAP_CONTENTTYPE_APPLICATION_JSON) },
|
{ LSTRKEY( "JSON"), LNUMVAL( COAP_CONTENTTYPE_APPLICATION_JSON) },
|
||||||
|
|
||||||
{ LSTRKEY( "__metatable" ), LROVAL( coap_map ) },
|
{ LSTRKEY( "__metatable" ), LROVAL( coap_map ) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
@ -602,5 +599,9 @@ LUALIB_API int luaopen_coap( lua_State *L )
|
||||||
endpoint_setup();
|
endpoint_setup();
|
||||||
luaL_rometatable(L, "coap_server", (void *)coap_server_map); // create metatable for coap_server
|
luaL_rometatable(L, "coap_server", (void *)coap_server_map); // create metatable for coap_server
|
||||||
luaL_rometatable(L, "coap_client", (void *)coap_client_map); // create metatable for coap_client
|
luaL_rometatable(L, "coap_client", (void *)coap_client_map); // create metatable for coap_client
|
||||||
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,18 +150,20 @@ static int crypto_lhmac (lua_State *L)
|
||||||
|
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
const LUA_REG_TYPE crypto_map[] =
|
const LUA_REG_TYPE crypto_map[] = {
|
||||||
{
|
{ LSTRKEY( "sha1" ), LFUNCVAL( crypto_sha1 ) },
|
||||||
{ LSTRKEY( "sha1" ), LFUNCVAL( crypto_sha1 ) },
|
|
||||||
{ LSTRKEY( "toBase64" ), LFUNCVAL( crypto_base64_encode ) },
|
{ LSTRKEY( "toBase64" ), LFUNCVAL( crypto_base64_encode ) },
|
||||||
{ LSTRKEY( "toHex" ), LFUNCVAL( crypto_hex_encode ) },
|
{ LSTRKEY( "toHex" ), LFUNCVAL( crypto_hex_encode ) },
|
||||||
{ LSTRKEY( "mask" ), LFUNCVAL( crypto_mask ) },
|
{ LSTRKEY( "mask" ), LFUNCVAL( crypto_mask ) },
|
||||||
{ LSTRKEY( "hash" ), LFUNCVAL( crypto_lhash ) },
|
{ LSTRKEY( "hash" ), LFUNCVAL( crypto_lhash ) },
|
||||||
{ LSTRKEY( "hmac" ), LFUNCVAL( crypto_lhmac ) },
|
{ LSTRKEY( "hmac" ), LFUNCVAL( crypto_lhmac ) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_crypto( lua_State *L )
|
LUALIB_API int luaopen_crypto( lua_State *L ) {
|
||||||
{
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// Module for interfacing with the DHTxx sensors (xx = 11-21-22-33-44).
|
// Module for interfacing with the DHTxx sensors (xx = 11-21-22-33-44).
|
||||||
|
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
#include "auxmods.h"
|
|
||||||
#include "lrodefs.h"
|
#include "lrodefs.h"
|
||||||
|
#include "platform.h"
|
||||||
#include "cpu_esp8266.h"
|
#include "cpu_esp8266.h"
|
||||||
#include "dht.h"
|
#include "dht.h"
|
||||||
|
|
||||||
|
@ -99,18 +99,20 @@ static int dht_lapi_readxx( lua_State *L )
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
const LUA_REG_TYPE dht_map[] =
|
const LUA_REG_TYPE dht_map[] = {
|
||||||
{
|
{ LSTRKEY( "read" ), LFUNCVAL( dht_lapi_read ) },
|
||||||
{ LSTRKEY( "read" ), LFUNCVAL( dht_lapi_read ) },
|
{ LSTRKEY( "read11" ), LFUNCVAL( dht_lapi_read11 ) },
|
||||||
{ LSTRKEY( "read11" ), LFUNCVAL( dht_lapi_read11 ) },
|
{ LSTRKEY( "readxx" ), LFUNCVAL( dht_lapi_readxx ) },
|
||||||
{ LSTRKEY( "readxx" ), LFUNCVAL( dht_lapi_readxx ) },
|
{ LSTRKEY( "OK" ), LNUMVAL( DHTLIB_OK ) },
|
||||||
{ LSTRKEY( "OK" ), LNUMVAL( DHTLIB_OK ) },
|
|
||||||
{ LSTRKEY( "ERROR_CHECKSUM" ), LNUMVAL( DHTLIB_ERROR_CHECKSUM ) },
|
{ LSTRKEY( "ERROR_CHECKSUM" ), LNUMVAL( DHTLIB_ERROR_CHECKSUM ) },
|
||||||
{ LSTRKEY( "ERROR_TIMEOUT" ), LNUMVAL( DHTLIB_ERROR_TIMEOUT ) },
|
{ LSTRKEY( "ERROR_TIMEOUT" ), LNUMVAL( DHTLIB_ERROR_TIMEOUT ) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_dht( lua_State *L )
|
LUALIB_API int luaopen_dht( lua_State *L ) {
|
||||||
{
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -927,14 +927,17 @@ static int enduser_setup_stop(lua_State* L)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const LUA_REG_TYPE enduser_setup_map[] =
|
const LUA_REG_TYPE enduser_setup_map[] = {
|
||||||
{
|
|
||||||
{ LSTRKEY( "start" ), LFUNCVAL( enduser_setup_start )},
|
{ LSTRKEY( "start" ), LFUNCVAL( enduser_setup_start )},
|
||||||
{ LSTRKEY( "stop" ), LFUNCVAL( enduser_setup_stop )},
|
{ LSTRKEY( "stop" ), LFUNCVAL( enduser_setup_stop )},
|
||||||
{ LNILKEY, LNILVAL}
|
{ LNILKEY, LNILVAL}
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_enduser_setup(lua_State *L) {
|
LUALIB_API int luaopen_enduser_setup(lua_State *L) {
|
||||||
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -296,29 +296,30 @@ static int file_writeline( lua_State* L )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
const LUA_REG_TYPE file_map[] =
|
const LUA_REG_TYPE file_map[] = {
|
||||||
{
|
{ LSTRKEY( "list" ), LFUNCVAL( file_list ) },
|
||||||
{ LSTRKEY( "list" ), LFUNCVAL( file_list ) },
|
{ LSTRKEY( "open" ), LFUNCVAL( file_open ) },
|
||||||
{ LSTRKEY( "open" ), LFUNCVAL( file_open ) },
|
{ LSTRKEY( "close" ), LFUNCVAL( file_close ) },
|
||||||
{ LSTRKEY( "close" ), LFUNCVAL( file_close ) },
|
{ LSTRKEY( "write" ), LFUNCVAL( file_write ) },
|
||||||
{ LSTRKEY( "write" ), LFUNCVAL( file_write ) },
|
|
||||||
{ LSTRKEY( "writeline" ), LFUNCVAL( file_writeline ) },
|
{ LSTRKEY( "writeline" ), LFUNCVAL( file_writeline ) },
|
||||||
{ LSTRKEY( "read" ), LFUNCVAL( file_read ) },
|
{ LSTRKEY( "read" ), LFUNCVAL( file_read ) },
|
||||||
{ LSTRKEY( "readline" ), LFUNCVAL( file_readline ) },
|
{ LSTRKEY( "readline" ), LFUNCVAL( file_readline ) },
|
||||||
{ LSTRKEY( "format" ), LFUNCVAL( file_format ) },
|
{ LSTRKEY( "format" ), LFUNCVAL( file_format ) },
|
||||||
#if defined(BUILD_WOFS)
|
#if defined(BUILD_SPIFFS) && !defined(BUILD_WOFS)
|
||||||
#elif defined(BUILD_SPIFFS)
|
{ LSTRKEY( "remove" ), LFUNCVAL( file_remove ) },
|
||||||
{ LSTRKEY( "remove" ), LFUNCVAL( file_remove ) },
|
{ LSTRKEY( "seek" ), LFUNCVAL( file_seek ) },
|
||||||
{ LSTRKEY( "seek" ), LFUNCVAL( file_seek ) },
|
{ LSTRKEY( "flush" ), LFUNCVAL( file_flush ) },
|
||||||
{ LSTRKEY( "flush" ), LFUNCVAL( file_flush ) },
|
//{ LSTRKEY( "check" ), LFUNCVAL( file_check ) },
|
||||||
// { LSTRKEY( "check" ), LFUNCVAL( file_check ) },
|
{ LSTRKEY( "rename" ), LFUNCVAL( file_rename ) },
|
||||||
{ LSTRKEY( "rename" ), LFUNCVAL( file_rename ) },
|
{ LSTRKEY( "fsinfo" ), LFUNCVAL( file_fsinfo ) },
|
||||||
{ LSTRKEY( "fsinfo" ), LFUNCVAL( file_fsinfo ) },
|
|
||||||
#endif
|
#endif
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_file( lua_State *L )
|
LUALIB_API int luaopen_file( lua_State *L ) {
|
||||||
{
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Module for interfacing with GPIO
|
// Module for interfacing with GPIO
|
||||||
|
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
#include "auxmods.h"
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "lrodefs.h"
|
#include "lrodefs.h"
|
||||||
|
|
||||||
|
@ -221,27 +220,25 @@ static int lgpio_serout( lua_State* L )
|
||||||
#undef DELAY_TABLE_MAX_LEN
|
#undef DELAY_TABLE_MAX_LEN
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
const LUA_REG_TYPE gpio_map[] =
|
const LUA_REG_TYPE gpio_map[] = {
|
||||||
{
|
{ LSTRKEY( "mode" ), LFUNCVAL( lgpio_mode ) },
|
||||||
{ LSTRKEY( "mode" ), LFUNCVAL( lgpio_mode ) },
|
{ LSTRKEY( "read" ), LFUNCVAL( lgpio_read ) },
|
||||||
{ LSTRKEY( "read" ), LFUNCVAL( lgpio_read ) },
|
{ LSTRKEY( "write" ), LFUNCVAL( lgpio_write ) },
|
||||||
{ LSTRKEY( "write" ), LFUNCVAL( lgpio_write ) },
|
|
||||||
{ LSTRKEY( "serout" ), LFUNCVAL( lgpio_serout ) },
|
{ LSTRKEY( "serout" ), LFUNCVAL( lgpio_serout ) },
|
||||||
#ifdef GPIO_INTERRUPT_ENABLE
|
#ifdef GPIO_INTERRUPT_ENABLE
|
||||||
{ LSTRKEY( "trig" ), LFUNCVAL( lgpio_trig ) },
|
{ LSTRKEY( "trig" ), LFUNCVAL( lgpio_trig ) },
|
||||||
{ LSTRKEY( "INT" ), LNUMVAL( INTERRUPT ) },
|
{ LSTRKEY( "INT" ), LNUMVAL( INTERRUPT ) },
|
||||||
#endif
|
#endif
|
||||||
{ LSTRKEY( "OUTPUT" ), LNUMVAL( OUTPUT ) },
|
{ LSTRKEY( "OUTPUT" ), LNUMVAL( OUTPUT ) },
|
||||||
{ LSTRKEY( "INPUT" ), LNUMVAL( INPUT ) },
|
{ LSTRKEY( "INPUT" ), LNUMVAL( INPUT ) },
|
||||||
{ LSTRKEY( "HIGH" ), LNUMVAL( HIGH ) },
|
{ LSTRKEY( "HIGH" ), LNUMVAL( HIGH ) },
|
||||||
{ LSTRKEY( "LOW" ), LNUMVAL( LOW ) },
|
{ LSTRKEY( "LOW" ), LNUMVAL( LOW ) },
|
||||||
{ LSTRKEY( "FLOAT" ), LNUMVAL( FLOAT ) },
|
{ LSTRKEY( "FLOAT" ), LNUMVAL( FLOAT ) },
|
||||||
{ LSTRKEY( "PULLUP" ), LNUMVAL( PULLUP ) },
|
{ LSTRKEY( "PULLUP" ), LNUMVAL( PULLUP ) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_gpio( lua_State *L )
|
LUALIB_API int luaopen_gpio( lua_State *L ) {
|
||||||
{
|
|
||||||
#ifdef GPIO_INTERRUPT_ENABLE
|
#ifdef GPIO_INTERRUPT_ENABLE
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<GPIO_PIN_NUM;i++){
|
for(i=0;i<GPIO_PIN_NUM;i++){
|
||||||
|
@ -249,5 +246,10 @@ LUALIB_API int luaopen_gpio( lua_State *L )
|
||||||
}
|
}
|
||||||
platform_gpio_init(gpio_intr_callback);
|
platform_gpio_init(gpio_intr_callback);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "auxmods.h"
|
|
||||||
#include "lrodefs.h"
|
#include "lrodefs.h"
|
||||||
#include "c_stdlib.h"
|
#include "c_stdlib.h"
|
||||||
#include "c_string.h"
|
#include "c_string.h"
|
||||||
|
@ -66,8 +65,8 @@ static int ICACHE_FLASH_ATTR hx711_read(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LUA_REG_TYPE hx711_map[] =
|
// Module function map
|
||||||
{
|
const LUA_REG_TYPE hx711_map[] = {
|
||||||
{ LSTRKEY( "init" ), LFUNCVAL( hx711_init )},
|
{ LSTRKEY( "init" ), LFUNCVAL( hx711_init )},
|
||||||
{ LSTRKEY( "read" ), LFUNCVAL( hx711_read )},
|
{ LSTRKEY( "read" ), LFUNCVAL( hx711_read )},
|
||||||
{ LNILKEY, LNILVAL}
|
{ LNILKEY, LNILVAL}
|
||||||
|
@ -75,5 +74,9 @@ const LUA_REG_TYPE hx711_map[] =
|
||||||
|
|
||||||
LUALIB_API int luaopen_hx711(lua_State *L) {
|
LUALIB_API int luaopen_hx711(lua_State *L) {
|
||||||
// TODO: Make sure that the GPIO system is initialized
|
// TODO: Make sure that the GPIO system is initialized
|
||||||
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "auxmods.h"
|
|
||||||
#include "lrodefs.h"
|
#include "lrodefs.h"
|
||||||
|
|
||||||
// Lua: speed = i2c.setup( id, sda, scl, speed )
|
// Lua: speed = i2c.setup( id, sda, scl, speed )
|
||||||
|
@ -141,23 +140,25 @@ static int i2c_read( lua_State *L )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
const LUA_REG_TYPE i2c_map[] =
|
const LUA_REG_TYPE i2c_map[] = {
|
||||||
{
|
{ LSTRKEY( "setup" ), LFUNCVAL( i2c_setup ) },
|
||||||
{ LSTRKEY( "setup" ), LFUNCVAL( i2c_setup ) },
|
{ LSTRKEY( "start" ), LFUNCVAL( i2c_start ) },
|
||||||
{ LSTRKEY( "start" ), LFUNCVAL( i2c_start ) },
|
{ LSTRKEY( "stop" ), LFUNCVAL( i2c_stop ) },
|
||||||
{ LSTRKEY( "stop" ), LFUNCVAL( i2c_stop ) },
|
{ LSTRKEY( "address" ), LFUNCVAL( i2c_address ) },
|
||||||
{ LSTRKEY( "address" ), LFUNCVAL( i2c_address ) },
|
{ LSTRKEY( "write" ), LFUNCVAL( i2c_write ) },
|
||||||
{ LSTRKEY( "write" ), LFUNCVAL( i2c_write ) },
|
{ LSTRKEY( "read" ), LFUNCVAL( i2c_read ) },
|
||||||
{ LSTRKEY( "read" ), LFUNCVAL( i2c_read ) },
|
//{ LSTRKEY( "FAST" ), LNUMVAL( PLATFORM_I2C_SPEED_FAST ) },
|
||||||
// { LSTRKEY( "FAST" ), LNUMVAL( PLATFORM_I2C_SPEED_FAST ) },
|
{ LSTRKEY( "SLOW" ), LNUMVAL( PLATFORM_I2C_SPEED_SLOW ) },
|
||||||
{ LSTRKEY( "SLOW" ), LNUMVAL( PLATFORM_I2C_SPEED_SLOW ) },
|
|
||||||
{ LSTRKEY( "TRANSMITTER" ), LNUMVAL( PLATFORM_I2C_DIRECTION_TRANSMITTER ) },
|
{ LSTRKEY( "TRANSMITTER" ), LNUMVAL( PLATFORM_I2C_DIRECTION_TRANSMITTER ) },
|
||||||
{ LSTRKEY( "RECEIVER" ), LNUMVAL( PLATFORM_I2C_DIRECTION_RECEIVER ) },
|
{ LSTRKEY( "RECEIVER" ), LNUMVAL( PLATFORM_I2C_DIRECTION_RECEIVER ) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_i2c( lua_State *L )
|
LUALIB_API int luaopen_i2c( lua_State *L ) {
|
||||||
{
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "auxmods.h"
|
|
||||||
#include "lrodefs.h"
|
#include "lrodefs.h"
|
||||||
|
|
||||||
#include "c_string.h"
|
#include "c_string.h"
|
||||||
|
@ -1390,22 +1389,20 @@ static int mqtt_socket_lwt( lua_State* L )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
static const LUA_REG_TYPE mqtt_socket_map[] =
|
static const LUA_REG_TYPE mqtt_socket_map[] = {
|
||||||
{
|
{ LSTRKEY( "connect" ), LFUNCVAL( mqtt_socket_connect ) },
|
||||||
{ LSTRKEY( "connect" ), LFUNCVAL ( mqtt_socket_connect ) },
|
{ LSTRKEY( "close" ), LFUNCVAL( mqtt_socket_close ) },
|
||||||
{ LSTRKEY( "close" ), LFUNCVAL ( mqtt_socket_close ) },
|
{ LSTRKEY( "publish" ), LFUNCVAL( mqtt_socket_publish ) },
|
||||||
{ LSTRKEY( "publish" ), LFUNCVAL ( mqtt_socket_publish ) },
|
{ LSTRKEY( "subscribe" ), LFUNCVAL( mqtt_socket_subscribe ) },
|
||||||
{ LSTRKEY( "subscribe" ), LFUNCVAL ( mqtt_socket_subscribe ) },
|
{ LSTRKEY( "lwt" ), LFUNCVAL( mqtt_socket_lwt ) },
|
||||||
{ LSTRKEY( "lwt" ), LFUNCVAL ( mqtt_socket_lwt ) },
|
{ LSTRKEY( "on" ), LFUNCVAL( mqtt_socket_on ) },
|
||||||
{ LSTRKEY( "on" ), LFUNCVAL ( mqtt_socket_on ) },
|
{ LSTRKEY( "__gc" ), LFUNCVAL( mqtt_delete ) },
|
||||||
{ LSTRKEY( "__gc" ), LFUNCVAL ( mqtt_delete ) },
|
{ LSTRKEY( "__index" ), LROVAL( mqtt_socket_map ) },
|
||||||
{ LSTRKEY( "__index" ), LROVAL ( mqtt_socket_map ) },
|
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
const LUA_REG_TYPE mqtt_map[] =
|
const LUA_REG_TYPE mqtt_map[] = {
|
||||||
{
|
{ LSTRKEY( "Client" ), LFUNCVAL( mqtt_socket_client ) },
|
||||||
{ LSTRKEY( "Client" ), LFUNCVAL ( mqtt_socket_client ) },
|
|
||||||
{ LSTRKEY( "__metatable" ), LROVAL( mqtt_map ) },
|
{ LSTRKEY( "__metatable" ), LROVAL( mqtt_map ) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
@ -1413,5 +1410,9 @@ const LUA_REG_TYPE mqtt_map[] =
|
||||||
LUALIB_API int luaopen_mqtt( lua_State *L )
|
LUALIB_API int luaopen_mqtt( lua_State *L )
|
||||||
{
|
{
|
||||||
luaL_rometatable(L, "mqtt.socket", (void *)mqtt_socket_map); // create metatable for mqtt.socket
|
luaL_rometatable(L, "mqtt.socket", (void *)mqtt_socket_map); // create metatable for mqtt.socket
|
||||||
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "auxmods.h"
|
|
||||||
#include "lrodefs.h"
|
#include "lrodefs.h"
|
||||||
|
|
||||||
#include "c_string.h"
|
#include "c_string.h"
|
||||||
|
@ -1506,66 +1505,59 @@ static int expose_array(lua_State* L, char *array, unsigned short len) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
static const LUA_REG_TYPE net_server_map[] =
|
static const LUA_REG_TYPE net_server_map[] = {
|
||||||
{
|
{ LSTRKEY( "listen" ), LFUNCVAL( net_server_listen ) },
|
||||||
{ LSTRKEY( "listen" ), LFUNCVAL ( net_server_listen ) },
|
{ LSTRKEY( "close" ), LFUNCVAL( net_server_close ) },
|
||||||
{ LSTRKEY( "close" ), LFUNCVAL ( net_server_close ) },
|
{ LSTRKEY( "on" ), LFUNCVAL( net_udpserver_on ) },
|
||||||
{ LSTRKEY( "on" ), LFUNCVAL ( net_udpserver_on ) },
|
{ LSTRKEY( "send" ), LFUNCVAL( net_udpserver_send ) },
|
||||||
{ LSTRKEY( "send" ), LFUNCVAL ( net_udpserver_send ) },
|
//{ LSTRKEY( "delete" ), LFUNCVAL( net_server_delete ) },
|
||||||
// { LSTRKEY( "delete" ), LFUNCVAL ( net_server_delete ) },
|
{ LSTRKEY( "__gc" ), LFUNCVAL( net_server_delete ) },
|
||||||
{ LSTRKEY( "__gc" ), LFUNCVAL ( net_server_delete ) },
|
{ LSTRKEY( "__index" ), LROVAL( net_server_map ) },
|
||||||
{ LSTRKEY( "__index" ), LROVAL ( net_server_map ) },
|
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const LUA_REG_TYPE net_socket_map[] =
|
static const LUA_REG_TYPE net_socket_map[] = {
|
||||||
{
|
|
||||||
{ LSTRKEY( "connect" ), LFUNCVAL( net_socket_connect ) },
|
{ LSTRKEY( "connect" ), LFUNCVAL( net_socket_connect ) },
|
||||||
{ LSTRKEY( "close" ), LFUNCVAL ( net_socket_close ) },
|
{ LSTRKEY( "close" ), LFUNCVAL( net_socket_close ) },
|
||||||
{ LSTRKEY( "on" ), LFUNCVAL ( net_socket_on ) },
|
{ LSTRKEY( "on" ), LFUNCVAL( net_socket_on ) },
|
||||||
{ LSTRKEY( "send" ), LFUNCVAL ( net_socket_send ) },
|
{ LSTRKEY( "send" ), LFUNCVAL( net_socket_send ) },
|
||||||
{ LSTRKEY( "hold" ), LFUNCVAL ( net_socket_hold ) },
|
{ LSTRKEY( "hold" ), LFUNCVAL( net_socket_hold ) },
|
||||||
{ LSTRKEY( "unhold" ), LFUNCVAL ( net_socket_unhold ) },
|
{ LSTRKEY( "unhold" ), LFUNCVAL( net_socket_unhold ) },
|
||||||
{ LSTRKEY( "dns" ), LFUNCVAL ( net_socket_dns ) },
|
{ LSTRKEY( "dns" ), LFUNCVAL( net_socket_dns ) },
|
||||||
{ LSTRKEY( "getpeer" ), LFUNCVAL ( net_socket_getpeer ) },
|
{ LSTRKEY( "getpeer" ), LFUNCVAL( net_socket_getpeer ) },
|
||||||
// { LSTRKEY( "delete" ), LFUNCVAL ( net_socket_delete ) },
|
//{ LSTRKEY( "delete" ), LFUNCVAL( net_socket_delete ) },
|
||||||
{ LSTRKEY( "__gc" ), LFUNCVAL ( net_socket_delete ) },
|
{ LSTRKEY( "__gc" ), LFUNCVAL( net_socket_delete ) },
|
||||||
{ LSTRKEY( "__index" ), LROVAL ( net_socket_map ) },
|
{ LSTRKEY( "__index" ), LROVAL( net_socket_map ) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
#if 0
|
#if 0
|
||||||
static const LUA_REG_TYPE net_array_map[] =
|
static const LUA_REG_TYPE net_array_map[] = {
|
||||||
{
|
{ LSTRKEY( "__index" ), LFUNCVAL( net_array_index ) },
|
||||||
{ LSTRKEY( "__index" ), LFUNCVAL( net_array_index ) },
|
|
||||||
{ LSTRKEY( "__newindex" ), LFUNCVAL( net_array_newindex ) },
|
{ LSTRKEY( "__newindex" ), LFUNCVAL( net_array_newindex ) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const LUA_REG_TYPE net_dns_map[] =
|
static const LUA_REG_TYPE net_dns_map[] = {
|
||||||
{
|
{ LSTRKEY( "setdnsserver" ), LFUNCVAL( net_setdnsserver ) },
|
||||||
{ LSTRKEY( "setdnsserver" ), LFUNCVAL ( net_setdnsserver ) },
|
{ LSTRKEY( "getdnsserver" ), LFUNCVAL( net_getdnsserver ) },
|
||||||
{ LSTRKEY( "getdnsserver" ), LFUNCVAL ( net_getdnsserver ) },
|
{ LSTRKEY( "resolve" ), LFUNCVAL( net_dns_static ) },
|
||||||
{ LSTRKEY( "resolve" ), LFUNCVAL ( net_dns_static ) },
|
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
const LUA_REG_TYPE net_map[] =
|
const LUA_REG_TYPE net_map[] = {
|
||||||
{
|
{ LSTRKEY( "createServer" ), LFUNCVAL( net_createServer ) },
|
||||||
{ LSTRKEY( "createServer" ), LFUNCVAL ( net_createServer ) },
|
{ LSTRKEY( "createConnection" ), LFUNCVAL( net_createConnection ) },
|
||||||
{ LSTRKEY( "createConnection" ), LFUNCVAL ( net_createConnection ) },
|
{ LSTRKEY( "multicastJoin"), LFUNCVAL( net_multicastJoin ) },
|
||||||
{ LSTRKEY( "multicastJoin"), LFUNCVAL( net_multicastJoin ) },
|
{ LSTRKEY( "multicastLeave"), LFUNCVAL( net_multicastLeave ) },
|
||||||
{ LSTRKEY( "multicastLeave"), LFUNCVAL( net_multicastLeave ) },
|
{ LSTRKEY( "dns" ), LROVAL( net_dns_map ) },
|
||||||
{ LSTRKEY( "dns" ), LROVAL( net_dns_map ) },
|
{ LSTRKEY( "TCP" ), LNUMVAL( TCP ) },
|
||||||
{ LSTRKEY( "TCP" ), LNUMVAL( TCP ) },
|
{ LSTRKEY( "UDP" ), LNUMVAL( UDP ) },
|
||||||
{ LSTRKEY( "UDP" ), LNUMVAL( UDP ) },
|
{ LSTRKEY( "__metatable" ), LROVAL( net_map ) },
|
||||||
|
|
||||||
{ LSTRKEY( "__metatable" ), LROVAL( net_map ) },
|
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_net( lua_State *L )
|
LUALIB_API int luaopen_net( lua_State *L ) {
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<MAX_SOCKET;i++)
|
for(i=0;i<MAX_SOCKET;i++)
|
||||||
{
|
{
|
||||||
|
@ -1575,7 +1567,12 @@ LUALIB_API int luaopen_net( lua_State *L )
|
||||||
luaL_rometatable(L, "net.server", (void *)net_server_map); // create metatable for net.server
|
luaL_rometatable(L, "net.server", (void *)net_server_map); // create metatable for net.server
|
||||||
luaL_rometatable(L, "net.socket", (void *)net_socket_map); // create metatable for net.socket
|
luaL_rometatable(L, "net.socket", (void *)net_socket_map); // create metatable for net.socket
|
||||||
#if 0
|
#if 0
|
||||||
luaL_rometatable(L, "net.array", (void *)net_array_map); // create metatable for net.array
|
luaL_rometatable(L, "net.array", (void *)net_array_map); // create metatable for net.array
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// Module for interfacing with the OneWire interface
|
// Module for interfacing with the OneWire interface
|
||||||
|
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
#include "auxmods.h"
|
|
||||||
#include "lrodefs.h"
|
#include "lrodefs.h"
|
||||||
|
#include "platform.h"
|
||||||
#include "driver/onewire.h"
|
#include "driver/onewire.h"
|
||||||
|
|
||||||
// Lua: ow.setup( id )
|
// Lua: ow.setup( id )
|
||||||
|
@ -280,33 +280,35 @@ static int ow_crc16( lua_State *L )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
const LUA_REG_TYPE ow_map[] =
|
const LUA_REG_TYPE ow_map[] = {
|
||||||
{
|
{ LSTRKEY( "setup" ), LFUNCVAL( ow_setup ) },
|
||||||
{ LSTRKEY( "setup" ), LFUNCVAL( ow_setup ) },
|
{ LSTRKEY( "reset" ), LFUNCVAL( ow_reset ) },
|
||||||
{ LSTRKEY( "reset" ), LFUNCVAL( ow_reset ) },
|
{ LSTRKEY( "skip" ), LFUNCVAL( ow_skip ) },
|
||||||
{ LSTRKEY( "skip" ), LFUNCVAL( ow_skip ) },
|
{ LSTRKEY( "select" ), LFUNCVAL( ow_select ) },
|
||||||
{ LSTRKEY( "select" ), LFUNCVAL( ow_select ) },
|
{ LSTRKEY( "write" ), LFUNCVAL( ow_write ) },
|
||||||
{ LSTRKEY( "write" ), LFUNCVAL( ow_write ) },
|
{ LSTRKEY( "write_bytes" ), LFUNCVAL( ow_write_bytes ) },
|
||||||
{ LSTRKEY( "write_bytes" ), LFUNCVAL( ow_write_bytes ) },
|
{ LSTRKEY( "read" ), LFUNCVAL( ow_read ) },
|
||||||
{ LSTRKEY( "read" ), LFUNCVAL( ow_read ) },
|
{ LSTRKEY( "read_bytes" ), LFUNCVAL( ow_read_bytes ) },
|
||||||
{ LSTRKEY( "read_bytes" ), LFUNCVAL( ow_read_bytes ) },
|
{ LSTRKEY( "depower" ), LFUNCVAL( ow_depower ) },
|
||||||
{ LSTRKEY( "depower" ), LFUNCVAL( ow_depower ) },
|
|
||||||
#if ONEWIRE_SEARCH
|
#if ONEWIRE_SEARCH
|
||||||
{ LSTRKEY( "reset_search" ), LFUNCVAL( ow_reset_search ) },
|
{ LSTRKEY( "reset_search" ), LFUNCVAL( ow_reset_search ) },
|
||||||
{ LSTRKEY( "target_search" ), LFUNCVAL( ow_target_search ) },
|
{ LSTRKEY( "target_search" ), LFUNCVAL( ow_target_search ) },
|
||||||
{ LSTRKEY( "search" ), LFUNCVAL( ow_search ) },
|
{ LSTRKEY( "search" ), LFUNCVAL( ow_search ) },
|
||||||
#endif
|
#endif
|
||||||
#if ONEWIRE_CRC
|
#if ONEWIRE_CRC
|
||||||
{ LSTRKEY( "crc8" ), LFUNCVAL( ow_crc8 ) },
|
{ LSTRKEY( "crc8" ), LFUNCVAL( ow_crc8 ) },
|
||||||
#if ONEWIRE_CRC16
|
#if ONEWIRE_CRC16
|
||||||
{ LSTRKEY( "check_crc16" ), LFUNCVAL( ow_check_crc16 ) },
|
{ LSTRKEY( "check_crc16" ), LFUNCVAL( ow_check_crc16 ) },
|
||||||
{ LSTRKEY( "crc16" ), LFUNCVAL( ow_crc16 ) },
|
{ LSTRKEY( "crc16" ), LFUNCVAL( ow_crc16 ) },
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_ow( lua_State *L )
|
LUALIB_API int luaopen_ow( lua_State *L ) {
|
||||||
{
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "auxmods.h"
|
|
||||||
#include "lrodefs.h"
|
#include "lrodefs.h"
|
||||||
|
|
||||||
#include "c_types.h"
|
#include "c_types.h"
|
||||||
|
@ -123,20 +122,22 @@ static int lpwm_getduty( lua_State* L )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
const LUA_REG_TYPE pwm_map[] =
|
const LUA_REG_TYPE pwm_map[] = {
|
||||||
{
|
{ LSTRKEY( "setup" ), LFUNCVAL( lpwm_setup ) },
|
||||||
{ LSTRKEY( "setup" ), LFUNCVAL( lpwm_setup ) },
|
{ LSTRKEY( "close" ), LFUNCVAL( lpwm_close ) },
|
||||||
{ LSTRKEY( "close" ), LFUNCVAL( lpwm_close ) },
|
{ LSTRKEY( "start" ), LFUNCVAL( lpwm_start ) },
|
||||||
{ LSTRKEY( "start" ), LFUNCVAL( lpwm_start ) },
|
{ LSTRKEY( "stop" ), LFUNCVAL( lpwm_stop ) },
|
||||||
{ LSTRKEY( "stop" ), LFUNCVAL( lpwm_stop ) },
|
|
||||||
{ LSTRKEY( "setclock" ), LFUNCVAL( lpwm_setclock ) },
|
{ LSTRKEY( "setclock" ), LFUNCVAL( lpwm_setclock ) },
|
||||||
{ LSTRKEY( "getclock" ), LFUNCVAL( lpwm_getclock ) },
|
{ LSTRKEY( "getclock" ), LFUNCVAL( lpwm_getclock ) },
|
||||||
{ LSTRKEY( "setduty" ), LFUNCVAL( lpwm_setduty ) },
|
{ LSTRKEY( "setduty" ), LFUNCVAL( lpwm_setduty ) },
|
||||||
{ LSTRKEY( "getduty" ), LFUNCVAL( lpwm_getduty ) },
|
{ LSTRKEY( "getduty" ), LFUNCVAL( lpwm_getduty ) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_pwm( lua_State *L )
|
LUALIB_API int luaopen_pwm( lua_State *L ) {
|
||||||
{
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,8 +79,8 @@ static int ICACHE_FLASH_ATTR rc_send(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LUA_REG_TYPE rc_map[] =
|
// Module function map
|
||||||
{
|
const LUA_REG_TYPE rc_map[] = {
|
||||||
{ LSTRKEY( "send" ), LFUNCVAL( rc_send )},
|
{ LSTRKEY( "send" ), LFUNCVAL( rc_send )},
|
||||||
{ LNILKEY, LNILVAL}
|
{ LNILKEY, LNILVAL}
|
||||||
};
|
};
|
||||||
|
@ -88,5 +88,9 @@ const LUA_REG_TYPE rc_map[] =
|
||||||
//LUALIB_API int luaopen_ultra(lua_State *L) {
|
//LUALIB_API int luaopen_ultra(lua_State *L) {
|
||||||
LUALIB_API int luaopen_rc(lua_State *L) {
|
LUALIB_API int luaopen_rc(lua_State *L) {
|
||||||
// TODO: Make sure that the GPIO system is initialized
|
// TODO: Make sure that the GPIO system is initialized
|
||||||
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,8 +165,7 @@ static int rtcfifo_dsleep_until_sample (lua_State *L)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
const LUA_REG_TYPE rtcfifo_map[] =
|
const LUA_REG_TYPE rtcfifo_map[] = {
|
||||||
{
|
|
||||||
{ LSTRKEY("prepare"), LFUNCVAL(rtcfifo_prepare) },
|
{ LSTRKEY("prepare"), LFUNCVAL(rtcfifo_prepare) },
|
||||||
{ LSTRKEY("ready"), LFUNCVAL(rtcfifo_ready) },
|
{ LSTRKEY("ready"), LFUNCVAL(rtcfifo_ready) },
|
||||||
{ LSTRKEY("put"), LFUNCVAL(rtcfifo_put) },
|
{ LSTRKEY("put"), LFUNCVAL(rtcfifo_put) },
|
||||||
|
@ -182,5 +181,9 @@ const LUA_REG_TYPE rtcfifo_map[] =
|
||||||
|
|
||||||
LUALIB_API int luaopen_rtcfifo (lua_State *L)
|
LUALIB_API int luaopen_rtcfifo (lua_State *L)
|
||||||
{
|
{
|
||||||
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,14 +41,16 @@ static int rtcmem_write32 (lua_State *L)
|
||||||
|
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
const LUA_REG_TYPE rtcmem_map[] =
|
const LUA_REG_TYPE rtcmem_map[] = {
|
||||||
{
|
|
||||||
{ LSTRKEY("read32"), LFUNCVAL(rtcmem_read32) },
|
{ LSTRKEY("read32"), LFUNCVAL(rtcmem_read32) },
|
||||||
{ LSTRKEY("write32"), LFUNCVAL(rtcmem_write32) },
|
{ LSTRKEY("write32"), LFUNCVAL(rtcmem_write32) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_rtcmem (lua_State *L)
|
LUALIB_API int luaopen_rtcmem (lua_State *L) {
|
||||||
{
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,16 +116,18 @@ static int rtctime_dsleep_aligned (lua_State *L)
|
||||||
|
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
const LUA_REG_TYPE rtctime_map[] =
|
const LUA_REG_TYPE rtctime_map[] = {
|
||||||
{
|
{ LSTRKEY("set"), LFUNCVAL(rtctime_set) },
|
||||||
{ LSTRKEY("set"), LFUNCVAL(rtctime_set) },
|
{ LSTRKEY("get"), LFUNCVAL(rtctime_get) },
|
||||||
{ LSTRKEY("get"), LFUNCVAL(rtctime_get) },
|
{ LSTRKEY("dsleep"), LFUNCVAL(rtctime_dsleep) },
|
||||||
{ LSTRKEY("dsleep"), LFUNCVAL(rtctime_dsleep) },
|
|
||||||
{ LSTRKEY("dsleep_aligned"), LFUNCVAL(rtctime_dsleep_aligned) },
|
{ LSTRKEY("dsleep_aligned"), LFUNCVAL(rtctime_dsleep_aligned) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_rtctime (lua_State *L)
|
LUALIB_API int luaopen_rtctime (lua_State *L) {
|
||||||
{
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,13 +376,15 @@ error:
|
||||||
|
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
const LUA_REG_TYPE sntp_map[] =
|
const LUA_REG_TYPE sntp_map[] = {
|
||||||
{
|
|
||||||
{ LSTRKEY("sync"), LFUNCVAL(sntp_sync) },
|
{ LSTRKEY("sync"), LFUNCVAL(sntp_sync) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_sntp (lua_State *L)
|
LUALIB_API int luaopen_sntp (lua_State *L) {
|
||||||
{
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "auxmods.h"
|
|
||||||
#include "lrodefs.h"
|
#include "lrodefs.h"
|
||||||
|
|
||||||
#define SPI_HALFDUPLEX 0
|
#define SPI_HALFDUPLEX 0
|
||||||
|
@ -307,27 +306,29 @@ static int spi_transaction( lua_State *L )
|
||||||
|
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
const LUA_REG_TYPE spi_map[] =
|
const LUA_REG_TYPE spi_map[] = {
|
||||||
{
|
|
||||||
{ LSTRKEY( "setup" ), LFUNCVAL( spi_setup ) },
|
{ LSTRKEY( "setup" ), LFUNCVAL( spi_setup ) },
|
||||||
{ LSTRKEY( "send" ), LFUNCVAL( spi_send_recv ) },
|
{ LSTRKEY( "send" ), LFUNCVAL( spi_send_recv ) },
|
||||||
{ LSTRKEY( "recv" ), LFUNCVAL( spi_recv ) },
|
{ LSTRKEY( "recv" ), LFUNCVAL( spi_recv ) },
|
||||||
{ LSTRKEY( "set_mosi" ), LFUNCVAL( spi_set_mosi ) },
|
{ LSTRKEY( "set_mosi" ), LFUNCVAL( spi_set_mosi ) },
|
||||||
{ LSTRKEY( "get_miso" ), LFUNCVAL( spi_get_miso ) },
|
{ LSTRKEY( "get_miso" ), LFUNCVAL( spi_get_miso ) },
|
||||||
{ LSTRKEY( "transaction" ), LFUNCVAL( spi_transaction ) },
|
{ LSTRKEY( "transaction" ), LFUNCVAL( spi_transaction ) },
|
||||||
{ LSTRKEY( "MASTER" ), LNUMVAL( PLATFORM_SPI_MASTER ) },
|
{ LSTRKEY( "MASTER" ), LNUMVAL( PLATFORM_SPI_MASTER ) },
|
||||||
{ LSTRKEY( "SLAVE" ), LNUMVAL( PLATFORM_SPI_SLAVE) },
|
{ LSTRKEY( "SLAVE" ), LNUMVAL( PLATFORM_SPI_SLAVE) },
|
||||||
{ LSTRKEY( "CPHA_LOW" ), LNUMVAL( PLATFORM_SPI_CPHA_LOW) },
|
{ LSTRKEY( "CPHA_LOW" ), LNUMVAL( PLATFORM_SPI_CPHA_LOW) },
|
||||||
{ LSTRKEY( "CPHA_HIGH" ), LNUMVAL( PLATFORM_SPI_CPHA_HIGH) },
|
{ LSTRKEY( "CPHA_HIGH" ), LNUMVAL( PLATFORM_SPI_CPHA_HIGH) },
|
||||||
{ LSTRKEY( "CPOL_LOW" ), LNUMVAL( PLATFORM_SPI_CPOL_LOW) },
|
{ LSTRKEY( "CPOL_LOW" ), LNUMVAL( PLATFORM_SPI_CPOL_LOW) },
|
||||||
{ LSTRKEY( "CPOL_HIGH" ), LNUMVAL( PLATFORM_SPI_CPOL_HIGH) },
|
{ LSTRKEY( "CPOL_HIGH" ), LNUMVAL( PLATFORM_SPI_CPOL_HIGH) },
|
||||||
{ LSTRKEY( "DATABITS_8" ), LNUMVAL( 8 ) },
|
{ LSTRKEY( "DATABITS_8" ), LNUMVAL( 8 ) },
|
||||||
{ LSTRKEY( "HALFDUPLEX" ), LNUMVAL( SPI_HALFDUPLEX ) },
|
{ LSTRKEY( "HALFDUPLEX" ), LNUMVAL( SPI_HALFDUPLEX ) },
|
||||||
{ LSTRKEY( "FULLDUPLEX" ), LNUMVAL( SPI_FULLDUPLEX ) },
|
{ LSTRKEY( "FULLDUPLEX" ), LNUMVAL( SPI_FULLDUPLEX ) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_spi( lua_State *L )
|
LUALIB_API int luaopen_spi( lua_State *L ) {
|
||||||
{
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@ tmr.softwd(int)
|
||||||
|
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "auxmods.h"
|
|
||||||
#include "lrodefs.h"
|
#include "lrodefs.h"
|
||||||
#include "c_types.h"
|
#include "c_types.h"
|
||||||
|
|
||||||
|
@ -308,21 +307,21 @@ static int tmr_softwd( lua_State* L ){
|
||||||
// Module function map
|
// Module function map
|
||||||
|
|
||||||
const LUA_REG_TYPE tmr_map[] = {
|
const LUA_REG_TYPE tmr_map[] = {
|
||||||
{ LSTRKEY( "delay" ), LFUNCVAL( tmr_delay ) },
|
{ LSTRKEY( "delay" ), LFUNCVAL( tmr_delay ) },
|
||||||
{ LSTRKEY( "now" ), LFUNCVAL( tmr_now ) },
|
{ LSTRKEY( "now" ), LFUNCVAL( tmr_now ) },
|
||||||
{ LSTRKEY( "wdclr" ), LFUNCVAL( tmr_wdclr ) },
|
{ LSTRKEY( "wdclr" ), LFUNCVAL( tmr_wdclr ) },
|
||||||
{ LSTRKEY( "softwd" ), LFUNCVAL( tmr_softwd ) },
|
{ LSTRKEY( "softwd" ), LFUNCVAL( tmr_softwd ) },
|
||||||
{ LSTRKEY( "time" ), LFUNCVAL( tmr_time ) },
|
{ LSTRKEY( "time" ), LFUNCVAL( tmr_time ) },
|
||||||
{ LSTRKEY( "register" ), LFUNCVAL ( tmr_register ) },
|
{ LSTRKEY( "register" ), LFUNCVAL( tmr_register ) },
|
||||||
{ LSTRKEY( "alarm" ), LFUNCVAL( tmr_alarm ) },
|
{ LSTRKEY( "alarm" ), LFUNCVAL( tmr_alarm ) },
|
||||||
{ LSTRKEY( "start" ), LFUNCVAL ( tmr_start ) },
|
{ LSTRKEY( "start" ), LFUNCVAL( tmr_start ) },
|
||||||
{ LSTRKEY( "stop" ), LFUNCVAL ( tmr_stop ) },
|
{ LSTRKEY( "stop" ), LFUNCVAL( tmr_stop ) },
|
||||||
{ LSTRKEY( "unregister" ), LFUNCVAL ( tmr_unregister ) },
|
{ LSTRKEY( "unregister" ), LFUNCVAL( tmr_unregister ) },
|
||||||
{ LSTRKEY( "state" ), LFUNCVAL ( tmr_state ) },
|
{ LSTRKEY( "state" ), LFUNCVAL( tmr_state ) },
|
||||||
{ LSTRKEY( "interval" ), LFUNCVAL ( tmr_interval) },
|
{ LSTRKEY( "interval" ), LFUNCVAL( tmr_interval) },
|
||||||
{ LSTRKEY( "ALARM_SINGLE" ), LNUMVAL( TIMER_MODE_SINGLE ) },
|
{ LSTRKEY( "ALARM_SINGLE" ), LNUMVAL( TIMER_MODE_SINGLE ) },
|
||||||
{ LSTRKEY( "ALARM_SEMI" ), LNUMVAL( TIMER_MODE_SEMI ) },
|
{ LSTRKEY( "ALARM_SEMI" ), LNUMVAL( TIMER_MODE_SEMI ) },
|
||||||
{ LSTRKEY( "ALARM_AUTO" ), LNUMVAL( TIMER_MODE_AUTO ) },
|
{ LSTRKEY( "ALARM_AUTO" ), LNUMVAL( TIMER_MODE_AUTO ) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -338,6 +337,9 @@ LUALIB_API int luaopen_tmr( lua_State *L ){
|
||||||
ets_timer_setfn(&rtc_timer, rtc_callback, NULL);
|
ets_timer_setfn(&rtc_timer, rtc_callback, NULL);
|
||||||
ets_timer_arm_new(&rtc_timer, 1000, 1, 1);
|
ets_timer_arm_new(&rtc_timer, 1000, 1, 1);
|
||||||
|
|
||||||
return 0;
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,35 +100,34 @@ static int ICACHE_FLASH_ATTR tsl2561_lua_getchannels(lua_State* L) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LUA_REG_TYPE tsl2561_map[] =
|
// Module function map
|
||||||
{
|
const LUA_REG_TYPE tsl2561_map[] = {
|
||||||
{ LSTRKEY( "settiming" ), LFUNCVAL( tsl2561_lua_settiming)},
|
{ LSTRKEY( "settiming" ), LFUNCVAL( tsl2561_lua_settiming)},
|
||||||
{ LSTRKEY( "getlux" ), LFUNCVAL( tsl2561_lua_calclux )},
|
{ LSTRKEY( "getlux" ), LFUNCVAL( tsl2561_lua_calclux )},
|
||||||
{ LSTRKEY( "getrawchannels" ), LFUNCVAL( tsl2561_lua_getchannels )},
|
{ LSTRKEY( "getrawchannels" ), LFUNCVAL( tsl2561_lua_getchannels )},
|
||||||
{ LSTRKEY( "init" ), LFUNCVAL( tsl2561_init )},
|
{ LSTRKEY( "init" ), LFUNCVAL( tsl2561_init )},
|
||||||
|
{ LSTRKEY( "TSL2561_OK" ), LNUMVAL( TSL2561_ERROR_OK )},
|
||||||
{ LSTRKEY( "TSL2561_OK" ), LNUMVAL( TSL2561_ERROR_OK )},
|
|
||||||
{ LSTRKEY( "TSL2561_ERROR_I2CINIT" ), LNUMVAL( TSL2561_ERROR_I2CINIT )},
|
{ LSTRKEY( "TSL2561_ERROR_I2CINIT" ), LNUMVAL( TSL2561_ERROR_I2CINIT )},
|
||||||
{ LSTRKEY( "TSL2561_ERROR_I2CBUSY" ), LNUMVAL( TSL2561_ERROR_I2CBUSY )},
|
{ LSTRKEY( "TSL2561_ERROR_I2CBUSY" ), LNUMVAL( TSL2561_ERROR_I2CBUSY )},
|
||||||
{ LSTRKEY( "TSL2561_ERROR_NOINIT" ), LNUMVAL( TSL2561_ERROR_NOINIT )},
|
{ LSTRKEY( "TSL2561_ERROR_NOINIT" ), LNUMVAL( TSL2561_ERROR_NOINIT )},
|
||||||
{ LSTRKEY( "TSL2561_ERROR_LAST" ), LNUMVAL( TSL2561_ERROR_LAST )},
|
{ LSTRKEY( "TSL2561_ERROR_LAST" ), LNUMVAL( TSL2561_ERROR_LAST )},
|
||||||
|
{ LSTRKEY( "INTEGRATIONTIME_13MS" ), LNUMVAL( TSL2561_INTEGRATIONTIME_13MS )},
|
||||||
{ LSTRKEY( "INTEGRATIONTIME_13MS" ), LNUMVAL( TSL2561_INTEGRATIONTIME_13MS )},
|
|
||||||
{ LSTRKEY( "INTEGRATIONTIME_101MS" ), LNUMVAL( TSL2561_INTEGRATIONTIME_101MS )},
|
{ LSTRKEY( "INTEGRATIONTIME_101MS" ), LNUMVAL( TSL2561_INTEGRATIONTIME_101MS )},
|
||||||
{ LSTRKEY( "INTEGRATIONTIME_402MS" ), LNUMVAL( TSL2561_INTEGRATIONTIME_402MS )},
|
{ LSTRKEY( "INTEGRATIONTIME_402MS" ), LNUMVAL( TSL2561_INTEGRATIONTIME_402MS )},
|
||||||
{ LSTRKEY( "GAIN_1X" ), LNUMVAL( TSL2561_GAIN_1X )},
|
{ LSTRKEY( "GAIN_1X" ), LNUMVAL( TSL2561_GAIN_1X )},
|
||||||
{ LSTRKEY( "GAIN_16X" ), LNUMVAL( TSL2561_GAIN_16X )},
|
{ LSTRKEY( "GAIN_16X" ), LNUMVAL( TSL2561_GAIN_16X )},
|
||||||
|
{ LSTRKEY( "PACKAGE_CS" ), LNUMVAL( TSL2561_PACKAGE_CS )},
|
||||||
{ LSTRKEY( "PACKAGE_CS" ), LNUMVAL( TSL2561_PACKAGE_CS )},
|
{ LSTRKEY( "PACKAGE_T_FN_CL" ), LNUMVAL( TSL2561_PACKAGE_T_FN_CL )},
|
||||||
{ LSTRKEY( "PACKAGE_T_FN_CL" ), LNUMVAL( TSL2561_PACKAGE_T_FN_CL )},
|
{ LSTRKEY( "ADDRESS_GND" ), LNUMVAL( TSL2561_ADDRESS_GND )},
|
||||||
|
{ LSTRKEY( "ADDRESS_FLOAT" ), LNUMVAL( TSL2561_ADDRESS_FLOAT )},
|
||||||
{ LSTRKEY( "ADDRESS_GND" ), LNUMVAL( TSL2561_ADDRESS_GND )},
|
{ LSTRKEY( "ADDRESS_VDD" ), LNUMVAL( TSL2561_ADDRESS_VDD )},
|
||||||
{ LSTRKEY( "ADDRESS_FLOAT" ), LNUMVAL( TSL2561_ADDRESS_FLOAT )},
|
|
||||||
{ LSTRKEY( "ADDRESS_VDD" ), LNUMVAL( TSL2561_ADDRESS_VDD )},
|
|
||||||
|
|
||||||
{ LNILKEY, LNILVAL}
|
{ LNILKEY, LNILVAL}
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_tsl2561(lua_State *L) {
|
LUALIB_API int luaopen_tsl2561(lua_State *L) {
|
||||||
return 0;
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -1025,92 +1025,92 @@ U8G_DISPLAY_TABLE_SPI
|
||||||
|
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
static const LUA_REG_TYPE lu8g_display_map[] =
|
static const LUA_REG_TYPE lu8g_display_map[] = {
|
||||||
{
|
{ LSTRKEY( "begin" ), LFUNCVAL( lu8g_begin ) },
|
||||||
{ LSTRKEY( "begin" ), LFUNCVAL( lu8g_begin ) },
|
{ LSTRKEY( "drawBitmap" ), LFUNCVAL( lu8g_drawBitmap ) },
|
||||||
{ LSTRKEY( "drawBitmap" ), LFUNCVAL( lu8g_drawBitmap ) },
|
{ LSTRKEY( "drawBox" ), LFUNCVAL( lu8g_drawBox ) },
|
||||||
{ LSTRKEY( "drawBox" ), LFUNCVAL( lu8g_drawBox ) },
|
{ LSTRKEY( "drawCircle" ), LFUNCVAL( lu8g_drawCircle ) },
|
||||||
{ LSTRKEY( "drawCircle" ), LFUNCVAL( lu8g_drawCircle ) },
|
{ LSTRKEY( "drawDisc" ), LFUNCVAL( lu8g_drawDisc ) },
|
||||||
{ LSTRKEY( "drawDisc" ), LFUNCVAL( lu8g_drawDisc ) },
|
{ LSTRKEY( "drawEllipse" ), LFUNCVAL( lu8g_drawEllipse ) },
|
||||||
{ LSTRKEY( "drawEllipse" ), LFUNCVAL( lu8g_drawEllipse ) },
|
{ LSTRKEY( "drawFilledEllipse" ), LFUNCVAL( lu8g_drawFilledEllipse ) },
|
||||||
{ LSTRKEY( "drawFilledEllipse" ), LFUNCVAL( lu8g_drawFilledEllipse ) },
|
{ LSTRKEY( "drawFrame" ), LFUNCVAL( lu8g_drawFrame ) },
|
||||||
{ LSTRKEY( "drawFrame" ), LFUNCVAL( lu8g_drawFrame ) },
|
{ LSTRKEY( "drawHLine" ), LFUNCVAL( lu8g_drawHLine ) },
|
||||||
{ LSTRKEY( "drawHLine" ), LFUNCVAL( lu8g_drawHLine ) },
|
{ LSTRKEY( "drawLine" ), LFUNCVAL( lu8g_drawLine ) },
|
||||||
{ LSTRKEY( "drawLine" ), LFUNCVAL( lu8g_drawLine ) },
|
{ LSTRKEY( "drawPixel" ), LFUNCVAL( lu8g_drawPixel ) },
|
||||||
{ LSTRKEY( "drawPixel" ), LFUNCVAL( lu8g_drawPixel ) },
|
{ LSTRKEY( "drawRBox" ), LFUNCVAL( lu8g_drawRBox ) },
|
||||||
{ LSTRKEY( "drawRBox" ), LFUNCVAL( lu8g_drawRBox ) },
|
{ LSTRKEY( "drawRFrame" ), LFUNCVAL( lu8g_drawRFrame ) },
|
||||||
{ LSTRKEY( "drawRFrame" ), LFUNCVAL( lu8g_drawRFrame ) },
|
{ LSTRKEY( "drawStr" ), LFUNCVAL( lu8g_drawStr ) },
|
||||||
{ LSTRKEY( "drawStr" ), LFUNCVAL( lu8g_drawStr ) },
|
{ LSTRKEY( "drawStr90" ), LFUNCVAL( lu8g_drawStr90 ) },
|
||||||
{ LSTRKEY( "drawStr90" ), LFUNCVAL( lu8g_drawStr90 ) },
|
{ LSTRKEY( "drawStr180" ), LFUNCVAL( lu8g_drawStr180 ) },
|
||||||
{ LSTRKEY( "drawStr180" ), LFUNCVAL( lu8g_drawStr180 ) },
|
{ LSTRKEY( "drawStr270" ), LFUNCVAL( lu8g_drawStr270 ) },
|
||||||
{ LSTRKEY( "drawStr270" ), LFUNCVAL( lu8g_drawStr270 ) },
|
{ LSTRKEY( "drawTriangle" ), LFUNCVAL( lu8g_drawTriangle ) },
|
||||||
{ LSTRKEY( "drawTriangle" ), LFUNCVAL( lu8g_drawTriangle ) },
|
{ LSTRKEY( "drawVLine" ), LFUNCVAL( lu8g_drawVLine ) },
|
||||||
{ LSTRKEY( "drawVLine" ), LFUNCVAL( lu8g_drawVLine ) },
|
{ LSTRKEY( "drawXBM" ), LFUNCVAL( lu8g_drawXBM ) },
|
||||||
{ LSTRKEY( "drawXBM" ), LFUNCVAL( lu8g_drawXBM ) },
|
{ LSTRKEY( "firstPage" ), LFUNCVAL( lu8g_firstPage ) },
|
||||||
{ LSTRKEY( "firstPage" ), LFUNCVAL( lu8g_firstPage ) },
|
{ LSTRKEY( "getColorIndex" ), LFUNCVAL( lu8g_getColorIndex ) },
|
||||||
{ LSTRKEY( "getColorIndex" ), LFUNCVAL( lu8g_getColorIndex ) },
|
{ LSTRKEY( "getFontAscent" ), LFUNCVAL( lu8g_getFontAscent ) },
|
||||||
{ LSTRKEY( "getFontAscent" ), LFUNCVAL( lu8g_getFontAscent ) },
|
{ LSTRKEY( "getFontDescent" ), LFUNCVAL( lu8g_getFontDescent ) },
|
||||||
{ LSTRKEY( "getFontDescent" ), LFUNCVAL( lu8g_getFontDescent ) },
|
{ LSTRKEY( "getFontLineSpacing" ), LFUNCVAL( lu8g_getFontLineSpacing ) },
|
||||||
{ LSTRKEY( "getFontLineSpacing" ), LFUNCVAL( lu8g_getFontLineSpacing ) },
|
{ LSTRKEY( "getHeight" ), LFUNCVAL( lu8g_getHeight ) },
|
||||||
{ LSTRKEY( "getHeight" ), LFUNCVAL( lu8g_getHeight ) },
|
{ LSTRKEY( "getMode" ), LFUNCVAL( lu8g_getMode ) },
|
||||||
{ LSTRKEY( "getMode" ), LFUNCVAL( lu8g_getMode ) },
|
{ LSTRKEY( "getStrWidth" ), LFUNCVAL( lu8g_getStrWidth ) },
|
||||||
{ LSTRKEY( "getStrWidth" ), LFUNCVAL( lu8g_getStrWidth ) },
|
{ LSTRKEY( "getWidth" ), LFUNCVAL( lu8g_getWidth ) },
|
||||||
{ LSTRKEY( "getWidth" ), LFUNCVAL( lu8g_getWidth ) },
|
{ LSTRKEY( "nextPage" ), LFUNCVAL( lu8g_nextPage ) },
|
||||||
{ LSTRKEY( "nextPage" ), LFUNCVAL( lu8g_nextPage ) },
|
{ LSTRKEY( "setColorIndex" ), LFUNCVAL( lu8g_setColorIndex ) },
|
||||||
{ LSTRKEY( "setColorIndex" ), LFUNCVAL( lu8g_setColorIndex ) },
|
{ LSTRKEY( "setDefaultBackgroundColor" ), LFUNCVAL( lu8g_setDefaultBackgroundColor ) },
|
||||||
{ LSTRKEY( "setDefaultBackgroundColor" ), LFUNCVAL( lu8g_setDefaultBackgroundColor ) },
|
{ LSTRKEY( "setDefaultForegroundColor" ), LFUNCVAL( lu8g_setDefaultForegroundColor ) },
|
||||||
{ LSTRKEY( "setDefaultForegroundColor" ), LFUNCVAL( lu8g_setDefaultForegroundColor ) },
|
{ LSTRKEY( "setFont" ), LFUNCVAL( lu8g_setFont ) },
|
||||||
{ LSTRKEY( "setFont" ), LFUNCVAL( lu8g_setFont ) },
|
{ LSTRKEY( "setFontLineSpacingFactor" ), LFUNCVAL( lu8g_setFontLineSpacingFactor ) },
|
||||||
{ LSTRKEY( "setFontLineSpacingFactor" ), LFUNCVAL( lu8g_setFontLineSpacingFactor ) },
|
{ LSTRKEY( "setFontPosBaseline" ), LFUNCVAL( lu8g_setFontPosBaseline ) },
|
||||||
{ LSTRKEY( "setFontPosBaseline" ), LFUNCVAL( lu8g_setFontPosBaseline ) },
|
{ LSTRKEY( "setFontPosBottom" ), LFUNCVAL( lu8g_setFontPosBottom ) },
|
||||||
{ LSTRKEY( "setFontPosBottom" ), LFUNCVAL( lu8g_setFontPosBottom ) },
|
{ LSTRKEY( "setFontPosCenter" ), LFUNCVAL( lu8g_setFontPosCenter ) },
|
||||||
{ LSTRKEY( "setFontPosCenter" ), LFUNCVAL( lu8g_setFontPosCenter ) },
|
{ LSTRKEY( "setFontPosTop" ), LFUNCVAL( lu8g_setFontPosTop ) },
|
||||||
{ LSTRKEY( "setFontPosTop" ), LFUNCVAL( lu8g_setFontPosTop ) },
|
{ LSTRKEY( "setFontRefHeightAll" ), LFUNCVAL( lu8g_setFontRefHeightAll ) },
|
||||||
{ LSTRKEY( "setFontRefHeightAll" ), LFUNCVAL( lu8g_setFontRefHeightAll ) },
|
{ LSTRKEY( "setFontRefHeightExtendedText" ), LFUNCVAL( lu8g_setFontRefHeightExtendedText ) },
|
||||||
{ LSTRKEY( "setFontRefHeightExtendedText" ), LFUNCVAL( lu8g_setFontRefHeightExtendedText ) },
|
{ LSTRKEY( "setFontRefHeightText" ), LFUNCVAL( lu8g_setFontRefHeightText ) },
|
||||||
{ LSTRKEY( "setFontRefHeightText" ), LFUNCVAL( lu8g_setFontRefHeightText ) },
|
{ LSTRKEY( "setRot90" ), LFUNCVAL( lu8g_setRot90 ) },
|
||||||
{ LSTRKEY( "setRot90" ), LFUNCVAL( lu8g_setRot90 ) },
|
{ LSTRKEY( "setRot180" ), LFUNCVAL( lu8g_setRot180 ) },
|
||||||
{ LSTRKEY( "setRot180" ), LFUNCVAL( lu8g_setRot180 ) },
|
{ LSTRKEY( "setRot270" ), LFUNCVAL( lu8g_setRot270 ) },
|
||||||
{ LSTRKEY( "setRot270" ), LFUNCVAL( lu8g_setRot270 ) },
|
{ LSTRKEY( "setScale2x2" ), LFUNCVAL( lu8g_setScale2x2 ) },
|
||||||
{ LSTRKEY( "setScale2x2" ), LFUNCVAL( lu8g_setScale2x2 ) },
|
{ LSTRKEY( "sleepOff" ), LFUNCVAL( lu8g_sleepOff ) },
|
||||||
{ LSTRKEY( "sleepOff" ), LFUNCVAL( lu8g_sleepOff ) },
|
{ LSTRKEY( "sleepOn" ), LFUNCVAL( lu8g_sleepOn ) },
|
||||||
{ LSTRKEY( "sleepOn" ), LFUNCVAL( lu8g_sleepOn ) },
|
{ LSTRKEY( "undoRotation" ), LFUNCVAL( lu8g_undoRotation ) },
|
||||||
{ LSTRKEY( "undoRotation" ), LFUNCVAL( lu8g_undoRotation ) },
|
{ LSTRKEY( "undoScale" ), LFUNCVAL( lu8g_undoScale ) },
|
||||||
{ LSTRKEY( "undoScale" ), LFUNCVAL( lu8g_undoScale ) },
|
{ LSTRKEY( "__gc" ), LFUNCVAL( lu8g_close_display ) },
|
||||||
{ LSTRKEY( "__gc" ), LFUNCVAL( lu8g_close_display ) },
|
{ LSTRKEY( "__index" ), LROVAL( lu8g_display_map ) },
|
||||||
{ LSTRKEY( "__index" ), LROVAL ( lu8g_display_map ) },
|
{ LNILKEY, LNILVAL }
|
||||||
{ LNILKEY, LNILVAL }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const LUA_REG_TYPE lu8g_map[] =
|
|
||||||
{
|
|
||||||
#undef U8G_DISPLAY_TABLE_ENTRY
|
#undef U8G_DISPLAY_TABLE_ENTRY
|
||||||
#define U8G_DISPLAY_TABLE_ENTRY(device) { LSTRKEY( #device ), LFUNCVAL ( lu8g_ ##device ) },
|
|
||||||
U8G_DISPLAY_TABLE_I2C
|
|
||||||
U8G_DISPLAY_TABLE_SPI
|
|
||||||
|
|
||||||
// Register fonts
|
|
||||||
#undef U8G_FONT_TABLE_ENTRY
|
#undef U8G_FONT_TABLE_ENTRY
|
||||||
#define U8G_FONT_TABLE_ENTRY(font) { LSTRKEY( #font ), LUDATA( (void *)(u8g_ ## font) ) },
|
|
||||||
U8G_FONT_TABLE
|
|
||||||
|
|
||||||
// Options for circle/ ellipse drawing
|
const LUA_REG_TYPE lu8g_map[] = {
|
||||||
{ LSTRKEY( "DRAW_UPPER_RIGHT" ), LNUMVAL( U8G_DRAW_UPPER_RIGHT ) },
|
#define U8G_DISPLAY_TABLE_ENTRY(device) \
|
||||||
{ LSTRKEY( "DRAW_UPPER_LEFT" ), LNUMVAL( U8G_DRAW_UPPER_LEFT ) },
|
{ LSTRKEY( #device ), LFUNCVAL ( lu8g_ ##device ) },
|
||||||
{ LSTRKEY( "DRAW_LOWER_RIGHT" ), LNUMVAL( U8G_DRAW_LOWER_RIGHT ) },
|
U8G_DISPLAY_TABLE_I2C
|
||||||
{ LSTRKEY( "DRAW_LOWER_LEFT" ), LNUMVAL( U8G_DRAW_LOWER_LEFT ) },
|
U8G_DISPLAY_TABLE_SPI
|
||||||
{ LSTRKEY( "DRAW_ALL" ), LNUMVAL( U8G_DRAW_ALL ) },
|
// Register fonts
|
||||||
|
#define U8G_FONT_TABLE_ENTRY(font) \
|
||||||
// Display modes
|
{ LSTRKEY( #font ), LUDATA( (void *)(u8g_ ## font) ) },
|
||||||
{ LSTRKEY( "MODE_BW" ), LNUMVAL( U8G_MODE_BW ) },
|
U8G_FONT_TABLE
|
||||||
{ LSTRKEY( "MODE_GRAY2BIT" ), LNUMVAL( U8G_MODE_GRAY2BIT ) },
|
// Options for circle/ ellipse drawing
|
||||||
|
{ LSTRKEY( "DRAW_UPPER_RIGHT" ), LNUMVAL( U8G_DRAW_UPPER_RIGHT ) },
|
||||||
{ LSTRKEY( "__metatable" ), LROVAL( lu8g_map ) },
|
{ LSTRKEY( "DRAW_UPPER_LEFT" ), LNUMVAL( U8G_DRAW_UPPER_LEFT ) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ 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 ) },
|
||||||
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_u8g( lua_State *L )
|
LUALIB_API int luaopen_u8g( lua_State *L ) {
|
||||||
{
|
luaL_rometatable(L, "u8g.display", (void *)lu8g_display_map); // create metatable
|
||||||
luaL_rometatable(L, "u8g.display", (void *)lu8g_display_map); // create metatable
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "auxmods.h"
|
|
||||||
#include "lrodefs.h"
|
#include "lrodefs.h"
|
||||||
|
|
||||||
#include "c_types.h"
|
#include "c_types.h"
|
||||||
|
@ -156,16 +155,18 @@ static int uart_write( lua_State* L )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
const LUA_REG_TYPE uart_map[] =
|
const LUA_REG_TYPE uart_map[] = {
|
||||||
{
|
|
||||||
{ LSTRKEY( "setup" ), LFUNCVAL( uart_setup ) },
|
{ LSTRKEY( "setup" ), LFUNCVAL( uart_setup ) },
|
||||||
{ LSTRKEY( "write" ), LFUNCVAL( uart_write ) },
|
{ LSTRKEY( "write" ), LFUNCVAL( uart_write ) },
|
||||||
{ LSTRKEY( "on" ), LFUNCVAL( uart_on ) },
|
{ LSTRKEY( "on" ), LFUNCVAL( uart_on ) },
|
||||||
{ LSTRKEY( "alt" ), LFUNCVAL( uart_alt ) },
|
{ LSTRKEY( "alt" ), LFUNCVAL( uart_alt ) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_uart( lua_State *L )
|
LUALIB_API int luaopen_uart( lua_State *L ) {
|
||||||
{
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -1337,96 +1337,95 @@ static int wifi_ap_dhcp_stop( lua_State* L )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module function map
|
// Module function map
|
||||||
static const LUA_REG_TYPE wifi_station_map[] =
|
static const LUA_REG_TYPE wifi_station_map[] = {
|
||||||
{
|
{ LSTRKEY( "getconfig" ), LFUNCVAL( wifi_station_getconfig ) },
|
||||||
{ LSTRKEY( "getconfig" ), LFUNCVAL ( wifi_station_getconfig ) },
|
{ LSTRKEY( "config" ), LFUNCVAL( wifi_station_config ) },
|
||||||
{ LSTRKEY( "config" ), LFUNCVAL ( wifi_station_config ) },
|
{ LSTRKEY( "connect" ), LFUNCVAL( wifi_station_connect4lua ) },
|
||||||
{ LSTRKEY( "connect" ), LFUNCVAL ( wifi_station_connect4lua ) },
|
{ LSTRKEY( "disconnect" ), LFUNCVAL( wifi_station_disconnect4lua ) },
|
||||||
{ LSTRKEY( "disconnect" ), LFUNCVAL ( wifi_station_disconnect4lua ) },
|
{ LSTRKEY( "autoconnect" ), LFUNCVAL( wifi_station_setauto ) },
|
||||||
{ LSTRKEY( "autoconnect" ), LFUNCVAL ( wifi_station_setauto ) },
|
{ LSTRKEY( "getip" ), LFUNCVAL( wifi_station_getip ) },
|
||||||
{ LSTRKEY( "getip" ), LFUNCVAL ( wifi_station_getip ) },
|
{ LSTRKEY( "setip" ), LFUNCVAL( wifi_station_setip ) },
|
||||||
{ LSTRKEY( "setip" ), LFUNCVAL ( wifi_station_setip ) },
|
{ LSTRKEY( "getbroadcast" ), LFUNCVAL( wifi_station_getbroadcast) },
|
||||||
{ LSTRKEY( "getbroadcast" ), LFUNCVAL ( wifi_station_getbroadcast) },
|
{ LSTRKEY( "getmac" ), LFUNCVAL( wifi_station_getmac ) },
|
||||||
{ LSTRKEY( "getmac" ), LFUNCVAL ( wifi_station_getmac ) },
|
{ LSTRKEY( "setmac" ), LFUNCVAL( wifi_station_setmac ) },
|
||||||
{ LSTRKEY( "setmac" ), LFUNCVAL ( wifi_station_setmac ) },
|
{ LSTRKEY( "getap" ), LFUNCVAL( wifi_station_listap ) },
|
||||||
{ LSTRKEY( "getap" ), LFUNCVAL ( wifi_station_listap ) },
|
{ LSTRKEY( "status" ), LFUNCVAL( wifi_station_status ) },
|
||||||
{ LSTRKEY( "status" ), LFUNCVAL ( wifi_station_status ) },
|
{ LSTRKEY( "eventMonReg" ), LFUNCVAL( wifi_station_event_mon_reg ) },
|
||||||
{ LSTRKEY( "eventMonReg" ), LFUNCVAL ( wifi_station_event_mon_reg ) },
|
{ LSTRKEY( "eventMonStart" ), LFUNCVAL( wifi_station_event_mon_start ) },
|
||||||
{ LSTRKEY( "eventMonStart" ), LFUNCVAL ( wifi_station_event_mon_start ) },
|
{ LSTRKEY( "eventMonStop" ), LFUNCVAL( wifi_station_event_mon_stop ) },
|
||||||
{ LSTRKEY( "eventMonStop" ), LFUNCVAL ( wifi_station_event_mon_stop ) },
|
|
||||||
{ LNILKEY, LNILVAL }
|
{ 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( "config" ), LFUNCVAL( wifi_ap_dhcp_config ) },
|
{ LSTRKEY( "start" ), LFUNCVAL( wifi_ap_dhcp_start ) },
|
||||||
{ LSTRKEY( "start" ), LFUNCVAL( wifi_ap_dhcp_start ) },
|
{ LSTRKEY( "stop" ), LFUNCVAL( wifi_ap_dhcp_stop ) },
|
||||||
{ LSTRKEY( "stop" ), LFUNCVAL( wifi_ap_dhcp_stop ) },
|
|
||||||
{ LNILKEY, LNILVAL }
|
{ 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( "config" ), LFUNCVAL( wifi_ap_config ) },
|
{ LSTRKEY( "getip" ), LFUNCVAL( wifi_ap_getip ) },
|
||||||
{ LSTRKEY( "getip" ), LFUNCVAL ( wifi_ap_getip ) },
|
{ LSTRKEY( "setip" ), LFUNCVAL( wifi_ap_setip ) },
|
||||||
{ LSTRKEY( "setip" ), LFUNCVAL ( wifi_ap_setip ) },
|
{ LSTRKEY( "getbroadcast" ), LFUNCVAL( wifi_ap_getbroadcast) },
|
||||||
{ LSTRKEY( "getbroadcast" ), LFUNCVAL ( wifi_ap_getbroadcast) },
|
{ LSTRKEY( "getmac" ), LFUNCVAL( wifi_ap_getmac ) },
|
||||||
{ LSTRKEY( "getmac" ), LFUNCVAL ( wifi_ap_getmac ) },
|
{ LSTRKEY( "setmac" ), LFUNCVAL( wifi_ap_setmac ) },
|
||||||
{ LSTRKEY( "setmac" ), LFUNCVAL ( wifi_ap_setmac ) },
|
{ LSTRKEY( "getclient" ), LFUNCVAL( wifi_ap_listclient ) },
|
||||||
{ LSTRKEY( "getclient" ), LFUNCVAL ( wifi_ap_listclient ) },
|
{ LSTRKEY( "getconfig" ), LFUNCVAL( wifi_ap_getconfig ) },
|
||||||
{ LSTRKEY( "getconfig" ), LFUNCVAL( wifi_ap_getconfig ) },
|
{ LSTRKEY( "dhcp" ), LROVAL( wifi_ap_dhcp_map ) },
|
||||||
{ LSTRKEY( "dhcp" ), LROVAL( wifi_ap_dhcp_map ) },
|
//{ LSTRKEY( "__metatable" ), LROVAL( wifi_ap_map ) },
|
||||||
|
|
||||||
// { LSTRKEY( "__metatable" ), LROVAL( wifi_ap_map ) },
|
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
const LUA_REG_TYPE wifi_map[] =
|
const LUA_REG_TYPE wifi_map[] = {
|
||||||
{
|
{ LSTRKEY( "setmode" ), LFUNCVAL( wifi_setmode ) },
|
||||||
{ LSTRKEY( "setmode" ), LFUNCVAL( wifi_setmode ) },
|
{ LSTRKEY( "getmode" ), LFUNCVAL( wifi_getmode ) },
|
||||||
{ LSTRKEY( "getmode" ), LFUNCVAL( wifi_getmode ) },
|
{ LSTRKEY( "getchannel" ), LFUNCVAL( wifi_getchannel ) },
|
||||||
{ LSTRKEY( "getchannel" ), LFUNCVAL( wifi_getchannel ) },
|
{ LSTRKEY( "setphymode" ), LFUNCVAL( wifi_setphymode ) },
|
||||||
{ LSTRKEY( "setphymode" ), LFUNCVAL( wifi_setphymode ) },
|
{ LSTRKEY( "getphymode" ), LFUNCVAL( wifi_getphymode ) },
|
||||||
{ LSTRKEY( "getphymode" ), LFUNCVAL( wifi_getphymode ) },
|
{ LSTRKEY( "sleep" ), LFUNCVAL( wifi_sleep ) },
|
||||||
{ LSTRKEY( "sleep" ), LFUNCVAL( wifi_sleep ) },
|
{ LSTRKEY( "startsmart" ), LFUNCVAL( wifi_start_smart ) },
|
||||||
{ LSTRKEY( "startsmart" ), LFUNCVAL( wifi_start_smart ) },
|
{ LSTRKEY( "stopsmart" ), LFUNCVAL( wifi_exit_smart ) },
|
||||||
{ LSTRKEY( "stopsmart" ), LFUNCVAL( wifi_exit_smart ) },
|
{ LSTRKEY( "sleeptype" ), LFUNCVAL( wifi_sleeptype ) },
|
||||||
{ LSTRKEY( "sleeptype" ), LFUNCVAL( wifi_sleeptype ) },
|
|
||||||
|
|
||||||
{ LSTRKEY( "sta" ), LROVAL( wifi_station_map ) },
|
{ LSTRKEY( "sta" ), LROVAL( wifi_station_map ) },
|
||||||
{ LSTRKEY( "ap" ), LROVAL( wifi_ap_map ) },
|
{ LSTRKEY( "ap" ), LROVAL( wifi_ap_map ) },
|
||||||
|
|
||||||
{ LSTRKEY( "NULLMODE" ), LNUMVAL( NULL_MODE ) },
|
{ LSTRKEY( "NULLMODE" ), LNUMVAL( NULL_MODE ) },
|
||||||
{ LSTRKEY( "STATION" ), LNUMVAL( STATION_MODE ) },
|
{ LSTRKEY( "STATION" ), LNUMVAL( STATION_MODE ) },
|
||||||
{ LSTRKEY( "SOFTAP" ), LNUMVAL( SOFTAP_MODE ) },
|
{ LSTRKEY( "SOFTAP" ), LNUMVAL( SOFTAP_MODE ) },
|
||||||
{ LSTRKEY( "STATIONAP" ), LNUMVAL( STATIONAP_MODE ) },
|
{ LSTRKEY( "STATIONAP" ), LNUMVAL( STATIONAP_MODE ) },
|
||||||
|
|
||||||
{ LSTRKEY( "PHYMODE_B" ), LNUMVAL( PHY_MODE_11B ) },
|
{ LSTRKEY( "PHYMODE_B" ), LNUMVAL( PHY_MODE_11B ) },
|
||||||
{ LSTRKEY( "PHYMODE_G" ), LNUMVAL( PHY_MODE_11G ) },
|
{ LSTRKEY( "PHYMODE_G" ), LNUMVAL( PHY_MODE_11G ) },
|
||||||
{ LSTRKEY( "PHYMODE_N" ), LNUMVAL( PHY_MODE_11N ) },
|
{ LSTRKEY( "PHYMODE_N" ), LNUMVAL( PHY_MODE_11N ) },
|
||||||
|
|
||||||
{ LSTRKEY( "NONE_SLEEP" ), LNUMVAL( NONE_SLEEP_T ) },
|
{ LSTRKEY( "NONE_SLEEP" ), LNUMVAL( NONE_SLEEP_T ) },
|
||||||
{ LSTRKEY( "LIGHT_SLEEP" ), LNUMVAL( LIGHT_SLEEP_T ) },
|
{ LSTRKEY( "LIGHT_SLEEP" ), LNUMVAL( LIGHT_SLEEP_T ) },
|
||||||
{ LSTRKEY( "MODEM_SLEEP" ), LNUMVAL( MODEM_SLEEP_T ) },
|
{ LSTRKEY( "MODEM_SLEEP" ), LNUMVAL( MODEM_SLEEP_T ) },
|
||||||
|
|
||||||
{ LSTRKEY( "OPEN" ), LNUMVAL( AUTH_OPEN ) },
|
{ LSTRKEY( "OPEN" ), LNUMVAL( AUTH_OPEN ) },
|
||||||
// { LSTRKEY( "WEP" ), LNUMVAL( AUTH_WEP ) },
|
//{ LSTRKEY( "WEP" ), LNUMVAL( AUTH_WEP ) },
|
||||||
{ LSTRKEY( "WPA_PSK" ), LNUMVAL( AUTH_WPA_PSK ) },
|
{ LSTRKEY( "WPA_PSK" ), LNUMVAL( AUTH_WPA_PSK ) },
|
||||||
{ LSTRKEY( "WPA2_PSK" ), LNUMVAL( AUTH_WPA2_PSK ) },
|
{ LSTRKEY( "WPA2_PSK" ), LNUMVAL( AUTH_WPA2_PSK ) },
|
||||||
{ LSTRKEY( "WPA_WPA2_PSK" ), LNUMVAL( AUTH_WPA_WPA2_PSK ) },
|
{ LSTRKEY( "WPA_WPA2_PSK" ), LNUMVAL( AUTH_WPA_WPA2_PSK ) },
|
||||||
|
|
||||||
{ LSTRKEY( "STA_IDLE" ), LNUMVAL( STATION_IDLE ) },
|
{ LSTRKEY( "STA_IDLE" ), LNUMVAL( STATION_IDLE ) },
|
||||||
{ LSTRKEY( "STA_CONNECTING" ), LNUMVAL( STATION_CONNECTING ) },
|
{ LSTRKEY( "STA_CONNECTING" ), LNUMVAL( STATION_CONNECTING ) },
|
||||||
{ LSTRKEY( "STA_WRONGPWD" ), LNUMVAL( STATION_WRONG_PASSWORD ) },
|
{ LSTRKEY( "STA_WRONGPWD" ), LNUMVAL( STATION_WRONG_PASSWORD ) },
|
||||||
{ LSTRKEY( "STA_APNOTFOUND" ), LNUMVAL( STATION_NO_AP_FOUND ) },
|
{ LSTRKEY( "STA_APNOTFOUND" ), LNUMVAL( STATION_NO_AP_FOUND ) },
|
||||||
{ LSTRKEY( "STA_FAIL" ), LNUMVAL( STATION_CONNECT_FAIL ) },
|
{ LSTRKEY( "STA_FAIL" ), LNUMVAL( STATION_CONNECT_FAIL ) },
|
||||||
{ LSTRKEY( "STA_GOTIP" ), LNUMVAL( STATION_GOT_IP ) },
|
{ LSTRKEY( "STA_GOTIP" ), LNUMVAL( STATION_GOT_IP ) },
|
||||||
|
|
||||||
{ LSTRKEY( "__metatable" ), LROVAL( wifi_map ) },
|
{ LSTRKEY( "__metatable" ), LROVAL( wifi_map ) },
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
};
|
};
|
||||||
|
|
||||||
LUALIB_API int luaopen_wifi( lua_State *L )
|
LUALIB_API int luaopen_wifi( lua_State *L )
|
||||||
{
|
{
|
||||||
|
#if MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
# error "NodeMCU modules must be build with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,4 +243,20 @@ int platform_flash_erase_sector( uint32_t sector_id );
|
||||||
void* platform_get_first_free_ram( unsigned id );
|
void* platform_get_first_free_ram( unsigned id );
|
||||||
void* platform_get_last_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
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue