本文整理汇总了C#中IPin.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IPin.ToString方法的具体用法?C# IPin.ToString怎么用?C# IPin.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPin
的用法示例。
在下文中一共展示了IPin.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetServoDriver
/// <summary>
/// Gets a driver for the requested pin.
/// </summary>
/// <param name="servoPin">
/// The pin the driver is needed for.
/// </param>
/// <returns>
/// The servo driver assigned to the pin. May be null if no driver is
/// assigned or if the pin is unknown.
/// </returns>
/// <exception cref="ArgumentException">
/// The specified pin cannot be driven by any available servo driver
/// because it is not a defined servo pin.
/// </exception>
/// <exception cref="System.IO.IOException">
/// No driver is assigned to the specified pin - or - Cannot drive servo
/// from specified pin - or - another initialization error occurred.
/// </exception>
public IServoDriver GetServoDriver(IPin servoPin) {
List<IPin> servoPins = this.DefinedServoPins;
Int32 index = servoPins.IndexOf(servoPin);
if (index < 0) {
throw new ArgumentException("Servo driver cannot drive pin " + servoPin.ToString());
}
PCA9685GpioServoDriver driver = null;
lock (_lock) {
if (this._allocatedDrivers.ContainsKey((PCA9685Pin)servoPin)) {
driver = this._allocatedDrivers.Values.ElementAt(index);
}
else {
driver = new PCA9685GpioServoDriver(this._provider, (PCA9685Pin)servoPin);
this._allocatedDrivers.Add((PCA9685Pin)servoPin, driver);
}
}
return driver;
}
示例2: GetServoDriver
/// <summary>
/// Gets a driver for the requested pin.
/// </summary>
/// <param name="servoPin">
/// The pin the driver is needed for.
/// </param>
/// <returns>
/// The servo driver assigned to the pin. May be null if no driver is
/// assigned or if the pin is unknown.
/// </returns>
/// <exception cref="ArgumentException">
/// The specified servo pin is not a defined servo pin.
/// </exception>
/// <exception cref="System.IO.IOException">
/// No driver is assigned to the specified pin - or - Cannot drive servo
/// from specified pin - or - another initialization error occurred.
/// </exception>
public IServoDriver GetServoDriver(IPin servoPin) {
Int32 index = this.DefinedServoPins.IndexOf(servoPin);
if (index < 0) {
throw new ArgumentException("Servo driver cannot drive pin " + servoPin.ToString());
}
RPIServoBlasterDriver driver = null;
if (!this._allocatedDrivers.TryGetValue(servoPin, out driver)) {
String pinName = String.Empty;
if (PIN_MAP.TryGetValue((IRaspiGpio)servoPin, out pinName)) {
driver = new RPIServoBlasterDriver((IRaspiGpio)servoPin, index, pinName, this);
this.EnsureWriterIsCreated();
}
}
return driver;
}