You are reading a single comment by @Wilberforce and its replies. Click here to read the full conversation.
    1. Should getTemp return the last value, even with a callback, rather than undefined?

    2. here is how to avoid the intial bogus value:

      var sensors = s.map(function (device) {
      var t=ds.connect(ow, device);
      t.getTemp();
      return t;
      });
      
      sensors.forEach(function (sensor, index) {
        console.log('initial' + ": " + sensor.getTemp());
      });
      

    This could be done automagically in the constructor here:

      this.type=parseInt(this.sCode[0]+this.sCode[1]);
      this.getTemp(); // trigger a conversion
    }
    
About

Avatar for Wilberforce @Wilberforce started