Current Lua downloadable firmware will be posted here

User avatar
By dayzman
#16171 Suppose I rebuild nodemcu with the addition of a new driver written in C. Could C programs be run? If not, do the drivers need to be somehow translated to Lua functions?

Thanks
User avatar
By cal
#16175
dayzman wrote:Suppose I rebuild nodemcu with the addition of a new driver written in C. Could C programs be run? If not, do the drivers need to be somehow translated to Lua functions?

Thanks

Moin,

you would write a module in c that has a lua interface for that. See nodemcu source for examples.
Than you call it from lua.

Cal
User avatar
By dayzman
#16179
cal wrote:
dayzman wrote:Suppose I rebuild nodemcu with the addition of a new driver written in C. Could C programs be run? If not, do the drivers need to be somehow translated to Lua functions?

Thanks

Moin,

you would write a module in c that has a lua interface for that. See nodemcu source for examples.
Than you call it from lua.

Cal


I see. Do you know which examples might be helpful here? I've looked in /examples but they don't seem to be Lua interfaces.

Actually, are new drivers supposed to sit in /app/driver with header files in /include?

Thanks
User avatar
By cal
#16181 I don't really know.
But if I look at some recent additions like u8glib I see:

./lua_examples/u8glib - guess what ;-)
./app/modules/u8g.c - the lua integration

./app/u8glib - the c code
./app/include/u8g_config.h - the c include

That looks reasonable to me and I would use that as my template.

Hope that helps,
Cal