• Hi Gordon, thanks a lot! I will work through the examples. :-)

    Just for understanding: How would I disable the built-in Tensorflow module, if it becomes necessary?

    Running only the DSP code (and using Espruino's built-in Tensorflow module) would be an option that I would also prefer. However, the DSP code from EI uses libraries, partly with C++. I could not figure out yet if it would be possible to "inline" lenghty C/C++ code into Espruino and if Espruino compiler can compile C++ code, too? Maybe merge the code from EI into one file beforehand (as per https://www.reddit.com/r/cpp/comments/j2hg59/tool_to_merge_multiple_cc_files_into_a_single/ )?

  • I could not figure out yet if it would be possible to "inline" lenghty C/C++ code into Espruino

    Inline C is meant for short bits of code because the code+data is linked into small binary blob that runs from RAM. There is not that much RAM available for large code. It can be abused a lot and there could be hacks to the Inline C compiler to link it in different way so that it runs code from flash but nobody did that. Also Inline C is easier to use if you pass just simple types or pointers to flat byte arrays via (up to 4) parameters. Using JS variables/objects from inline C is a bit more complicated. All that is easier when code is built as part of Espruino firmware so for something that is not short and relatively simple linking the library to the firmware is better way and would take less space. And BTW the inline C source is actually passed to c++ compiler so c++ syntax in inline C works. The compiled javascript https://www.espruino.com/Compilation is translating JS into C++ and then compiling it. Here is reference counting class stolen from it https://gist.github.com/fanoush/4a5dcf777503461297cedf7e21e3c6b3#file-swd-js-L46 and used as part of Inline C https://gist.github.com/fanoush/4a5dcf777503461297cedf7e21e3c6b3#file-swd-js-L125

    Anyway, all the magic of calling native code is done by E.nativeCall() which is pretty generic so you can build your own compiler and linker and as long as you get your executable binary into ram or internal flash of the device you can run it.

    and if Espruino compiler can compile C++ code, too?

    tensorflow is c++ and is used as part of Espruino build, check https://github.com/espruino/Espruino/tree/master/libs/tensorflow

About

Avatar for user157902 @user157902 started