/// <summary> /// Sets the device's terminal configuration. /// </summary> /// <param name="config"> /// The configuration to set. /// </param> /// <exception cref="ObjectDisposedException"> /// This instance has been disposed and can no longer be used. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="config"/> cannot be null. /// </exception> /// <exception cref="ArgumentException"> /// The specified configuration cannot have a null channel. /// </exception> /// <exception cref="IOException"> /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. /// </exception> public void SetTerminalConfiguration(DeviceControllerTerminalConfiguration config) { if (this._isDisposed) { throw new ObjectDisposedException("CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotDeviceController"); } if (config == null) { throw new ArgumentNullException("config"); } DeviceControlChannel chan = config.Channel; if (chan == null) { throw new ArgumentException("A configuration with a null channel is not permitted.", "config"); } // Read current configuration. Byte memAddr = config.Channel.TerminalControlAddress; Int32 tcon = this.Read(memAddr); // Modify configuration. tcon = this.SetBit(tcon, chan.HardwareConfigControlBit, config.ChannelEnabled); tcon = this.SetBit(tcon, chan.TerminalAConnectionControlBit, config.PinAEnabled); tcon = this.SetBit(tcon, chan.WiperConnectionControlBit, config.PinWEnabled); tcon = this.SetBit(tcon, chan.TerminalBConnectionControlBit, config.PinBEnabled); // Write new config to device. this.Write(memAddr, tcon); }
/// <summary> /// Determines whether the specified /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/> is equal /// to the current <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/>. /// </summary> /// <param name="dctc">The <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/> to /// compare with the current <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/>.</param> /// <returns> /// <c>true</c> if the specified /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/> /// is equal to the current /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/>; /// otherwise, <c>false</c>. /// </returns> public Boolean Equals(DeviceControllerTerminalConfiguration dctc) { if (dctc == null) { return(false); } return((this._channel.Equals(dctc.Channel)) && (this._channelEnabled == dctc.ChannelEnabled) && (this._pinAEnabled == dctc.PinAEnabled) && (this._pinWEnabled == dctc.PinWEnabled) && (this._pinBEnabled == dctc.PinBEnabled)); }
/// <summary> /// Determines whether the specified <see cref="System.Object"/> is equal to the /// current <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/>. /// </summary> /// <param name="obj"> /// The <see cref="System.Object"/> to compare with the current /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/>. /// </param> /// <returns> /// <c>true</c> if the specified <see cref="System.Object"/> is equal to the current /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/>; /// otherwise, <c>false</c>. /// </returns> public override bool Equals(object obj) { if (obj == null) { return(false); } DeviceControllerTerminalConfiguration dctc = obj as DeviceControllerTerminalConfiguration; if ((Object)dctc == null) { return(false); } return((this._channel.Equals(dctc.Channel)) && (this._channelEnabled == dctc.ChannelEnabled) && (this._pinAEnabled == dctc.PinAEnabled) && (this._pinWEnabled == dctc.PinWEnabled) && (this._pinBEnabled == dctc.PinBEnabled)); }
/// <summary> /// Determines whether the specified /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/> is equal /// to the current <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/>. /// </summary> /// <param name="dctc">The <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/> to /// compare with the current <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/>.</param> /// <returns> /// <c>true</c> if the specified /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/> /// is equal to the current /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.DeviceControllerTerminalConfiguration"/>; /// otherwise, <c>false</c>. /// </returns> public Boolean Equals(DeviceControllerTerminalConfiguration dctc) { if (dctc == null) { return false; } return ((this._channel.Equals(dctc.Channel)) && (this._channelEnabled == dctc.ChannelEnabled) && (this._pinAEnabled == dctc.PinAEnabled) && (this._pinWEnabled == dctc.PinWEnabled) && (this._pinBEnabled == dctc.PinBEnabled)); }
/// <summary> /// Sets the device's terminal configuration. /// </summary> /// <param name="config"> /// The configuration to set. /// </param> /// <exception cref="ObjectDisposedException"> /// This instance has been disposed and can no longer be used. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="config"/> cannot be null. /// </exception> /// <exception cref="ArgumentException"> /// The specified configuration cannot have a null channel. /// </exception> /// <exception cref="IOException"> /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. /// </exception> public void SetTerminalConfiguration(DeviceControllerTerminalConfiguration config) { if (this._isDisposed) { throw new ObjectDisposedException("CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotDeviceController"); } if (config == null) { throw new ArgumentNullException("config"); } DeviceControlChannel chan = config.Channel; if (chan == null) { throw new ArgumentException("A configuration with a null channel is not permitted.", "config"); } // Read current configuration. Byte memAddr = config.Channel.TerminalControlAddress; Int32 tcon = this.Read(memAddr); // Modify configuration. tcon = this.SetBit(tcon, chan.HardwareConfigControlBit, config.ChannelEnabled); tcon = this.SetBit(tcon, chan.TerminalAConnectionControlBit, config.PinAEnabled); tcon = this.SetBit(tcon, chan.WiperConnectionControlBit, config.PinWEnabled); tcon = this.SetBit(tcon, chan.TerminalBConnectionControlBit, config.PinBEnabled); // Write new config to device. this.Write(memAddr, tcon); }