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

Base class for Microchip MCP45XX and MCP46XX IC device abstraction components.
Inheritance: ComponentBase, IMicrochipPotentiometer
ファイルを表示 Open project: cyrusbuilt/MonoPi

Protected Properties

Property Type Description
_nonVolMode MicrochipPotNonVolatileMode

Public Methods

Method Description
Decrease ( ) : void

Decreases the wiper's value by one step. It is not an error if the wiper already hit the lower boundary (0). In this situation, the wiper doesn't change.

Decrease ( Int32 steps ) : void

Decreases the wiper's value by the specified number of steps. It is not an error if the wiper hits or already hit the lower boundary (0). In such situations, the wiper sticks to the lower boundary or doesn't change.

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.MicrochipPotentiometerBase. The Dispose method leaves the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase in an unusable state. After calling Dispose, you must release all references to the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase so the garbage collector can reclaim the memory that the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase was occupying.

Increase ( ) : void

Increase the wiper's value by one step. It is not an error if the wiper already hit the upper boundary. In this situation, the wiper doesn't change.

Increase ( Int32 steps ) : void

Increases the wiper's value by the specified number of steps. It is not an error if the wiper hits or already hit the upper boundary. In such situations, the wiper sticks to the upper boundary or doesn't change.

IsChannelSupported ( MicrochipPotChannel channel ) : System.Boolean

Determines whether or not the specified channel is supported by the underlying device.

SetWiperLock ( System.Boolean enabled ) : void

Enables or disables the wiper lock.

SetWriteProtection ( System.Boolean enabled ) : void

Enables or disables write-protection for devices capable of non-volatile memory. Enabling write-protection does not only protect non-volatile wipers, it also protects any other non-volatile information stored (i.e. wiper-locks).

UpdateCacheFromDevice ( ) : Int32

Updates the cache to the wiper's value.

Protected Methods

Method Description
BuildI2CAddress ( System.Boolean pinA0, System.Boolean pinA1, System.Boolean pinA2 ) : Int32

Builds the I2C bus address of the device based on which which address pins are set.

GetNonVolatileValue ( ) : Int32

Gets the non-volatile wiper's value.

The visibility of this method is protected because not all devices support non-volatile wipers. Any derived class may publish this method.

Initialize ( Int32 initialValForNonVolWipers ) : void

Initializes the wiper to a defined status. For devices capable of non-volatile wipers, the non-volatile value is loaded. For devices not capable, the given value is set in the device.

MicrochipPotentiometerBase ( II2CBus device, System.Boolean pinA0, System.Boolean pinA1, System.Boolean pinA2, MicrochipPotChannel channel, MicrochipPotNonVolatileMode nonVolatileMode, Int32 initialNonVolWiperValue ) : System

Initializes a new instance of the 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.

SetNonVolatileMode ( MicrochipPotNonVolatileMode mode ) : void

Sets the non-volatility mode.

The visibility of this method is protected because not all devices support non-volatile wipers. Any derived class may publish this method.

Private Methods

Method Description
GetValueAccordingBoundaries ( Int32 val ) : Int32

Adjusts the given value according to the boundaries (0 and CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase.MaxValue).

MicrochipPotentiometerBase_WiperActionEvent ( object sender, WiperEventArgs e ) : void

The potentiometer base wiper action event handler. This sets the channel value for either volatile or non-volatile wipers (depending on volatilty mode).

OnWiperActionEvent ( WiperEventArgs e ) : void

Raises the wiper action event event.

Method Details

BuildI2CAddress() protected static method

Builds the I2C bus address of the device based on which which address pins are set.
protected static BuildI2CAddress ( System.Boolean pinA0, System.Boolean pinA1, System.Boolean pinA2 ) : Int32
pinA0 System.Boolean /// Whether the device's address pin A0 is high (true) or low (false). ///
pinA1 System.Boolean /// Whether the device's address pin A1 (if available) is high (true) or low (false). ///
pinA2 System.Boolean /// Whether the device's address pin A2 (if available) is high (true) or low (false). ///
return System.Int32

Decrease() public method

Decreases the wiper's value by one step. It is not an error if the wiper already hit the lower boundary (0). In this situation, the wiper doesn't change.
/// Communication with the device failed. ///
public Decrease ( ) : void
return void

Decrease() public method

