• @Robin

    i tried in a dirty way by adding some time in each command (a blank loop) and a try catch.
    i've got less error.
    sometime (1 in 5 switch on) there is no error but display does not start.
    When i unplug/plug i lost the connexion therefore i do not receive the error... but i blink the led in the main program and it blink....
    show you my ugly code

    const onInit = function() {
      clearInterval();
      clearWatch();
      pinMode(B6, 'opendrain');
      pinMode(B7, 'opendrain');
      require("Font4x6").add(Graphics);
      /* 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)+"%");
      // initialisation I2C
    
        console.log("setup I2C");
      I2C1.setup({scl: B6,sda: B7});
      // rouge
      try {
        console.log("try OSC ON");
        I2C1.writeTo(0x70, 0x21); // turn on oscillator
      } catch(e) {
        I2C1.setup({scl: B6,sda: B7});
        setTimeout(function() {
          console.log("try again 0x21");
          try {
            I2C1.writeTo(0x70, 0x21); // turn on oscillator
          } catch(e) {
            console.log("does not init",e);
          }
        }, 250);
      }
    
      // init suite I2C
      for (var i=0; i<10000; i++) {
        //
      }
      try {
        console.log("try display ON");
        I2C1.writeTo(0x70, 0x81); // display on
      } catch(r) {
        digitalPulse(LED1,1,20); //rouge
        for (i=0; i<10000; i++) {
          //
        }
        console.log("try again display ON");
        I2C1.writeTo(0x70, 0x81); // display on
      }
      digitalPulse(LED2,1,20);//verte
      try {
        console.log("try brightness");
        I2C1.writeTo(0x70, 0xE0 | 0); // luminosité 0-15
      } catch(r) {
        digitalPulse(LED1,1,20); //rouge
        for (i=0; i<10000; i++) {
          //
        }
        console.log("try again brightness");
        I2C1.writeTo(0x70, 0xE0 | 0); // luminosité 0-15
      }
      digitalPulse(LED2,1,20);//verte
      setTimeout(envoieMatrice, 1000);
    };
    
About

Avatar for Mrbbp @Mrbbp started