Пример #1
0
        private async Task InitializeAdF_BMP085_U_I2CDevice()
        {
            try
            {
                // Initialize I2C device
                var settings = new I2cConnectionSettings(Adafruit_BMP085_Unified.BMP085_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           */

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

                bmp       = new Adafruit_BMP085_Unified(ref I2CDevbmp, 18001);
                bmpSensor = bmp.getSensorObj();
                bmp.getSensor(ref bmpSensor);
                Debug.WriteLine("-------- PRESSURE/ALTITUDE ---------");
                Debug.WriteLine("Sensor:       " + bmpSensor.name);
                Debug.WriteLine("Driver Ver:   " + bmpSensor.version);
                Debug.WriteLine("Unique ID:    " + bmpSensor.sensor_id);
                Debug.WriteLine("Max Value:    " + bmpSensor.max_value + " hPa");
                Debug.WriteLine("Min Value:    " + bmpSensor.min_value + " hpa");
                Debug.WriteLine("Resolution:   " + bmpSensor.resolution + " hPa");
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());

                return;
            }
        }