You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Thanks - yes, I'll add this. I'll do what I did for the assembler, like this:­m

    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 your own version of sin - you could even copy Espruino's low memory version from­b/master/libs/math/jswrap_math.c#L26 (note it's actually got a good explanation of why just pulling in the stdlib sin wouldn't be so great).
    • 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.


Avatar for Gordon @Gordon started