You are reading a single comment by @Kim and its replies. Click here to read the full conversation.
  • Thanks for clarifying the code. It was already late yesterday and details such as that tend to get lost in those cases. The code is definitely JavaScript, but the JS code you write on an Espruino definitely has a different flavour.

    No idea which value causes the pow error, but it occurred when writing Math.sin(pos*Math.PI), 2) in the line that says digitalPulse(pin, 1, Math.pow(Math.sin(pos*Math.PI), 2)*cycle); .

    Thanks for the performance page, first time I see it.

    Overall, it would be good to have this software PWM on a lower, more barebone level for performance reasons. This code is nice to get your feet wet, but it does show how the Espruino can struggle with relatively simple things due to the embedded nature. I would also still suggest to introduce a delay() function. Where a timeout allows you to asynchronously (I think?) execute a function, a delay would allow similar behaviour during the execution of a function. I think this will simplify a lot of the code.

    And now that I think of it: are there any pages on power management on the Espruino? I know that there were a lot of things you could do such as enter a lower power state or even turn off USB, but information on those things is hard to find.

About

Avatar for Kim @Kim started