how can i register modules in lua firmware?
Posted: Fri Feb 13, 2015 1:54 pm
i am trying to add pcd8544 module in nodemcu firmware but i cant register "pcd8544" function. i wish to use something like this "pcd8544.init()" or "pcd8544.print("test")" but i cant do this.
i added this in auxmods.h
i added this in userconfig.h
also i added subdir and component i makefile and
i added this end of the pcd8544.c file
and i added this in modules.h
what am i missig?
i added this in auxmods.h
Code: Select all
#define AUXLIB_PCD8544 "pcd8544"
LUALIB_API int ( luaopen_pcd8544 )( lua_State *L );
i added this in userconfig.h
Code: Select all
#define LUA_USE_MODULES_PCD8544
also i added subdir and component i makefile and
i added this end of the pcd8544.c file
Code: Select all
// Module function map
#define MIN_OPT_LEVEL 2
#include "lrodefs.h"
const LUA_REG_TYPE pcd8544_map[] =
{
{ LSTRKEY( "init" ), LFUNCVAL( pcd8544_setup ) },
#if LUA_OPTIMIZE_MEMORY > 0
#endif
{ LNILKEY, LNILVAL }
};
LUALIB_API int luaopen_pcd8544( lua_State *L )
{
#if LUA_OPTIMIZE_MEMORY > 0
return 0;
#else // #if LUA_OPTIMIZE_MEMORY > 0
luaL_register( L, AUXLIB_PCD8544, pcd8544_map );
return 1;
#endif // #if LUA_OPTIMIZE_MEMORY > 0
}
and i added this in modules.h
Code: Select all
#if defined(LUA_USE_MODULES_PCD8544)
#define MODULES_PCD8544 "pcd8544"
#define ROM_MODULES_PCD8544 \
_ROM(MODULES_PCD8544, luaopen_pcd8544, pcd8544_map)
#else
#define ROM_MODULES_PCD8544
#endif
what am i missig?