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

A component that is an abstraction of a servo device. This is an implementation of CyrusBuilt.MonoPi.Components.Servos.Servo.
Inheritance: Servo
Mostrar archivo Open project: cyrusbuilt/MonoPi

Public Methods

Method Description
CalcEndPointPwmDuration ( ServoOrientation orientation ) : float

Calculates end point PWM duration for the specified servo orientation.

CalcNeutralPwmDuration ( ) : float

Calculates the duration of the neutral pwm.

CalcPwmDuration ( float pos ) : Int32

Calculates the PWM duration.

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

GenericServo ( IServoDriver driver, String name ) : System

Initializes a new instance of the CyrusBuilt.MonoPi.Components.Servos.GenericServo class with the servo driver and name. This overload will use default property values.

GenericServo ( IServoDriver driver, String name, String>.Dictionary props ) : System

Initializes a new instance of the CyrusBuilt.MonoPi.Components.Servos.GenericServo class with the servo driver, name, and properties.

SetProperty ( String key, String value ) : void

Sets the value of the specified property. If the property does not already exist in the property collection, it will be added. Once set, the servo will re-initialize using the new property values.

ToString ( ) : String

Returns a System.String that represents the current CyrusBuilt.MonoPi.Components.Servos.GenericServo.

Protected Methods

Method Description
Init ( ) : void

Initializes the servo.

Private Methods

Method Description
ValidateEndPoint ( float endpoint, String propName ) : void

Validates the specified end point. If the end point is invalid an ArgumentOutOfRangeException is thrown.

ValidatePosition ( float pos ) : void

Validates the specified position value. If the position is invalid, then an ArgumentOutOfRangeException is thrown.

ValidateSubTrim ( float subtrim, String propName ) : void

Validates the specified subtrim value. If the subtrim is invalid, then an ArgumentOutOfRangeException is thrown.

Method Details

CalcEndPointPwmDuration() public method

Calculates end point PWM duration for the specified servo orientation.
/// An unsupported orientation was specified. /// /// The end point property value is not between /// /// and . ///
public CalcEndPointPwmDuration ( ServoOrientation orientation ) : float
orientation ServoOrientation /// The servo orientation. ///
return float

CalcNeutralPwmDuration() public method

Calculates the duration of the neutral pwm.
/// The subtrim property value is not within the acceptable range (SUBTRIM_MAX_LEFT /// and SUBTRIM_MAX_RIGHT). ///
public CalcNeutralPwmDuration ( ) : float
return float

CalcPwmDuration() public method

Calculates the PWM duration.
public CalcPwmDuration ( float pos ) : Int32
pos float /// Position value between -100 and +100%. ///
return System.Int32

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.Servos.GenericServo. The Dispose method leaves the CyrusBuilt.MonoPi.Components.Servos.GenericServo in an unusable state. After calling Dispose, you must release all references to the CyrusBuilt.MonoPi.Components.Servos.GenericServo so the garbage collector can reclaim the memory that the CyrusBuilt.MonoPi.Components.Servos.GenericServo was occupying.
public Dispose ( ) : void
return void

GenericServo() public method

Initializes a new instance of the CyrusBuilt.MonoPi.Components.Servos.GenericServo class with the servo driver and name. This overload will use default property values.
public GenericServo ( IServoDriver driver, String name ) : System
driver IServoDriver /// The servo driver to use. ///
name String /// The name of this servo. ///
return System

GenericServo() public method

Initializes a new instance of the CyrusBuilt.MonoPi.Components.Servos.GenericServo class with the servo driver, name, and properties.
/// The specified end point property value is not between /// /// and . /// - or - /// The specified subtrim property value is not between /// /// and . ///
public GenericServo ( IServoDriver driver, String name, String>.Dictionary props ) : System
driver IServoDriver /// The servo driver to use. ///
name String /// The name of this servo. ///
props String>.Dictionary /// A dictionary containing servo properties. ///
return System

Init() protected method

Initializes the servo.
/// The specified end point property value is not between /// /// and . /// - or - /// The specified subtrim property value is not between /// /// and . ///
protected Init ( ) : void
return void

SetProperty() public method

Sets the value of the specified property. If the property does not already exist in the property collection, it will be added. Once set, the servo will re-initialize using the new property values.
public SetProperty ( String key, String value ) : void
key String /// The property name (key). ///
value String /// The value to assign to the property. ///
return void

ToString() public method

Returns a System.String that represents the current CyrusBuilt.MonoPi.Components.Servos.GenericServo.
public ToString ( ) : String
return String