/// <summary> /// Calculate Calibrated Preasure /// </summary> /// <param name="rawPreasure"></param> /// <param name="calibParam"></param> /// <returns> kPa </returns> private double CalculateCalibratedPreasure(int UP, short UT, short oss, BMPCalibParam calibParam) { short ac1 = calibParam.ac1; short ac2 = calibParam.ac2; short ac3 = calibParam.ac3; ushort ac4 = calibParam.ac4; ushort ac5 = calibParam.ac5; ushort ac6 = calibParam.ac6; short b1 = calibParam.b1; short b2 = calibParam.b2; short mb = calibParam.mb; short mc = calibParam.mc; short md = calibParam.md; int p; int X1, X2, X3, B3, B5, B6; uint B4, B7; X1 = ((UT - ac6) * ac5) >> 15; X2 = (mc << 11) / (X1 + md); B5 = X1 + X2; B6 = B5 - 4000; X1 = (b2 * ((B6 * B6) >> 12)) >> 11; X2 = (ac2 * B6) >> 11; X3 = X1 + X2; B3 = (((ac1 * 4 + X3) << oss) + 2) / 4; X1 = (ac3 * B6) >> 13; X2 = (b1 * (B6 * B6) >> 12) >> 16; X3 = ((X1 * X2) + 2) >> 2; B4 = (uint)(ac4 * ((X3 + 32768)) >> 15); B7 = (uint)((UP - B3) * (50000 >> oss)); if (B7 < 80000000) { p = (int)((B7 * 2) / B4); } else { p = (int)(B7 / B4) * 2; } X1 = (p >> 8) ^ 2; X1 = (X1 * 3038) >> 16; X2 = (-7375 * p) >> 15; p += ((X1 + X2 + 3791) >> 4); return(p); }
// /// <summary> /// Calculate Calibrated Temperature /// </summary> /// <param name="RawTemp"></param> /// <param name="calibParam"></param> /// <returns>deg C</returns> private double CalculateCalibratedTemperature(short RawTemp, BMPCalibParam calibParam) { short ac1 = calibParam.ac1; short ac2 = calibParam.ac2; short ac3 = calibParam.ac3; ushort ac4 = calibParam.ac4; ushort ac5 = calibParam.ac5; ushort ac6 = calibParam.ac6; short b1 = calibParam.b1; short b2 = calibParam.b2; short mb = calibParam.mb; short mc = calibParam.mc; short md = calibParam.md; int X1, X2, B5; X1 = ((RawTemp - ac6) * ac5) >> 15; X2 = (mc << 11) / (X1 + md); B5 = X1 + X2; return(((B5 + 8) >> 4) / 10.0); }