@Test public void testCompensatePressure() { final float[] tempResults = Bmx280.compensateTemperature(RAW_TEMPERATURE, TEMP_CALIBRATION); final float pressure = Bmx280.compensatePressure(RAW_PRESSURE, tempResults[1], PRESSURE_CALIBRATION); Assert.assertEquals(EXPECTED_PRESSURE, pressure, EXPECTED_PRESSURE * TOLERANCE); }
@VisibleForTesting static float compensatePressure(int rawPressure, float fineTemperature, int[] calibration) { int dig_P1 = calibration[0]; int dig_P2 = calibration[1]; int dig_P3 = calibration[2]; int dig_P4 = calibration[3]; int dig_P5 = calibration[4]; int dig_P6 = calibration[5]; int dig_P7 = calibration[6]; int dig_P8 = calibration[7]; int dig_P9 = calibration[8]; float var1 = (fineTemperature / 2.0f) - 64000.0f; float var2 = var1 * var1 * ((float) dig_P6) / 32768.0f; var2 = var2 + var1 * ((float) dig_P5) * 2.0f; var2 = (var2 / 4.0f) + (((float) dig_P4) * 65536.0f); var1 = (((float) dig_P3) * var1 * var1 / 524288.0f + ((float) dig_P2) * var1) / 524288.0f; var1 = (1.0f + var1 / 32768.0f) * ((float) dig_P1); if (var1 == 0.0) { return 0; } float p = 1048576.0f - (float) rawPressure; p = (p - (var2 / 4096.0f)) * 6250.0f / var1; var1 = ((float) dig_P9) * p * p / 2147483648.0f; var2 = p * ((float) dig_P8) / 32768.0f; p = p + (var1 + var2 + ((float) dig_P7)) / 16.0f; return p / 100.0f; }
Bmx280 implements AutoCloseable { @VisibleForTesting static float compensatePressure(int rawPressure, float fineTemperature, int[] calibration) { int dig_P1 = calibration[0]; int dig_P2 = calibration[1]; int dig_P3 = calibration[2]; int dig_P4 = calibration[3]; int dig_P5 = calibration[4]; int dig_P6 = calibration[5]; int dig_P7 = calibration[6]; int dig_P8 = calibration[7]; int dig_P9 = calibration[8]; float var1 = (fineTemperature / 2.0f) - 64000.0f; float var2 = var1 * var1 * ((float) dig_P6) / 32768.0f; var2 = var2 + var1 * ((float) dig_P5) * 2.0f; var2 = (var2 / 4.0f) + (((float) dig_P4) * 65536.0f); var1 = (((float) dig_P3) * var1 * var1 / 524288.0f + ((float) dig_P2) * var1) / 524288.0f; var1 = (1.0f + var1 / 32768.0f) * ((float) dig_P1); if (var1 == 0.0) { return 0; } float p = 1048576.0f - (float) rawPressure; p = (p - (var2 / 4096.0f)) * 6250.0f / var1; var1 = ((float) dig_P9) * p * p / 2147483648.0f; var2 = p * ((float) dig_P8) / 32768.0f; p = p + (var1 + var2 + ((float) dig_P7)) / 16.0f; return p / 100.0f; } }
Bmx280 implements AutoCloseable { @VisibleForTesting static float compensatePressure(int rawPressure, float fineTemperature, int[] calibration) { int dig_P1 = calibration[0]; int dig_P2 = calibration[1]; int dig_P3 = calibration[2]; int dig_P4 = calibration[3]; int dig_P5 = calibration[4]; int dig_P6 = calibration[5]; int dig_P7 = calibration[6]; int dig_P8 = calibration[7]; int dig_P9 = calibration[8]; float var1 = (fineTemperature / 2.0f) - 64000.0f; float var2 = var1 * var1 * ((float) dig_P6) / 32768.0f; var2 = var2 + var1 * ((float) dig_P5) * 2.0f; var2 = (var2 / 4.0f) + (((float) dig_P4) * 65536.0f); var1 = (((float) dig_P3) * var1 * var1 / 524288.0f + ((float) dig_P2) * var1) / 524288.0f; var1 = (1.0f + var1 / 32768.0f) * ((float) dig_P1); if (var1 == 0.0) { return 0; } float p = 1048576.0f - (float) rawPressure; p = (p - (var2 / 4096.0f)) * 6250.0f / var1; var1 = ((float) dig_P9) * p * p / 2147483648.0f; var2 = p * ((float) dig_P8) / 32768.0f; p = p + (var1 + var2 + ((float) dig_P7)) / 16.0f; return p / 100.0f; } Bmx280(String bus);  Bmx280(String bus, int address);   Bmx280(I2cDevice device); }
Bmx280 implements AutoCloseable { @VisibleForTesting static float compensatePressure(int rawPressure, float fineTemperature, int[] calibration) { int dig_P1 = calibration[0]; int dig_P2 = calibration[1]; int dig_P3 = calibration[2]; int dig_P4 = calibration[3]; int dig_P5 = calibration[4]; int dig_P6 = calibration[5]; int dig_P7 = calibration[6]; int dig_P8 = calibration[7]; int dig_P9 = calibration[8]; float var1 = (fineTemperature / 2.0f) - 64000.0f; float var2 = var1 * var1 * ((float) dig_P6) / 32768.0f; var2 = var2 + var1 * ((float) dig_P5) * 2.0f; var2 = (var2 / 4.0f) + (((float) dig_P4) * 65536.0f); var1 = (((float) dig_P3) * var1 * var1 / 524288.0f + ((float) dig_P2) * var1) / 524288.0f; var1 = (1.0f + var1 / 32768.0f) * ((float) dig_P1); if (var1 == 0.0) { return 0; } float p = 1048576.0f - (float) rawPressure; p = (p - (var2 / 4096.0f)) * 6250.0f / var1; var1 = ((float) dig_P9) * p * p / 2147483648.0f; var2 = p * ((float) dig_P8) / 32768.0f; p = p + (var1 + var2 + ((float) dig_P7)) / 16.0f; return p / 100.0f; } Bmx280(String bus);  Bmx280(String bus, int address);   Bmx280(I2cDevice device); void setMode(@Mode int mode); void setTemperatureOversampling(@Oversampling int oversampling); void setPressureOversampling(@Oversampling int oversampling); void setHumidityOversampling(@Oversampling int oversampling); @Oversampling int getTemperatureOversampling(); @Oversampling int getPressureOversampling(); @Oversampling int getHumidityOversampling(); @Override void close(); int getChipId(); boolean hasHumiditySensor(); float readTemperature(); float readPressure(); float readHumidity(); float[] readTemperatureAndPressure(); }
Bmx280 implements AutoCloseable { @VisibleForTesting static float compensatePressure(int rawPressure, float fineTemperature, int[] calibration) { int dig_P1 = calibration[0]; int dig_P2 = calibration[1]; int dig_P3 = calibration[2]; int dig_P4 = calibration[3]; int dig_P5 = calibration[4]; int dig_P6 = calibration[5]; int dig_P7 = calibration[6]; int dig_P8 = calibration[7]; int dig_P9 = calibration[8]; float var1 = (fineTemperature / 2.0f) - 64000.0f; float var2 = var1 * var1 * ((float) dig_P6) / 32768.0f; var2 = var2 + var1 * ((float) dig_P5) * 2.0f; var2 = (var2 / 4.0f) + (((float) dig_P4) * 65536.0f); var1 = (((float) dig_P3) * var1 * var1 / 524288.0f + ((float) dig_P2) * var1) / 524288.0f; var1 = (1.0f + var1 / 32768.0f) * ((float) dig_P1); if (var1 == 0.0) { return 0; } float p = 1048576.0f - (float) rawPressure; p = (p - (var2 / 4096.0f)) * 6250.0f / var1; var1 = ((float) dig_P9) * p * p / 2147483648.0f; var2 = p * ((float) dig_P8) / 32768.0f; p = p + (var1 + var2 + ((float) dig_P7)) / 16.0f; return p / 100.0f; } Bmx280(String bus);  Bmx280(String bus, int address);   Bmx280(I2cDevice device); void setMode(@Mode int mode); void setTemperatureOversampling(@Oversampling int oversampling); void setPressureOversampling(@Oversampling int oversampling); void setHumidityOversampling(@Oversampling int oversampling); @Oversampling int getTemperatureOversampling(); @Oversampling int getPressureOversampling(); @Oversampling int getHumidityOversampling(); @Override void close(); int getChipId(); boolean hasHumiditySensor(); float readTemperature(); float readPressure(); float readHumidity(); float[] readTemperatureAndPressure(); static final int CHIP_ID_BMP280; static final int CHIP_ID_BME280; static final int DEFAULT_I2C_ADDRESS; @Deprecated
    static final int I2C_ADDRESS; static final float MIN_TEMP_C; static final float MAX_TEMP_C; static final float MIN_PRESSURE_HPA; static final float MAX_PRESSURE_HPA; static final float MIN_HUM_RH; static final float MAX_HUM_RH; static final float MAX_POWER_CONSUMPTION_TEMP_UA; static final float MAX_POWER_CONSUMPTION_PRESSURE_UA; static final float MAX_POWER_CONSUMPTION_HUMIDITY_UA; static final float MAX_FREQ_HZ; static final float MIN_FREQ_HZ; static final int MODE_SLEEP; static final int MODE_FORCED; static final int MODE_NORMAL; static final int OVERSAMPLING_SKIPPED; static final int OVERSAMPLING_1X; }