• Gorgeous @allObjects!
    it works pretty well, have to try it more.
    Sometime pb persisting even with the tries...
    I definitively will try with the scotchy diode...

    My crappy solution seemed effective but it was an evidence there was a better, nicer code structure to write to do this.

    it seems if it catchs an error even with the tries it fail to initialize the display...
    never mind i use your "boot sequence"

    just a small misspelling throw rather than trow (i'm unfamiliar with this command).

    Thanks again.
    It's nice code

    I do not see a reset command in the doc
    therefore i remove the first function (res). ;)

    é.

    ps: clearInterval() was seen in a forum post about timeout

    var ini = function() { // first
      require("Font4x6").add(Graphics);
      // initialisation I2C
      console.log("setup I2C");
      I2C1.setup({scl: B6,sda: B7});
      /* rajouter les init de connexion pour le display */
      console.log("init programme affichage matrice v2.2 - éric choisy ©2019");
      console.log("mém. utilisée: "+Math.round(process.memory().usage/proc­ess.memory().total*100)+"%");
    }
    , osc = function(tries) { if (tries>0) { // third w/ retries
      try { console.log("turn OSC ON");
        digitalPulse(LED2,1,20);//verte
        I2C1.writeTo(0x70, 0x21); // turn on oscillator
        setTimeout(don,250,2);
      } catch(e) { console.log(e);
        setTimeout(osc,250,--tries);
        digitalPulse(LED1,1,20);//rouge
      } } else throw "Unable to turn osc on";
    }
    , don = function(tries) { if (tries>0) { // fourth w/ retries
      try { console.log("turn display ON");
      digitalPulse(LED2,1,20);//verte
        I2C1.writeTo(0x70, 0x81); // display on
        setTimeout(lum,250,2);
      } catch(e) { console.log(e);
        setTimeout(don,250,--tries);
        digitalPulse(LED1,1,20);// rouge
      } } else throw "Unable to turn display ON";
    }
    , lum = function(tries) { if (tries>0) { // fifth w/ retries
      try { console.log("set brightness");
        digitalPulse(LED2,1,20);//verte
        I2C1.writeTo(0x70, 0xE0 | 0); // luminosité 0-15
        setTimeout(envoieMatrice, 1000);
      } catch(e) { console.log(e);
        digitalPulse(LED1,1,20);//rouge
        setTimeout(lum,250,--tries);
      } } else throw "Unable to set brightness";
    };
    const onInit = function() {
      ini();
      osc(3); // starts the chain \:
    };
    

    i added led pulse to have visual feedback without a console...

About

Avatar for Mrbbp @Mrbbp started