public static void Main() { IMPU sensor = MPUSensor.GetInstance(SensorType.With6Axis); while (true) { ISensorData result = sensor.GetMeasurements(); Debug.Print(result.ToString()); Thread.Sleep(100); } }
/// <summary> /// Ruft eine Instance von MPU6050. /// Geeigent für die Nutzung mehrer I2C Module. /// </summary> /// <param name="i2c">Benötigt die Reference Instanz für die I2C Verbindung.</param> /// <param name="init">Initialisiert den Sensor mit Standard Einstellungen.</param> /// <returns>Gibt die Instanz von MPU6050 zurück.</returns> public static IMPU GetInstance(SensorType sensorType, I2CConnector i2c, bool init = true, IRegisterConfiguration regConfig = null) { if (_mpu == null) { _mpu = new MPUSensor(sensorType, i2c); if (init) { _mpu.Init(regConfig); } } return(_mpu); }
public static void Main() { IMPU sensor = MPUSensor.GetInstance(SensorType.With9Axis); while (true) { ISensorData result = sensor.GetMeasurements(); Debug.Print(result.ToString()); SensorData9Axis result9Axis = result as SensorData9Axis; if (result9Axis != null) { Debug.Print("MagX:" + result9Axis.MagnometerX + ", MagY:" + result9Axis.MagnometerY + ", MagZ:" + result9Axis.MagnometerZ); } Thread.Sleep(100); } }