You are reading a single comment by @luwar and its replies. Click here to read the full conversation.
  • Currently I'm developing an Espruino module for an I2C sensor which is not able to run with the default bitrate of 400 kHz.

    I want to ensure that nobody fall into the same trap to forget the bitrate parameter in I2C.setup(). I know: "Read the datasheet carefully ...". But better would be an automatic check with a human readable hint about the wrong usage.

    Is it possible to get the bitrate of an I2C instance to check the correct usage in the connect()-methods or directly in the constructor function of i2c-sensors, e.g.

        exports.connect = function ( /*=I2C*/i2c ) {
          var br = i2c.getBitrate();
          if (br && (br < 10000 || br > 100000)) {
            throw new Error( "The maximum clock frequency is 100 kHz and the minimum is 10 kHz." );
          }
          return new MLX90614( i2c );
        };
    
About

Avatar for luwar @luwar started