C# Class CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotDeviceController

An MCP45XX and MCP46XX device controller component. This mostly a port of the device controller in the Pi4J project (Java port author Raspelikan) which is a port of similar C++ code from Stibro's code blog.
Inheritance: IDisposable
ファイルを表示 Open project: cyrusbuilt/MonoPi Class Usage Examples

Public Methods

Method Description
Decrease ( DeviceControlChannel channel, Int32 steps ) : void

Decriments the volatile wiper for the given number of steps.

Dispose ( ) : void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Call Dispose when you are finished using the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotDeviceController. The Dispose method leaves the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotDeviceController in an unusable state. After calling Dispose, you must release all references to the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotDeviceController so the garbage collector can reclaim the memory that the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotDeviceController was occupying.

GetTerminalConfiguration ( DeviceControlChannel channel ) : DeviceControllerTerminalConfiguration

Gets the terminal configuration for the specified channel.

GetValue ( DeviceControlChannel channel, System.Boolean nonVolatile ) : Int32

Receives the current wiper's value from the device.

Increase ( DeviceControlChannel channel, Int32 steps ) : void

Increments the volatile wiper for the given number of steps.

MicrochipPotDeviceController ( II2CBus device, Int32 busAddress ) : System

Initializes a new instance of the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotDeviceController class with the I2C bus device this instance is connected to and the bus address of that device.

SetTerminalConfiguration ( DeviceControllerTerminalConfiguration config ) : void

Sets the device's terminal configuration.

SetValue ( DeviceControlChannel channel, Int32 value, System.Boolean nonVolatile ) : void

Sets the wiper's value in the device.

SetWiperLock ( DeviceControlChannel channel, System.Boolean locked ) : void

Enables or disables the wiper's lock.

SetWriteProtection ( System.Boolean enabled ) : void

Enables or disables the device's write-protection.

Private Methods

Method Description
IncreaseOrDecrease ( Byte memAddr, System.Boolean increase, Int32 steps ) : void

Writes n (steps) bytes to the device holding the wiper's address and the increment or decrement command and value.

Read ( Byte memAddr ) : Int32

Reads two bytes from the device at the given memory address.

SetBit ( Int32 mem, Int32 mask, System.Boolean val ) : Int32

Sets or clears a bit in the specified memory (integer).

Write ( Byte memAddr, Int32 val ) : void

Writes 9 bits of the give value to the device.

Method Details

Decrease() public method

Decriments the volatile wiper for the given number of steps.
/// This instance has been disposed and can no longer be used. /// /// cannot be null. /// /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. ///
public Decrease ( DeviceControlChannel channel, Int32 steps ) : void
channel DeviceControlChannel /// The device channel the wiper is on. ///
steps System.Int32 /// The number of steps. ///
return void

Dispose() public method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Call Dispose when you are finished using the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotDeviceController. The Dispose method leaves the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotDeviceController in an unusable state. After calling Dispose, you must release all references to the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotDeviceController so the garbage collector can reclaim the memory that the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotDeviceController was occupying.
public Dispose ( ) : void
return void

GetTerminalConfiguration() public method

Gets the terminal configuration for the specified channel.
/// This instance has been disposed and can no longer be used. /// /// cannot be null. /// /// Unable to read from device. ///
public GetTerminalConfiguration ( DeviceControlChannel channel ) : DeviceControllerTerminalConfiguration
channel DeviceControlChannel /// The channel to get the terminal configuration for. ///
return DeviceControllerTerminalConfiguration

GetValue() public method

Receives the current wiper's value from the device.
/// This instance has been disposed and can no longer be used. /// /// cannot be null. /// /// Unable to read from device. ///
public GetValue ( DeviceControlChannel channel, System.Boolean nonVolatile ) : Int32
channel DeviceControlChannel /// The device channel the wiper is on. ///
nonVolatile System.Boolean /// Set true to read from non-volatile memory, false to read from /// volatile memory. ///
return System.Int32

Increase() public method

Increments the volatile wiper for the given number of steps.
/// This instance has been disposed and can no longer be used. /// /// cannot be null. /// /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. ///
public Increase ( DeviceControlChannel channel, Int32 steps ) : void
channel DeviceControlChannel /// The device channel the wiper is on. ///
steps System.Int32 /// The number of steps. ///
return void

MicrochipPotDeviceController() public method

Initializes a new instance of the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotDeviceController class with the I2C bus device this instance is connected to and the bus address of that device.
/// cannot be null. /// /// Unable to open the I2C bus. ///
public MicrochipPotDeviceController ( II2CBus device, Int32 busAddress ) : System
device II2CBus /// The I2C bus device this instance is connected to. ///
busAddress System.Int32 /// The bus address of the device. ///
return System

SetTerminalConfiguration() public method

Sets the device's terminal configuration.
/// This instance has been disposed and can no longer be used. /// /// cannot be null. /// /// The specified configuration cannot have a null channel. /// /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. ///
public SetTerminalConfiguration ( DeviceControllerTerminalConfiguration config ) : void
config DeviceControllerTerminalConfiguration /// The configuration to set. ///
return void

SetValue() public method

Sets the wiper's value in the device.
/// This instance has been disposed and can no longer be used. /// /// cannot be null. /// /// cannot be a negative. /// /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. ///
public SetValue ( DeviceControlChannel channel, Int32 value, System.Boolean nonVolatile ) : void
channel DeviceControlChannel /// The device channel the wiper is on. ///
value System.Int32 /// The wiper's value. ///
nonVolatile System.Boolean /// Set true to write to non-volatile memory, or false to write to volatile memory. ///
return void

SetWiperLock() public method

Enables or disables the wiper's lock.
/// This instance has been disposed and can no longer be used. /// /// cannot be null. /// /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. ///
public SetWiperLock ( DeviceControlChannel channel, System.Boolean locked ) : void
channel DeviceControlChannel /// The channel of the wiper to set the lock for. ///
locked System.Boolean /// Set true to enable the lock, or false to disable. ///
return void

SetWriteProtection() public method

Enables or disables the device's write-protection.
/// This instance has been disposed and can no longer be used. /// /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. ///
public SetWriteProtection ( System.Boolean enabled ) : void
enabled System.Boolean /// Set true to enable write protection, or false to disable. ///
return void