You are reading a single comment by @Owen and its replies. Click here to read the full conversation.
  • Sorry to reopen topic but I think it's the best place. Since my last post here I've built a much bigger RGB LED matrix (15x15) and beginning to run into some serial data issues.
    On my 15x15 board I can easily output the first 168 pixels but any more and it all goes wrong. I'm not sure if this is an issue with Glediator, USB2Serial, Espruino reading the serial data or Espruino outputting the SPI data?
    I don't believe Espruino is the issue but I'm really not sure what is. The code below does the same as above but outputs the "line" length (the graphic SPI data). For 15x15 it should always be 675 but rarely is..

    function onInit() {
      SPI2.setup({baud:3200000, mosi:B15});
      var cmd = "";
      Serial1.setup(1000000, {tx:B6,rx:B7});
      Serial1.on('data', function (data) {
        cmd+=data;
        var idx = cmd.indexOf("\1");
        while (idx>=0) {
          var line = cmd.substr(0,idx);
          cmd = cmd.substr(idx+1);
          idx = cmd.indexOf("\1");
          console.log(line.length);
          SPI2.send4bit(line, 0b0001, 0b0011);
        }
      });
    }
    

    And the console returns:

    Running onInit()... 
    0 
    675 
    504 
    664 
    504 
    504 
    602 
    504 
    504 
    504 
    545 
    504 
    1002 
    219 
    504 
    504 
    504 
    504 
    504 
    504 
    504 
    504 
    504 
    504 
    504 
    1076 
    147 
    504 
    504 
    833 
    390 
    504 
    504 
    504 
    725 
    1128 
    88 
    504 
    504 
    504 
    661 
    504 
    504 
    1077 
    144 
    504 
    504 
    504 
    504 
    504 
    834 
    389 
    504 
    504 
    504 
    904 
    895 
    

    675 only appears a couple of time while 504 appears many but again there are lots of other seemly random lengths.
    Is the problem the serial data that's being sent from Glediator or the way I'm detecting a new frame "\1" ?
    Let me know if there is anything I can try to debug this or if the magic length 504 means anything? Thanks

About

Avatar for Owen @Owen started