Exemple #1
0
        async void StartMPU()
        {
            var mpu = new MPU6050();

            mpu.SensorInterruptEvent += MpuSensorInterruptEvent;

            await mpu.Init();
        }
Exemple #2
0
        public MeadowApp()
        {
            Console.WriteLine("Initializing");

            mpu = new MPU6050(Device.CreateI2cBus(), 0x69);

            mpu.AccelerationXChanged       += OnRotated;
            mpu.AccelerationYChanged       += OnRotated;
            mpu.AccelerationZChanged       += OnRotated;
            mpu.AccelerationChangeThreshold = 0.05f;
            mpu.StartSampling(TimeSpan.FromMilliseconds(500));

            while (true)
            {
                Console.WriteLine($"{mpu.TemperatureC}C");
                Thread.Sleep(5000);
            }
        }
Exemple #3
0
        public static void Main()
        {
            _i2cBus = new I2CBus();
            _mpu    = new MPU6050(_i2cBus, MPU6050.AddressLow, 400);

            Debug.Print("Testing device connections...");

            if (_mpu.TestConnection() == false)
            {
                Debug.Print("Connection failed");
            }
            else
            {
                Debug.Print("Initializing device...");

                _mpu.Initialize();

                short accelX, accelY, accelZ;
                short gyroX, gyroY, gyroZ;

                while (true)
                {
                    _mpu.GetMotion6(out accelX, out accelY, out accelZ, out gyroX, out gyroY, out gyroZ);

                    accelX /= 16384;
                    accelY /= 16384;
                    accelZ /= 16384;

                    gyroX /= 131;
                    gyroY /= 131;
                    gyroZ /= 131;

                    Debug.Print("Accel[" + accelX.ToString() + "," + accelY.ToString() + "," + accelZ.ToString() + "] "
                                + "Gyro[" + gyroX.ToString() + "," + gyroY.ToString() + "," + gyroZ.ToString() + "]");
                }
            }
        }