Example #1
0
 /// <summary>
 /// Asynchronously gets a pin's mode (digital input/output, analog etc.) and actual value.
 /// </summary>
 /// <param name="pinNumber">The pin number</param>
 /// <returns>The pin's state</returns>
 public static async Task <PinState> GetPinStateAsync(this ArduinoSession session, int pinNumber)
 {
     session.RequestPinState(pinNumber);
     //return await Task.Run
     //(
     //    () =>
     //    (PinState)((FirmataMessage)session.GetMessageFromQueue(new FirmataMessage(MessageType.PinStateResponse))).Value
     //);
     return(await Task.Run(() => session.GetMessageFromQueue <PinState>().Value).ConfigureAwait(false));
 }
Example #2
0
 /// <summary>
 /// Gets a pin's mode (digital input/output, analog etc.) and actual value.
 /// </summary>
 /// <param name="pinNumber">The pin number</param>
 /// <returns>The pin's state</returns>
 public static PinState GetPinState(this ArduinoSession session, int pinNumber)
 {
     session.RequestPinState(pinNumber);
     //return (PinState)((FirmataMessage)session.GetMessageFromQueue(new FirmataMessage(MessageType.PinStateResponse))).Value;
     return(session.GetMessageFromQueue <PinState>().Value);
 }