コード例 #1
0
        private async Task InitializeAdF_L3GD20_U_I2CDevice()
        {
            try
            {
                // Initialize I2C device
                var settings = new I2cConnectionSettings(Adafruit_L3GD20_Unified.L3GD20_ADDRESS);

                settings.BusSpeed    = I2cBusSpeed.FastMode;
                settings.SharingMode = I2cSharingMode.Shared;

                string aqs = I2cDevice.GetDeviceSelector("I2C1");              /* Find the selector string for the I2C bus controller                   */
                var    dis = await DeviceInformation.FindAllAsync(aqs);        /* Find the I2C bus controller device with our selector string           */

                I2CDevgyro = await I2cDevice.FromIdAsync(dis[0].Id, settings); /* Create an I2cDevice with our selected bus controller and I2C settings */

                gyro       = new Adafruit_L3GD20_Unified(ref I2CDevgyro, 20);
                gyroSensor = gyro.getSensorObj();
                gyro.getSensor(ref gyroSensor);
                Debug.WriteLine("------------- GYROSCOPE -----------");
                Debug.WriteLine("Sensor:       " + gyroSensor.name);
                Debug.WriteLine("Driver Ver:   " + gyroSensor.version);
                Debug.WriteLine("Unique ID:    " + gyroSensor.sensor_id);
                Debug.WriteLine("Max Value:    " + gyroSensor.max_value + " rad/s");
                Debug.WriteLine("Min Value:    " + gyroSensor.min_value + " rad/s");
                Debug.WriteLine("Resolution:   " + gyroSensor.resolution + " rad/s");
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());

                return;
            }
        }