WS2812 "matrix" + Graphics (invert direction)

Posted on
  • Hi all,
    I have a short test LED-matrix (6x6)
    It is arranged in zigzag order starting at top right going left down.

    06<05<04<03<02<01
    07>08>09>10>11>12
    18<17<16<15<14<13
    19>20>21>22>23>24
    30<29<28<27<26<25
    31>32>33>34>35>36
    

    How can I configure the Graphics to have correct coordinates?
    This is my current source code:

    SPI2.setup({baud:3200000, mosi:B15});
    var leds = Graphics.createArrayBuffer(6,6,24,{zigza­g:true, color_order:'bgr'}); 
    leds.flip = function() { SPI2.send4bit(leds.buffer, 0b0001, 0b0011); };
    leds.clear();
    // some text
    leds.setColor(0.1,0.1,0.1);
    leds.drawString("L",0,0);
    leds.flip();
    

    My result is following:

    .....X
    .....X
    .....X
    .....X
    ...XXX
    ......
    

    But I expect this:

    X.....
    X.....
    X.....
    X.....
    XXX...
    ......
    
  • Hello,
    I believe you want to set some rotation, probably something like

    leds.setRotation(2, true)

  • Hey @Loop - thx for the hint!!!
    it works fine for me by adding this:

    leds.setRotation(0, true);
    
  • Cool. I remember me too wiring the leds in unexpected ways a while ago.
    But that was before setRotation so I ended up rewiring them!
    Actually, I believe that the doc does not specify that 0,0 is top left, that is, web style coordinates. It may be a useful addition.

  • Thanks - I'll update the docs. I think it's pretty standard for most computer graphics (bar OpenGL?) so I hadn't thought to mention it :)

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

WS2812 "matrix" + Graphics (invert direction)

Posted by Avatar for Jorgen @Jorgen

Actions