You are reading a single comment by @Pinnchus and its replies. Click here to read the full conversation.
  • I think a my be doing something wrong, when run the code from the IDE, everything runs fine. But, when i try to save the code, wrapping the initialization code in a function and calling it from the onInit function does not run unless I call it manually with load(). When I run manually load() everything runs fine too.

    The code is uggly, but it's working when i run it manually.

    //All VAR are declared globally
    function initializeall() {
      require("Font6x8").add(Graphics);
      require("Font8x16").add(Graphics);
      i2c = new I2C();
      i2c.setup({ scl : B6, sda: B7, bitrate: 1000000  });
      g = require("SSD1306").connect(i2c, start, { height : 32 });
      dht = require("DHT22").connect(B5);
      Start_read();
      pinMode(B15,'input_pullup');
      pinMode(B14,'input_pullup');
      pinMode(B13,'input_pullup');
      setWatch(selection, B15, { repeat: true, edge:'falling', debounce:20});
      setWatch(BtnUP, B14, { repeat: true, edge:'falling', debounce:20});
      setWatch(BtnDown, B13, { repeat: true, edge:'falling', debounce:20});
    
    }
    
    function onInit() {
      USB.setConsole(true);
      setTimeout(function () {
                    initializeall();
                    }, 
          1000);
    }
    

    Does anyone has a hint?

    Thanks

About

Avatar for Pinnchus @Pinnchus started