public bool DigitalWrite(Mcu.GpioPin port, bool state) { var intState = state ? 1 : 0; this.Send(Mcu.McuCommand.CP_DIGITAL_WRITE, (int)port, intState); return(true); }
public bool SetDigitalPinMode(Mcu.GpioPin port, Mcu.DigitalIOMode mode) { this.Send(Mcu.McuCommand.CP_SET_PIN_MODE, (int)port, (int)mode); var r = this.ReadAnswer(); r.Values = new List <int>(); if (r.Succeeded && r.Buffer.Count == 2) // Answer is always 2 byte { return(r.Buffer[0] == (int)port); } else { return(false); } }
public bool DigitalRead(Mcu.GpioPin port) { this.Send(Mcu.McuCommand.CP_DIGITAL_READ, (int)port); var r = this.ReadAnswer(); r.Values = new List <int>(); if (r.Succeeded && r.Buffer.Count == 2) // Answer is always 2 byte { return(r.Buffer[0] == 1); } else { throw new InvalidOperationException(); } }