So you get docs and if the IDE doesn't convert the call for some reason, you still get a sensible warning.
For functions like sin/etc I'm afraid life gets difficult as you only have access to a very specific set of exported functions from Espruino. It's not just the math functions that are missing, but even the ability to convert doubles to ints and so on. You can:
Add a setLUT function or similar, and call that from JS with the right values (probably easier)
Use peek32(E.getAddressOf(Math.sin)) in JS to get the address of the JS Math.sin function and then pass that into your C code to call (but double conversion will probably still hit you).
Nether solution is great, but I don't see there's much of a way around it given how it's all working.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Thanks - yes, I'll add this. I'll do what I did for the assembler, like this: http://www.espruino.com/Reference#l_E_asm
So you get docs and if the IDE doesn't convert the call for some reason, you still get a sensible warning.
For functions like sin/etc I'm afraid life gets difficult as you only have access to a very specific set of exported functions from Espruino. It's not just the math functions that are missing, but even the ability to convert doubles to ints and so on. You can:
setLUT
function or similar, and call that from JS with the right values (probably easier)sin
- you could even copy Espruino's low memory version from https://github.com/espruino/Espruino/blob/master/libs/math/jswrap_math.c#L26 (note it's actually got a good explanation of why just pulling in the stdlibsin
wouldn't be so great).peek32(E.getAddressOf(Math.sin))
in JS to get the address of the JSMath.sin
function and then pass that into your C code to call (but double conversion will probably still hit you).Nether solution is great, but I don't see there's much of a way around it given how it's all working.