/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <filterpriority>2</filterpriority> /// <remarks> /// Call <see cref="Dispose"/> when you are finished using the /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase"/>. The /// <see cref="Dispose"/> method leaves the /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase"/> in an unusable /// state. After calling <see cref="Dispose"/>, you must release all references to the /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase"/> so the garbage /// collector can reclaim the memory that the /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase"/> was occupying. /// </remarks> public override void Dispose() { if (base.IsDisposed) { return; } if (this._controller != null) { this._controller.Dispose(); this._controller = null; } this._currentValue = -1; this._channel = MicrochipPotChannel.None; this._nonVolMode = MicrochipPotNonVolatileMode.VolatileAndNonVolatile; base.Dispose(); }
/// <summary> /// Initializes a new instance of the /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase"/> /// class with the I2C device connection, pin A0,A1, and A2 states, /// the potentiometer (channel) provided by the device, how to do /// non-volatile I/O and the initial value for devices which are not /// capable of non-volatile wipers. /// </summary> /// <param name="device"> /// The I2C bus device this instance is connected to. /// </param> /// <param name="pinA0"> /// Whether the device's address pin A0 is high (true) or low (false). /// </param> /// <param name="pinA1"> /// Whether the device's address pin A1 is high (true) or low (false). /// </param> /// <param name="pinA2"> /// Whether the device's address pin A2 is high (true) or low (false). /// </param> /// <param name="channel"> /// Which of the potentiometers provided by the device to control. /// </param> /// <param name="nonVolatileMode"> /// The way non-volatile reads or writes are done. /// </param> /// <param name="initialNonVolWiperValue"> /// The value for devices which are not capable of non-volatile wipers. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="device"/> cannot be null. - or - <paramref name="channel"/> /// cannot be null. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="channel"/> is not supported by this device. /// </exception> /// <exception cref="System.IO.IOException"> /// Unable to open the I2C bus. /// </exception> protected MicrochipPotentiometerBase(II2CBus device, Boolean pinA0, Boolean pinA1, Boolean pinA2, MicrochipPotChannel channel, MicrochipPotNonVolatileMode nonVolatileMode, Int32 initialNonVolWiperValue) : base() { if (device == null) { throw new ArgumentNullException("device"); } if (!this.IsChannelSupported(channel)) { throw new ArgumentException("Specified channel not supported by device.", "channel"); } this._channel = channel; this._nonVolMode = nonVolatileMode; Int32 deviceAddr = BuildI2CAddress(pinA0, pinA1, pinA2); this._controller = new MicrochipPotDeviceController(device, deviceAddr); this.WiperActionEvent += this.MicrochipPotentiometerBase_WiperActionEvent; this.Initialize(initialNonVolWiperValue); }
/// <summary> /// Initializes a new instance of the /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase.WiperEventArgs"/> /// class with the device control channel, device controller, and /// device reading value. /// </summary> /// <param name="channel"> /// The control channel for the wiper. /// </param> /// <param name="controller"> /// The device controller. /// </param> /// <param name="val"> /// The device reading value. /// </param> public WiperEventArgs(DeviceControlChannel channel, MicrochipPotDeviceController controller, Int32 val) : base() { this._chan = channel; this._ctlr = controller; }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <filterpriority>2</filterpriority> /// <remarks> /// Call <see cref="Dispose"/> when you are finished using the /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase"/>. The /// <see cref="Dispose"/> method leaves the /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase"/> in an unusable /// state. After calling <see cref="Dispose"/>, you must release all references to the /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase"/> so the garbage /// collector can reclaim the memory that the /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase"/> was occupying. /// </remarks> public override void Dispose() { if (base.IsDisposed) { return; } if (this._controller != null) { this._controller.Dispose(); this._controller = null; } this._currentValue = -1; this._channel = MicrochipPotChannel.None; this._nonVolMode = MicrochipPotNonVolatileMode.VolatileAndNonVolatile; base.Dispose(); }
/// <summary> /// Initializes a new instance of the /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase"/> /// class with the I2C device connection, pin A0,A1, and A2 states, /// the potentiometer (channel) provided by the device, how to do /// non-volatile I/O and the initial value for devices which are not /// capable of non-volatile wipers. /// </summary> /// <param name="device"> /// The I2C bus device this instance is connected to. /// </param> /// <param name="pinA0"> /// Whether the device's address pin A0 is high (true) or low (false). /// </param> /// <param name="pinA1"> /// Whether the device's address pin A1 is high (true) or low (false). /// </param> /// <param name="pinA2"> /// Whether the device's address pin A2 is high (true) or low (false). /// </param> /// <param name="channel"> /// Which of the potentiometers provided by the device to control. /// </param> /// <param name="nonVolatileMode"> /// The way non-volatile reads or writes are done. /// </param> /// <param name="initialNonVolWiperValue"> /// The value for devices which are not capable of non-volatile wipers. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="device"/> cannot be null. - or - <paramref name="channel"/> /// cannot be null. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="channel"/> is not supported by this device. /// </exception> /// <exception cref="System.IO.IOException"> /// Unable to open the I2C bus. /// </exception> protected MicrochipPotentiometerBase(II2CBus device, Boolean pinA0, Boolean pinA1, Boolean pinA2, MicrochipPotChannel channel, MicrochipPotNonVolatileMode nonVolatileMode, Int32 initialNonVolWiperValue) : base() { if (device == null) { throw new ArgumentNullException("device"); } if (!this.IsChannelSupported(channel)) { throw new ArgumentException("Specified channel not supported by device.", "channel"); } this._channel = channel; this._nonVolMode = nonVolatileMode; Int32 deviceAddr = BuildI2CAddress(pinA0, pinA1, pinA2); this._controller = new MicrochipPotDeviceController(device, deviceAddr); this.WiperActionEvent += this.MicrochipPotentiometerBase_WiperActionEvent; this.Initialize(initialNonVolWiperValue); }
/// <summary> /// Initializes a new instance of the /// <see cref="CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase.WiperEventArgs"/> /// class with the device control channel, device controller, and /// device reading value. /// </summary> /// <param name="channel"> /// The control channel for the wiper. /// </param> /// <param name="controller"> /// The device controller. /// </param> /// <param name="val"> /// The device reading value. /// </param> public WiperEventArgs(DeviceControlChannel channel, MicrochipPotDeviceController controller, Int32 val) : base() { this._chan = channel; this._ctlr = controller; }