Decreases the wiper's value by the specified number of steps. It is not an error if the wiper hits or already hit the lower boundary (0). In such situations, the wiper sticks to the lower boundary or doesn't change.
/// Communication with the device failed. ///
public Decrease ( Int32 steps ) : void
steps System.Int32 /// The number of steps to decrease by. ///
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.MicrochipPotentiometerBase. The Dispose method leaves the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase in an unusable state. After calling Dispose, you must release all references to the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase so the garbage collector can reclaim the memory that the CyrusBuilt.MonoPi.Components.Potentiometers.Microchip.MicrochipPotentiometerBase was occupying.
public Dispose ( ) : void
return void

GetNonVolatileValue() protected method

Gets the non-volatile wiper's value.
The visibility of this method is protected because not all devices support non-volatile wipers. Any derived class may publish this method.
/// Communication with device failed or malformed result. /// /// The device is not capable of non-volatile wipers. ///
protected GetNonVolatileValue ( ) : Int32
return System.Int32

Increase() public method

Increase the wiper's value by one step. It is not an error if the wiper already hit the upper boundary. In this situation, the wiper doesn't change.
/// Communication with the device failed. ///
public Increase ( ) : void
return void

Increase() public method

Increases the wiper's value by the specified number of steps. It is not an error if the wiper hits or already hit the upper boundary. In such situations, the wiper sticks to the upper boundary or doesn't change.
/// Communication with the device failed. ///
public Increase ( Int32 steps ) : void
steps System.Int32 /// How many steps to increase. ///
return void

Initialize() protected method

Initializes the wiper to a defined status. For devices capable of non-volatile wipers, the non-volatile value is loaded. For devices not capable, the given value is set in the device.
/// Communication with device failed or malformed result. ///
protected Initialize ( Int32 initialValForNonVolWipers ) : void
initialValForNonVolWipers System.Int32 /// The initial value for devices not capable of non-volatile wipers. ///
return void

IsChannelSupported() public method

Determines whether or not the specified channel is supported by the underlying device.
public IsChannelSupported ( MicrochipPotChannel channel ) : System.Boolean
channel MicrochipPotChannel /// The channel to check. ///
return System.Boolean

MicrochipPotentiometerBase() protected method

Initializes a new instance of the 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.
/// cannot be null. - or - /// cannot be null. /// /// is not supported by this device. /// /// Unable to open the I2C bus. ///
protected MicrochipPotentiometerBase ( II2CBus device, System.Boolean pinA0, System.Boolean pinA1, System.Boolean pinA2, MicrochipPotChannel channel, MicrochipPotNonVolatileMode nonVolatileMode, Int32 initialNonVolWiperValue ) : System
device II2CBus /// The I2C bus device this instance is connected to. ///
pinA0 System.Boolean /// Whether the device's address pin A0 is high (true) or low (false). ///
pinA1 System.Boolean /// Whether the device's address pin A1 is high (true) or low (false). ///
pinA2 System.Boolean /// Whether the device's address pin A2 is high (true) or low (false). ///
channel MicrochipPotChannel /// Which of the potentiometers provided by the device to control. ///
nonVolatileMode MicrochipPotNonVolatileMode /// The way non-volatile reads or writes are done. ///
initialNonVolWiperValue System.Int32 /// The value for devices which are not capable of non-volatile wipers. ///
return System

SetNonVolatileMode() protected method

Sets the non-volatility mode.
The visibility of this method is protected because not all devices support non-volatile wipers. Any derived class may publish this method.
/// This device is not capable of non-volatile wipers. ///
protected SetNonVolatileMode ( MicrochipPotNonVolatileMode mode ) : void
mode MicrochipPotNonVolatileMode /// The way non-volatile reads or writes are done. ///
return void

SetWiperLock() public method

Enables or disables the wiper lock.
/// Communication with device failed or malformed result. ///
public SetWiperLock ( System.Boolean enabled ) : void
enabled System.Boolean /// Set true to enable. ///
return void

SetWriteProtection() public method

Enables or disables write-protection for devices capable of non-volatile memory. Enabling write-protection does not only protect non-volatile wipers, it also protects any other non-volatile information stored (i.e. wiper-locks).
/// Communication with device failed or malformed result. ///
public SetWriteProtection ( System.Boolean enabled ) : void
enabled System.Boolean /// Set true to enable. ///
return void

UpdateCacheFromDevice() public method

Updates the cache to the wiper's value.
/// Communication with device failed or malformed result. ///
public UpdateCacheFromDevice ( ) : Int32
return System.Int32

Property Details

_nonVolMode protected_oe property

protected MicrochipPotNonVolatileMode _nonVolMode
return MicrochipPotNonVolatileMode