Can Espruino code be used with other boards?

Posted on
  • I found no example or tutorial of this. If it can, how?

    Let us use the following c file as example:

    //What files do I include here???
    
    extern int getInputState(int pos);
    
    char* jsCode = "\
    function ShowInputsState()\
    {\
    	var res = '';\
    	for (var i = 0; i < 10; i++)\
    	{\
    		var state = getInputState(i);\
    		res += '\nState of Input ' + i + ' is: ' + state;\
    	}\
    	return res;\
    }\
    \
    print(ShowInputsState());\
    \
    ";
    
    void main()
    {
    	//What do I do here to run the js code???
    }
    
    
  • Hi @user53337, I think this comment, and actually the whole thread, should give you a start point...

  • Thank you, @asez73, it gave me the starting point, however I cannot make it compile; do you have any idea where the platform_config.h file is located?

  • You have to compile Espruino for a precise target which is the same as your C englobing program. Espruino is actually compiled with various options and files which are generated by some python programs called by make. That, probably, means using some makefile changes as you are not just compiling Espruino as an fully autonomous interpreter. Adding your own libraries and main C function is yet not so obvious...
    I have not, so far, attempted this.

  • For now, I'm trying to compile only Espruino with Visual Studio 2013.

  • Your best bet is to build with GCC under Linux - then it'll 'just work' for the boards it's designed for. If you're trying to use it with some other board then you'll probably have a hard time - you'll need to implement support for all the IO and timekeeping. There's some info on porting in the Readme in the GitHub repo.

    If you need to use Visual Studio you'll have to look at the Makefile and then figure out what you need to add to your visual studio project to emulate what it's doing.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Can Espruino code be used with other boards?

Posted by Avatar for user53337 @user53337

Actions