• Hello, i'm working with a cheap chinese 8x8 led matrix mounted with a Max7219.
    sometime ( i'm enable to determine when or why, can't reproduce bug). the display go weird... it show only one line or 2 lines of pix... after a time it come back good.
    if i unplug/replug the board (a pico) everything restart well.
    in first i was thinking about a prob with the graphic buffer but when i ask to show content it look full of datas...
    therfore i was thinking a prob with the display...

    is it possible to reduce the spi baudrate and in wich value?
    or to reset an spi connection?
    do i need to find an other matrix with better chip... an idea?

    ps: i'm testing with low data transfer to display and it seem to work well (show on display one time on 10)
    i'have a second timer with a led pulse...


    // spi mosi=DIN, sck=CLOCK
    SPI2.setup({mosi:B15, sck:B13});
    // crée le buffer graphique 8x8 en 1 bit
    var g = Graphics.createArrayBuffer(8,8,1);
    // connecte en spi
    var disp = require("MAX7219").connect(SPI2, B14);
    var texte = "Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.";
    var phrase = texte.substr(0,12);
    var sDerCar = phrase.substr(10,2);
    var cPhrase = 0;
    var compteur = 8;
    var longT = 0;
    var lengthT = texte.length;
    var longP = 0;
    var decalage = 0;
    var debut = false;
    var val=0;
    var step = 5;
    function sendData() {
      // raccorde le bout de ligne suivant
      if (compteur < -longP+decalage+1){
        if (debut) {compteur = 8; debut=false;console.log("debut");} else {compteur = 0;}
        // si au bout du texte
        phrase= texte.substr(cPhrase*10,12);
        sDerCar = phrase.substr(10,2);
        decalage = g.stringWidth(sDerCar);
        if (decalage === 0) {
          // on est en fin de texte, à la prochaine boucle, on reprend le texte au début
          debut = true;
          console.log("redemarrage texte");
      // reset le buffer, ajoute la font, ecrit la chaine de caractères
      g = Graphics.createArrayBuffer(8,8,1);
      /* une fois font utilisée, on connait la longueur de la chaine*/
      longP = g.stringWidth(phrase);
      // calcul le decalage (en pix) entre chaque bout de phrase
      decalage = g.stringWidth(sDerCar);
      // envoie à la matrice
    function led() {
      /* var val= Math.random();
        if (val<.5) {val = 0;}*/
      calc = Math.sin(val/100);
      analogWrite(A5, Math.abs(calc),{freq:300});
      if (val>314) {val = 0; step=(Math.random()*8)+1;}
    function onInit() {
      console.log("init programme - éric choisy ©2018");
      setInterval(sendData, 60);
      setInterval(led, 10);

Avatar for Mrbbp @Mrbbp started