Raspberry.IO.InterIntegratedCircuit.I2cDriver.Connect C# (CSharp) Method

Connect() public method

Connects the specified device address.
public Connect ( int deviceAddress ) : Raspberry.IO.InterIntegratedCircuit.I2cDeviceConnection
deviceAddress int The device address.
return Raspberry.IO.InterIntegratedCircuit.I2cDeviceConnection
        public I2cDeviceConnection Connect(int deviceAddress)
        {
            return new I2cDeviceConnection(this, deviceAddress);
        }

Usage Example

コード例 #1
0
        private IPwmDevice GetRealDevice()
        {
            PwmFrequency = new Frequency(60);
            DeviceAddress = 0x40;

            try
            {
                Log.Info("Creating pins");
                var sdaPin = SdaPin.ToProcessor();
                var sclPin = SclPin.ToProcessor();

                Log.Info("Creating i2cDriver");
                _i2cDriver = new I2cDriver(sdaPin, sclPin);
            }
            catch (Exception e)
            {
                Log.Error("Failed to initialise i2c driver. Did you forget sudo?", e);
            }

            Log.Info("Creating real device...");
            var device = new Pca9685Connection(_i2cDriver.Connect(DeviceAddress));
            Log.Info("Setting frequency...");
            device.SetPwmUpdateRate(PwmFrequency); //                        # Set frequency to 60 Hz


            IsConnected = true;
            return device;
        }
All Usage Examples Of Raspberry.IO.InterIntegratedCircuit.I2cDriver::Connect