-->
Page 1 of 2

how can i register modules in lua firmware?

PostPosted: Fri Feb 13, 2015 1:54 pm
by alonewolfx2
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
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?

Re: how can i register modules in lua firmware?

PostPosted: Wed Feb 25, 2015 8:00 am
by pracas
Did you manage to figure it out? I'm struck on this as well. infact i did manage to register and run a module successfully but absent mindedly deleted the whole folder. Now back on this. It seems to be a small oversigth somewhere.

Re: how can i register modules in lua firmware?

PostPosted: Wed Feb 25, 2015 12:18 pm
by alonewolfx2
i didnt figure it out. i cant register functions. if anyone can help us i will be very happy.

Re: how can i register modules in lua firmware?

PostPosted: Wed Feb 25, 2015 4:07 pm
by devsaurus
What about pushing your code to github for a cross check?