compensate-pres

denis-nabatchikov/bme280/compensate-pres

No description
compensate-pres
@/compensate-pres
adc_Pnumber
t_FINEnumber
dig_P1number
dig_P2number
dig_P3number
dig_P4number
dig_P5number
dig_P6number
dig_P7number
dig_P8number
dig_P9number
compensate-pres
PRES
DONE
adc_P
t_FINE
dig_P1
dig_P2
dig_P3
dig_P4
dig_P5
dig_P6
dig_P7
dig_P8
dig_P9
DONEpulse
PRESnumber
To use the node in your project you should have the denis-nabatchikov/bme280 library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

node {
    void evaluate(Context ctx) {
        int64_t var1;
        int64_t var2;
        float p;

        int32_t adc_P = getValue<input_adc_P>(ctx);
        int32_t t_fine = getValue<input_t_FINE>(ctx);
        uint16_t dig_P1 = getValue<input_dig_P1>(ctx);
        int16_t dig_P2 = getValue<input_dig_P2>(ctx);
        int16_t dig_P3 = getValue<input_dig_P3>(ctx);
        int16_t dig_P4 = getValue<input_dig_P4>(ctx);
        int16_t dig_P5 = getValue<input_dig_P5>(ctx);
        int16_t dig_P6 = getValue<input_dig_P6>(ctx);
        int16_t dig_P7 = getValue<input_dig_P7>(ctx);
        int16_t dig_P8 = getValue<input_dig_P8>(ctx);
        int16_t dig_P9 = getValue<input_dig_P9>(ctx);

        var1 = ((int64_t)t_fine) - 128000;
        var2 = var1 * var1 * (int64_t)dig_P6;
        var2 = var2 + ((var1 * (int64_t)dig_P5) << 17);
        var2 = var2 + (((int64_t)dig_P4) << 35);
        var1 = ((var1 * var1 * (int64_t)dig_P3) >> 8) + ((var1 * (int64_t)dig_P2) << 12);
        var1 = (((((int64_t)1) << 47) + var1)) * ((int64_t)dig_P1) >> 33;

        if (var1 == 0) {
            return;
        }

        p = 1048576.0 - adc_P;
        p = ((((int64_t)p << 31) - var2) * 3125.0) / var1;
        var1 = (dig_P9 * ((int64_t)p >> 13) * ((int64_t)p >> 13)) >> 25;
        var2 = (dig_P8 * (int64_t)p) >> 19;

        p = ((((int64_t)p + var1 + var2) >> 8) + (dig_P7 << 4)) >> 8;

        emitValue<output_PRES>(ctx, p);
        emitValue<output_DONE>(ctx, true);
    }
}