You are reading a single comment by @possmann and its replies. Click here to read the full conversation.
  • Here a little example. I clean and reduce a little bit the code. Some var definitions are not needed.

    /* Copyright (c) 2014 ToDo */
    /*
    Quick description ToDO
    */
    
    var C = {
      ADDRESS : 0x48    // description
    };
    
    /**
     * Description
    */
    function TMP102(_i2c) {
        this.i2c = _i2c;
    }
    
    /**
     * Description
    */
    TMP102.prototype.getTemperature = function() {
        var d = this.i2c.readFrom(C.ADDRESS, 2);
        return (((d[0] << 8) | d[1]) >> 4)*0.0625; 
    };
    
    /**
     * export
    */
    exports.connect = function (_i2c) {
        return new TMP102(_i2c);
    };
    
About

Avatar for possmann @possmann started