You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • You used this code?

    var arr = new Uint8ClampedArray(100*3);
    var pos = 0;
    function getPattern() {
      pos++;
      for (var i=0;i<arr.length;i+=3)
        arr.set(E.HSBtoRGB((i+pos)*0.01,1,1,1),i­);
    }
    

    Espruino isn't as fast as something like MicroPython by an order of magnitude - it's just a side-effect of it trying to be very efficient with memory (which admittedly is less of an issue on ESP32). The ESP32 port also hasn't had any real speed optimisation done at all either.

    However for 100 LEDs I'm extremely surprised that it's that slow - even one of the 64MHz ARM Espruino boards should be doing significantly better than that.

  • This code is a little bit smoother I think, but it's about this same speed. I think looping through all objects in array is so slow, because I've commented out all other things, and it's still slow. I'm not even using neopixel library with this.

    function getPattern() {
      pos++;
      for (var i=0;i<arr.length;i+=3);
      console.log('a');
        //arr.set(E.HSBtoRGB((i+pos)*0.01,1,1,1)­,i);
    }
    
    

    I've done this

    arr.set(E.HSBtoRGB((0+pos)*0.01,1,1,1),0­);
    arr.set(E.HSBtoRGB((3+pos)*0.01,1,1,1),3­);
    arr.set(E.HSBtoRGB((6+pos)*0.01,1,1,1),6­);
    arr.set(E.HSBtoRGB((9+pos)*0.01,1,1,1),9­);
    [...] 97 times
    

    And it's still slow.

About

Avatar for Gordon @Gordon started