public static byte ConfigureSensingParameters(MagnetometerOutputDataRate outputDataRate = MagnetometerOutputDataRate.Hz_80, MagnetometerPerformanceMode performanceMode = MagnetometerPerformanceMode.High, bool selfTest = false, bool fastOdr = false, bool temperatureCompensation = true) { var bitArray = new BitArray(Constants.ByteBitLength); // Self-test bitArray.Set(selfTestIndex, selfTest); // Fast ODR bitArray.Set(fastOdrIndex, fastOdr); // Temperature compensation bitArray.Set(temperatureCompensationIndex, temperatureCompensation); // ODR SetOdr(outputDataRate, bitArray); // Performance mode SetPerformance(performanceMode, bitArray); return(ConversionHelper.GetByteValueFromBitArray(bitArray)); }
private static void SetOdr(MagnetometerOutputDataRate outputDataRate, BitArray bitArray) { bool[] odrBitValues; switch (outputDataRate) { case MagnetometerOutputDataRate.Hz_0_625: odrBitValues = new bool[] { false, false, false }; break; case MagnetometerOutputDataRate.Hz_1_25: odrBitValues = new bool[] { true, false, false }; break; case MagnetometerOutputDataRate.Hz_2_5: odrBitValues = new bool[] { false, true, false }; break; case MagnetometerOutputDataRate.Hz_5: odrBitValues = new bool[] { true, true, false }; break; case MagnetometerOutputDataRate.Hz_10: odrBitValues = new bool[] { false, false, true }; break; case MagnetometerOutputDataRate.Hz_20: odrBitValues = new bool[] { true, false, true }; break; case MagnetometerOutputDataRate.Hz_40: odrBitValues = new bool[] { false, true, true }; break; case MagnetometerOutputDataRate.Hz_80: default: odrBitValues = new bool[] { true, true, true }; break; } ConversionHelper.SetBitArrayValues(bitArray, odrBitValues, odrBeginIndex, odrEndIndex); }