• ...and with a variable you can control the logging - even when connected - and enhanced with a watch dog for setup - sDog - which - if setup not successful - restarts. Timing may be adjusted because it is dependent on all the retries w/ the timeouts cumulated plus some reserve and pause that can and should happen under its watch. You may setup another watch dog for running / sending the texts / grpahics ( envoieMatrice() ).

    PS: é, I like the francophonisation of - not just - les noms... <;:{ooops}>>>

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

Avatar for allObjects @allObjects started