Extensions to Espruino for WS2812 modules

Posted on
  • In the internet are some modules with WS2812 Leds. I created extensions to Espruino, written in C to support these modules.
    LED-Matrix 8*8
    LED-Circles
    Sources are available on github

  • @JumJum the githup link show 404 , can you please update

  • Done, thanks

  • @JumJum any reason for not writing a java script module to handle this ?

  • Yes, and at least first one is a very good reason ;-)

    • loved to do it and learned a lot
    • it's much faster than java script, try to rotate in java script and you will see
    • doesn't take away as many variables compared to java script

    There are already a lot of special functions inside Espruino, that could be a module. May be on a long term we will have a couple of Espruino extensions which can be used to create customized firmware by sticking together firmware modules.

  • ok - I understand - first point is the best ;-)

    I prefer to have JS solutions ;-)

    A idea to use 3 time shift came from a snippet tve gave me, this can be used to rotate / walk like this small sample shows:

    
    // large ring with 24 NPs
    var NPs = 24;
    var array = new Array(NPs*3).fill(0);
    array[0] = array[1] = array[2] = 32;
    
    function rotate() {
      array.push(array.shift());
      array.push(array.shift());
      array.push(array.shift());
    }
    
    
  • This works from left to right, but how to rotate from top down ;-)

  • right to left works too for a ring ;-)

    function rotateRight() {
          array.unshift(array.pop()); 
          array.unshift(array.pop());
          array.unshift(array.pop());
    }
    
    

    you mean using a matrix NxM and rotate the hole lines horizontal or vertical like scrolling in a loop ?

    Here are two new things for you Rotating Neopixel with trailer effect

    and Adafruit Neopixel ringlight for close-up photography

    - what do you think ?

  • I worked with a lot of optimizations for handling arrays, including Uint8. None of them was even close to compiled C.
    Yes, rotating means rotate full line or full row of a matrix. Another available option is to have a large buffer, like 16by16 and display 8by8 blocks based on input with joystick or something like that.
    BTW, there are already some functions in Espruino, that could have been done easily in JavaScript like E.sum, E.interpolate, E.variance .... If there wasn't the factor called time...

    Hmm, video looks funny. And does'nt look too complex to be done.
    But right now,my focus is to understand events deep inside Espruino.
    First step will be to create something like a Schmitt Trigger having a change event.
    May be once this is done,.... ;-)

    Tschüss für heute

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Extensions to Espruino for WS2812 modules

Posted by Avatar for JumJum @JumJum

Actions