/// <summary> /// Change Pin mode /// </summary> /// <param name="mode">Mode</param> public void ChangePinMode(PinMode mode, string bundle = null) { if (!isInit || mode != pinMode) { pinMode = mode; WriteMessage(UduinoManager.BuildMessageParameters("s", currentPin, (int)pinMode), bundle); isInit = true; } }
/// <summary> /// Send OptimizedValue /// </summary> /// <param name="sendValue">Value to send</param> public void SendPinValue(int sendValue, string typeOfPin, string bundle = null) { if (sendValue != prevSendValue) { this.sendValue = sendValue; WriteMessage(UduinoManager.BuildMessageParameters(typeOfPin, currentPin, sendValue), bundle); prevSendValue = sendValue; } }
public void Destroy() { if (pinMode == PinMode.Output) { WriteMessage(UduinoManager.BuildMessageParameters("d", currentPin, 0), "destroy"); } else if (pinMode == PinMode.PWM || pinMode == PinMode.Input) { WriteMessage(UduinoManager.BuildMessageParameters("a", currentPin, 0), "destroy"); } }
/// <summary> /// Send OptimizedValue /// </summary> /// <param name="sendValue">Value to send</param> public virtual int SendRead(string bundle = null, System.Action <string> action = null, bool digital = false) { string cmd = "r" + (digital ? "d" : ""); if (bundle != null) { cmd = "br"; } string valueAsString = Manager.Read(device, UduinoManager.BuildMessageParameters(cmd, currentPin), action: action, bundle: bundle); int returnedValue = ParseIntValue(valueAsString); if (returnedValue != -1) { lastReadValue = returnedValue; } return(lastReadValue); }