You are reading a single comment by @JumJum and its replies. Click here to read the full conversation.
  • Life could be much easier, doing things correctly , .....

    Good news first, I got it running.
    Bad news, ESP32 seems to be too slow.
    Scan takes 70 msecs, so refresh rate is 14 hz only which means flickering like crazy.
    Another bad part is converting from Graphics buffer to the format needed for the LED Matrix.

    I'm pretty sure there are better ways for converting, but I'm pretty sure it will always be slow.
    An option could be a small c-function for converting, and may be shiftout could be optimized (?)

    Anyway, if somebody wants to test with other boards, this could be a good start

    function LedMatrix(){
      var me = this;
      var gr,buf; //graphics object and buffer in graphics object
      var ledBuf; //converted graphics.buffer to datapanes for LED
      var sfnc,dfnc; //function calls to send data to LED Matrix
      var Pr1,Pr2,Pb1,Pb2,Pg1,Pg2; //Color Pins
      var Pa,Pb,Pc,Pd; //address pins
      var Platch,Pclock,Penable; //control pins
      me.init = function(R1,R2,B1,B2,G1,G2,A,B,C,D,Latch,Clock,Enable){
        Pr1 = R1; Pr2 = R2; Pb1 = B1; Pb2 = B2; Pg1 = G1; Pg2 = G2;
        Pa = A; Pb = B; Pc = C; Pd = D;
        Platch = Latch; Pclock = Clock; Penable = Enable;
        sfnc = shiftOut.bind(null,[Pr1,Pg1,Pb1,Pr2,Pg2,Pb2],{clk:Pclock,repeat:0});
        dfnc = digitalWrite.bind(null,[Penable,Platch,Pd,Pc,Pb,Pa,Penable]);
        gr = Graphics.createArrayBuffer(64,32,4);
        buf = gr.buffer;
        return gr;
      };
      me.convertArray = function(){
        ledBuf = new Uint8Array(64 * 32 / 2);
        var bufpnt1,bufpnt2,ledpnt;
        bufpnt1 = 0; bufpnt2 = 512; ledpnt = 0;
        var pane = false;
        for(var i = 0; i < 16; i++){
          for(var j = 0; j < 64;j +=2){
            ledBuf[ledpnt] = (buf[bufpnt2] & 7) + ((buf[bufpnt1] & 7)<<3);
            ledpnt++;
            ledBuf[ledpnt] = ((buf[bufpnt2] & 0xf0) >>4) + ((buf[bufpnt1] & 0xf0)>>1);
            ledpnt++;
            bufpnt1++;
            bufpnt2++;
          }
        }
      };
      me.scan = function(){
        var y;
        y = 0;
        Penable.reset();
        for (y=0;y<16;y++) {
          sfnc(new Uint8Array(ledBuf.buffer,y*64,64));
          dfnc(33|y<<1);
        }
        Penable.set();
      };
    }
    var gr,led = new LedMatrix();
    function test(){
      gr = led.init(D2,D16,D4,D17,D15,D27,D5,D18,D19,D21,D26,D22,D25);
      gr.setBgColor(1);
      gr.clear();
      gr.setColor(2);
      gr.fillRect(5,16,50,25);
      gr.setColor(4);
      gr.fillRect(10,7,40,20);
      led.convertArray();
      setInterval(function(){led.scan();},80);
    }
    
    
About

Avatar for JumJum @JumJum started