-->
Page 1 of 1

Run C code with new drivers?

PostPosted: Fri May 01, 2015 4:48 am
by dayzman
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

Re: Run C code with new drivers?

PostPosted: Fri May 01, 2015 5:35 am
by cal
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

Re: Run C code with new drivers?

PostPosted: Fri May 01, 2015 6:15 am
by dayzman
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

Re: Run C code with new drivers?

PostPosted: Fri May 01, 2015 7:16 am
by cal
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