C# Class CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterProvider

A GPIO provider for servos driven via ServoBlaster. This is an implementation of Implementation of https://github.com/richardghirst/PiBits/tree/master/ServoBlaster
Inheritance: IServoProvider
ファイルを表示 Open project: cyrusbuilt/MonoPi Class Usage Examples

Public Properties

Property Type Description
PIN_MAP String>.Dictionary
REVERSE_PIN_MAP IRaspiGpio>.Dictionary

Public Methods

Method Description
Dispose ( ) : void

Releases all resource used by the CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterProvider object.

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

GetServoDriver ( IPin servoPin ) : IServoDriver

Gets a driver for the requested pin.

UpdateServo ( String pinName, Int32 value ) : void

Updates the servo by writing the specified value to the specified pin.

Protected Methods

Method Description
EnsureWriterIsCreated ( ) : void

Ensures the writer is created.

OnUnrecognizedPinFound ( UnrecognizedPinFoundEventArgs e ) : void

Raises the unrecognized pin found event.

Private Methods

Method Description
DefinePin ( IRaspiGpio pin, String name ) : void

Helper method for adding pins to the pin maps.

GetServoPinsFromConfig ( ) : List

Gets a list of servo pins from the config and validates them against the pin map.

RPIServoBlasterProvider ( ) : System

Initializes the CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterProvider class. This is a static initializer to populate the pin maps (which are also static). This initializer will only be called *ONCE* before any static members are referenced and will not be called again during the lifetime of the application domain. As such, it is NOT advisable to dispose of the pin maps (clear the dictionaries and/or set null) unless you know what you are doing as they are only initialized once.

Method Details

Dispose() public method

Releases all resource used by the CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterProvider object.
Call Dispose when you are finished using the CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterProvider. The Dispose method leaves the CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterProvider in an unusable state. After calling Dispose, you must release all references to the CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterProvider so the garbage collector can reclaim the memory that the CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterProvider was occupying.
public Dispose ( ) : void
return void

EnsureWriterIsCreated() protected method

Ensures the writer is created.
protected EnsureWriterIsCreated ( ) : void
return void

GetServoDriver() public method

Gets a driver for the requested pin.
/// The specified servo pin is not a defined servo pin. /// /// No driver is assigned to the specified pin - or - Cannot drive servo /// from specified pin - or - another initialization error occurred. ///
public GetServoDriver ( IPin servoPin ) : IServoDriver
servoPin IPin /// The pin the driver is needed for. ///
return IServoDriver

OnUnrecognizedPinFound() protected method

Raises the unrecognized pin found event.
protected OnUnrecognizedPinFound ( UnrecognizedPinFoundEventArgs e ) : void
e CyrusBuilt.MonoPi.IO.UnrecognizedPinFoundEventArgs /// The event arguments. ///
return void

UpdateServo() public method

Updates the servo by writing the specified value to the specified pin.
/// Unable to write to the ServoBlaster device. ///
public UpdateServo ( String pinName, Int32 value ) : void
pinName String /// The name of the pin to write to. ///
value System.Int32 /// The value to write to the pin. ///
return void

Property Details

PIN_MAP public_oe static_oe property

A pin map. Maps pin GPIO pins to pin names.
public static Dictionary PIN_MAP
return String>.Dictionary

REVERSE_PIN_MAP public_oe static_oe property

A reverse-order pin map. Maps pin names to GPIO pins.
public static Dictionary REVERSE_PIN_MAP
return IRaspiGpio>.Dictionary