Beispiel #1
0
        public Mpu9250Device(SpiDevice device)
        {
            // Validate
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            // Initialize hardware
            Hardware = device;

            // Reset the device to default setting
            this.Reset();

            // Set clock source
            Hardware.WriteJoinByte((byte)Mpu9250Register.PowerManagment1, 0x01);

            // Set I2C master mode
            Hardware.WriteJoinByte((byte)Mpu9250Register.UserControl, 0x20);

            // Set I2C configureation multi-master IIC 400KHz.
            Hardware.WriteJoinByte((byte)Mpu9250Register.I2cMasterControl, 0x0D);

            // Set temprature bandwidth to 188Hz and gyroscope bandwidth to 184Hz.
            Hardware.WriteJoinByte((byte)Mpu9250Register.Config, 0x00);

            // Verify the device is connected, accessable and ready for use.
            if (ChipId == 0x71 & Ak8963ChipId == 0x48)
            {
                IsConnected = true;
            }

            // Initialize sensor reading
            SensorReading = new Mpu9250SensorReading();

            // Initialize sensor axis offset data
            AxisOffset = new Mpu9250OffsetReading()
            {
                MagXAxisSensitivity = 1, MagYAxisSensitivity = 1, MagZAxisSensitivity = 1
            };
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Mpu9250ReadingChangedEventArgs"/> class.
 /// </summary>
 /// <param name="reading">The sensor readings.</param>
 public Mpu9250ReadingChangedEventArgs(Mpu9250SensorReading reading)
 {
     Timestamp = DateTime.UtcNow;
     Reading   = reading;
 }