You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Yep, you're right - you can only send data to all the LEDs in a chain, not just one. The data gets sent pretty quickly though, so you won't notice any difference in when the lights come on or go off.

    It's about 20,000 LEDs/sec - so if you were updating 50 LEDs they would update in 1/400 sec, which you'd never notice.

    The code before will let you change every LED individually (not just row or column), but in a similar way to the lights, you'd have to figure out what colour every LED should be at the same time.

    If you actually just want to change individual colours, you could re-write the code as:

    var rgb = new Uint8Array(5*6*3);
    function setPixel(x,y,r,g,b) {
      var i = (x+y*6)*3;
       rgb[i++] = r;  
       rgb[i++] = g;
       rgb[i] = b;
      SPI2.send4bit(rgb, 0b0001, 0b0011); // update the display
    }
    // ...
    setPixel(2,2, 255,255,255); /* the colour */
    

    OR, you could do what @Loop suggested earlier, and use the Graphics class, which already provides functions like setPixel and clear:

    var g = Graphics.createArrayBuffer(6,5,24);
    g.setColor(255,255,255);
    g.setPixel(2,2);
    SPI2.send4bit(g.buffer, 0b0001, 0b0011); // update the display
    
About

Avatar for Gordon @Gordon started