/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.PiFaceGpioBase"/> /// class with the physical pin represented by this class. /// </summary> /// <param name="pin"> /// The physical pin being wrapped by this class. /// </param> protected PiFaceGpioBase(PiFacePins pin) { this._innerPin = pin; switch (pin) { case PiFacePins.Input00: case PiFacePins.Input01: case PiFacePins.Input02: case PiFacePins.Input03: case PiFacePins.Input04: case PiFacePins.Input05: case PiFacePins.Input06: case PiFacePins.Input07: this._mode = PinMode.IN; break; case PiFacePins.Output00: case PiFacePins.Output01: case PiFacePins.Output02: case PiFacePins.Output03: case PiFacePins.Output04: case PiFacePins.Output05: case PiFacePins.Output06: case PiFacePins.Output07: this._mode = PinMode.OUT; break; case PiFacePins.None: default: break; } }
/// <summary> /// Releases all resource used by the <see cref="CyrusBuilt.MonoPi.IO.PiFaceGpioBase"/> /// object. /// </summary> /// <remarks> /// Call <see cref="Dispose"/> when you are finished using the /// <see cref="CyrusBuilt.MonoPi.IO.PiFaceGpioBase"/>. The /// <see cref="Dispose"/> method leaves the <see cref="CyrusBuilt.MonoPi.IO.PiFaceGpioBase"/> /// in an unusable state. After calling <see cref="Dispose"/>, you must /// release all references to the <see cref="CyrusBuilt.MonoPi.IO.PiFaceGpioBase"/> /// so the garbage collector can reclaim the memory that the /// <see cref="CyrusBuilt.MonoPi.IO.PiFaceGpioBase"/> was occupying. /// </remarks> public virtual void Dispose() { if (this._isDisposed) { return; } _exportedPins.Clear(); _exportedPins = null; this.StateChanged = null; this._innerPin = PiFacePins.None; this._mode = PinMode.IN; this._isDisposed = true; this._name = null; this._tag = null; GC.SuppressFinalize(this); }
/// <summary> /// Read the specified Revision 1.0 pin. /// </summary> /// <param name="pin"> /// The pin to read. /// </param> /// <returns> /// The value read from the pin. /// </returns> public static PinState Read(PiFacePins pin) { String name = Enum.GetName(typeof(PiFacePins), pin); return(internal_Read((Int32)pin, name)); }
/// <summary> /// Write the specified pin and value. /// </summary> /// <param name="pin"> /// The pin to write to. /// </param> /// <param name="value"> /// The value to write. /// </param> public static void Write(PiFacePins pin, PinState value) { String name = Enum.GetName(typeof(PiFacePins), pin); internal_Write((Int32)pin, value, name); }
/// <summary> /// Unexport the GPIO. /// </summary> /// <param name="pin"> /// The pin to unexport. /// </param> private static void UnexportPin(PiFacePins pin) { internal_UnexportPin((Int32)pin); }
/// <summary> /// Exports the pin setting the direction. /// </summary> /// <param name="pin"> /// The pin on the PiFace to export. /// </param> /// <param name="mode"> /// The I/0 mode of the pin. /// </param> private static void ExportPin(PiFacePins pin, PinMode mode) { internal_ExportPin((Int32)pin, mode); }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.PiFaceDigitalGPIO"/> /// class with the PiFace pin to control and the initial value to write. /// </summary> /// <param name="pin"> /// The PiFace pin to control. /// </param> /// <param name="initialValue"> /// The initial value to write. /// </param> public PiFaceDigitalGPIO(PiFacePins pin, PinState initialValue) : base(pin, initialValue) { }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.PiFaceGpioBase"/> /// class with the physical pin represented by this class. /// </summary> /// <param name="pin"> /// The physical pin being wrapped by this class. /// </param> /// <param name="initialValue"> /// Initial value. /// </param> protected PiFaceGpioBase(PiFacePins pin, PinState initialValue) : this(pin) { this._initValue = initialValue; }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.PiFaceDigitalGPIO"/> /// class with the PiFace pin to control. /// </summary> /// <param name="pin"> /// The PiFace pin to control. /// </param> public PiFaceDigitalGPIO(PiFacePins pin) : base(pin) { }
/// <summary> /// Read the specified Revision 1.0 pin. /// </summary> /// <param name="pin"> /// The pin to read. /// </param> /// <returns> /// The value read from the pin. /// </returns> public static PinState Read(PiFacePins pin) { String name = Enum.GetName(typeof(PiFacePins), pin); return internal_Read((Int32)pin, name); }