• Hello @allObjects,

    I think I understood the idea of a large ArrayBuffer with the entire line of text and display only part of it. Unfortunately, I am not comfortable with ArrayBuffers nor dataView
    The idea is to measure the size of my sentence written in a buffer and generate the correct size Arraybuffer once (between 20 and 60 characters), then go and copy the useful portion to display on the matrix.
    Did i well understood?

    I read on MDN that there was an arrayBuffer.slice (start, end) but on espruino, the function does not return an arrayBuffer but just an array so I remain skeptical about the solution.
    Any help would be great for a starting point to explore.
    regards

    the basic writing program

    const phrases = ["Sourire aux cons","Aquiescer aux injonctions d'un supérieur","Mourir de honte","Mourir d'envie","Sourire aux jolies femmes","s'endormir devant la télévision"]; //it contains more sentence
    
    function ecris() {
      phrase = "À quoi bon, ";
      tirage = Math.floor(Math.random()*phrases.length)­;
      phrase += phrases[tirage].toLowerCase()+".";
      return phrase;
    }
    console.log(ecris());
    

    a try as you said

    let bitIndex = 0;
    let phraseAB;
    g = Graphics.createArrayBuffer(8,8,1);
    
    const phrases = ["Sourire aux cons","Aquiescer aux injonctions d'un supérieur","Mourir de honte","Mourir d'envie","Sourire aux jolies femmes","s'endormir devant la télévision"];
    
    function ecris() {
      phrase = "À quoi bon, ";
      tirage = Math.floor(Math.random()*phrases.length)­;
      phrase += phrases[tirage].toLowerCase()+".";
      const width = g.stringWidth(phrase);
      phraseAB = Graphics.createArrayBuffer(width,8,1);
      phraseAB.drawString(laPhrase, 0, 0);
      sendDatas();
    }
    
    function sendDatas() {
      g = phraseAB.slice(bitIndex, bitIndex+8);
      g.setContrast(7); /* val entre 0 et 7 - TM1640*/
      g.setRotation(2,true); // TM1640
      // mise à jour du display
      g.flip();
      bitIndex++;
      setTimeout(sendDatas, 50);
      // do it til the end of phraseAB + ecris() + reset bitIndex
    }
    

    Am i on the good way?

    regards
    é.

About

Avatar for Mrbbp @Mrbbp started