You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Seems to work for me?

    >col=0x80000000;(8|(((((col&0x80808000)>­>>15)*0x4081)>>14)&7)).toString(2)  
    ="1100"
    >col=0x00800000;(8|(((((col&0x80808000)>­>>15)*0x4081)>>14)&7)).toString(2)  
    ="1010"
    >col=0x00008000;(8|(((((col&0x80808000)>­>>15)*0x4081)>>14)&7)).toString(2)  
    ="1001"
    >col=0xFFFFFFFF;(8|(((((col&0x80808000)>­>>15)*0x4081)>>14)&7)).toString(2)         
    ="1111"
    

    If you're serious about getting the scanning speed up, I'd try and precalculate a Uint8Array of bytes where the 4th bit is 1, and the 1st, 2nd and 3rd are R,G and B.

    Then you can do something like:

    var p = [B8,B8,LED3,LED2,LED1];     
    var d = digitalWrite;                          
    words.forEach(function(w) {d(p,w)});
    

    (new versions of Espruino allow you to use forEach directly, rather than the whole [].forEach thing that was done before)

    Having said that, for the 1024 bytes (32x32) it still seems to take 247ms (and that's without the latching), which is too slow for you really. To get the speed up you might still be looking at writing some inline assembler.

    A quick test shows that you can get down to around 30ms:

    var sender = E.asm("void(int)", 
      "bx  lr");
    
    words = new Uint8Array(1024);
    
    a=getTime();
    words.forEach(sender);
    print(getTime()-a);
    

    although that's not doing anything in the assembler code itself - you'd have to write some code to set the relevant pins to the right values.

About

Avatar for Gordon @Gordon started