/// <summary> /// Gets the unused digital pins. /// </summary> /// <returns>The unused digital pins.</returns> private DPin[] GetUnusedDigitalPins() { var unusedpins = new List<DPin> (); var numpins = Board.NumberOfDigitalPins; for (uint i = 0; i < numpins; i++) { unusedpins.Add (new DPin () { Number = i, AnalogNumber = ((Array.IndexOf (Board.HardwareAnalogPins, i) > -1) ? Array.IndexOf (Board.HardwareAnalogPins, i) : -1), RX = (Board.RX [0] == i), TX = (Board.TX [0] == i), SDA = (Board.SDA [0] == i), SCL = (Board.SCL [0] == i) }); } foreach (IPin pin in Pins) { if (pin is DPin) { unusedpins.RemoveAll (o => o.Number == pin.Number); } else if (pin is APin) { unusedpins.RemoveAll (o => o.Number == (pin as APin).DigitalNumber); } } return unusedpins.ToArray<DPin> (); }
/// <summary> /// Gets the unused analog pins. /// </summary> /// <returns>The unused analog pins.</returns> private APin[] GetUnusedAnalogPins() { var unusedpins = new List<APin> (); var numpins = Board.NumberOfAnalogPins; for (uint i = 0; i < numpins; i++) { unusedpins.Add (new APin () { Number = i, DigitalNumber = Board.HardwareAnalogPins [i], RX = (Board.RX [0] == i), TX = (Board.TX [0] == i), SDA = (Board.SDA [0] == i), SCL = (Board.SCL [0] == i) }); } foreach (IPin pin in Pins) { if (pin is APin) { unusedpins.RemoveAll (o => o.Number == pin.Number); } else if (pin is DPin) { unusedpins.RemoveAll (o => o.DigitalNumber == pin.Number); } } return unusedpins.OrderBy (o => o.Number).ToArray<APin> (); }