public SparkFunAnemometerDriver(GpioController gpioController, GpioPins pin) { _gpioController = gpioController; _pin = _gpioController.OpenPin((int)pin); _pin.SetDriveMode(GpioPinDriveMode.InputPullUp); _pulseCounter = new GpioChangeCounter(_pin) { Polarity = GpioChangePolarity.Falling }; }
public StatusLed(GpioController gpioController, GpioPins wifiStatus, GpioPins mqttStatus) { _gpioController = gpioController; _connectionStatus = mqttStatus; _wifiStatusLed = _gpioController.OpenPin((int)wifiStatus); _mqttStatusLed = _gpioController.OpenPin((int)mqttStatus); _wifiStatusLed.SetDriveMode(GpioPinDriveMode.Output); _mqttStatusLed.SetDriveMode(GpioPinDriveMode.Output); _wifiStatusLed.Write(GpioPinValue.Low); _mqttStatusLed.Write(GpioPinValue.Low); }
/// <summary> /// Releases all resource used by the <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/> /// object. /// </summary> /// <remarks> /// Call <see cref="Dispose"/> when you are finished using the /// <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/>.The <see cref="Dispose"/> /// method leaves the <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/> in an /// unusable state. After calling <see cref="Dispose"/>, you must release /// all references to the <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/> so /// the garbage collector can reclaim the memory that the /// <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/> was occupying. /// </remarks> public virtual void Dispose() { if (this._isDisposed) { return; } _exportedPins.Clear(); _exportedPins = null; this.StateChanged = null; this._state = PinState.Low; this._mode = PinMode.TRI; this._pin = GpioPins.GPIO_NONE; this._isDisposed = true; }
public GpioStatus InitializeGpios() { if (Gpios != null && GpioPins != null) { for (int i = 0; i < GpioPins.Count(); i++) { Gpios.Add(InitGpioOutput(GpioPins[i])); if (Gpios[i] == null) { return(GpioStatus.NoPin); } } } return(GpioStatus.Success); }
public LinearActuatorDriver(GpioController gpioController, GpioPins pinExtension, GpioPins pinReduction, GpioPins pinEnable) { _gpioController = gpioController; _pinEnable = _gpioController.OpenPin((int)pinEnable); _pinEnable.SetDriveMode(GpioPinDriveMode.Output); _pinEnable.Write(GpioPinValue.Low); _pinExtension = _gpioController.OpenPin((int)pinExtension); _pinExtension.SetDriveMode(GpioPinDriveMode.Output); _pinExtension.Write(GpioPinValue.Low); _pinReduction = _gpioController.OpenPin((int)pinReduction); _pinReduction.SetDriveMode(GpioPinDriveMode.Output); _pinReduction.Write(GpioPinValue.Low); }
public Hardware(Int32[] pins) { if (GpioPins == null) { GpioPins = pins == null ? new List <int>() : new List <int>(pins); Gpios = new List <GpioPin>(); } else { if (pins != null) { foreach (var pin in pins) { GpioPins.Add(pin); Gpios.Add(InitGpioOutput(pin)); } } } }
public GpioFile(GpioPins pin, GpioDirection direction, bool initialValue) { if (pin == GpioPins.GpioNone) { throw new ArgumentException("Invalid pin"); } gpio_open(); _pin = pin; try { PinDirection = direction; Write(initialValue); } catch { Dispose(); throw; } }
public static void Main(string[] args) { Dictionary <string, string> parameters; try { parameters = ParseParameters(args); } catch (Exception e) { Console.WriteLine("Error while initializing."); Console.WriteLine(e.Message); Console.WriteLine("Terminating program."); return; } if (!parameters.ContainsKey("url")) { parameters.Add("url", @"http://donotdisturb.ngrok.io/room"); } if (!parameters.ContainsKey("room")) { parameters.Add("roomName", "GB-Demo"); } //Start the organizer here MeetingOrganizer.Start(parameters["url"], parameters["roomName"]); MeetingOrganizer.Instance.MeetingEndsIn += MeetingEndsIn; bool end = false; gpio = new GpioPins(); gpio.Enable(26); while (!end) { end = Console.ReadLine() == "exit"; } gpio.Close(); }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.LCD.GpioFileLcdTransferProvider"/> /// class with the mode, register select pin, read/write pin, enable /// pin, and data lines. /// </summary> /// <param name="fourBitMode"> /// If set to true, then use 4 bit mode instead of 8 bit. /// </param> /// <param name="rs"> /// The number of the CPU pin that is connected to the RS (Register Select) /// pin on the LCD. /// </param> /// <param name="rw"> /// The number of the CPU pin that is connected to the RW (Read/Write) /// pin on the LCD. /// </param> /// <param name="enable"> /// The number of the CPU pin that is connected to the enable pin on /// the LCD. /// </param> /// <param name="d0"> /// Data line 0. /// </param> /// <param name="d1"> /// Data line 1. /// </param> /// <param name="d2"> /// Data line 2. /// </param> /// <param name="d3"> /// Data line 3. /// </param> /// <param name="d4"> /// Data line 4. /// </param> /// <param name="d5"> /// Data line 5. /// </param> /// <param name="d6"> /// Data line 6. /// </param> /// <param name="d7"> /// Data line 7. /// </param> /// <remarks> /// The display can be controlled using 4 or 8 data lines. If the former, /// omit the pin numbers for d0 to d3 and leave those lines disconnected. /// The RW pin can be tied to ground instead of connected to a pin on the /// Arduino; If so, omit it from this constructor's parameters. /// </remarks> /// <exception cref="ArgumentException"> /// <paramref name="rs"/> and <paramref name="enable"/> cannot be set to /// <see cref="GpioPins.GPIO_NONE"/>. /// </exception> public GpioFileLcdTransferProvider(Boolean fourBitMode, GpioPins rs, GpioPins rw, GpioPins enable, GpioPins d0, GpioPins d1, GpioPins d2, GpioPins d3, GpioPins d4, GpioPins d5, GpioPins d6, GpioPins d7) { this._fourBitMode = fourBitMode; if (rs == GpioPins.GPIO_NONE) { throw new ArgumentException("rs"); } this._registerSelectPort = new GpioFile(rs, PinMode.OUT); this._registerSelectPort.Provision(); // We can save 1 pin by not using RW. Indicate this by passing GpioPins.GPIO_NONE // instead of pin #. if (rw != GpioPins.GPIO_NONE) { this._readWritePort = new GpioFile(rw, PinMode.OUT); this._readWritePort.Provision(); } if (enable == GpioPins.GPIO_NONE) { throw new ArgumentException("enable"); } this._enablePort = new GpioFile(enable, PinMode.OUT); this._enablePort.Provision(); GpioPins[] dataPins = { d0, d1, d2, d3, d4, d5, d6, d7 }; this._dataPorts = new GpioFile[8]; for (Int32 i = 0; i < 8; i++) { if (dataPins[i] != GpioPins.GPIO_NONE) { this._dataPorts[i] = new GpioFile(dataPins[i], PinMode.OUT); this._dataPorts[i].Provision(); } } }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.LCD.GpioMemLcdTransferProvider"/> /// class with the mode flag, register select pin, read/write pin, /// enable pin, and data pins. /// </summary> /// <param name="rs"> /// The number of the CPU pin that is connected to the RS (Register Select) /// pin on the LCD. /// </param> /// <param name="enable"> /// The number of the CPU pin that is connected to the enable pin /// on the LCD. /// </param> /// <param name="d0"> /// Data line 0. /// </param> /// <param name="d1"> /// Data line 1. /// </param> /// <param name="d2"> /// Data line 2. /// </param> /// <param name="d3"> /// Data line 3. /// </param> /// <param name="d4"> /// Data line 4. /// </param> /// <param name="d5"> /// Data line 5. /// </param> /// <param name="d6"> /// Data line 6. /// </param> /// <param name="d7"> /// Data line 7. /// </param> /// <remarks> /// The display can be controlled using 4 or 8 data lines. If the former, /// omit the pin numbers for d0 to d3 and leave those lines disconnected. /// The RW pin can be tied to ground instead of connected to a pin on the /// Arduino; If so, omit it from this constructor's parameters. /// </remarks> /// <exception cref="ArgumentException"> /// <paramref name="rs"/> and <paramref name="enable"/> cannot be set to /// <see cref="GpioPins.GPIO_NONE"/>. /// </exception> public GpioMemLcdTransferProvider(GpioPins rs, GpioPins enable, GpioPins d0, GpioPins d1, GpioPins d2, GpioPins d3, GpioPins d4, GpioPins d5, GpioPins d6, GpioPins d7) : this(rs, GpioPins.GPIO_NONE, enable, d0, d1, d2, d3, d4, d5, d6, d7) { }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.LCD.GpioMemLcdTransferProvider"/> /// class with the mode flag, register select pin, read/write pin, /// enable pin, and data pins. /// </summary> /// <param name="rs"> /// The number of the CPU pin that is connected to the RS (Register Select) /// pin on the LCD. /// </param> /// <param name="rw"> /// The number of the CPU pin that is connected to the RW (Read/Write) /// pin on the LCD. /// </param> /// <param name="enable"> /// The number of the CPU pin that is connected to the enable pin /// on the LCD. /// </param> /// <param name="d4"> /// Data line 4. /// </param> /// <param name="d5"> /// Data line 5. /// </param> /// <param name="d6"> /// Data line 6. /// </param> /// <param name="d7"> /// Data line 7. /// </param> /// <remarks> /// The display can be controlled using 4 or 8 data lines. If the former, /// omit the pin numbers for d0 to d3 and leave those lines disconnected. /// The RW pin can be tied to ground instead of connected to a pin on the /// Arduino; If so, omit it from this constructor's parameters. /// </remarks> /// <exception cref="ArgumentException"> /// <paramref name="rs"/> and <paramref name="enable"/> cannot be set to /// <see cref="GpioPins.GPIO_NONE"/>. /// </exception> public GpioMemLcdTransferProvider(GpioPins rs, GpioPins rw, GpioPins enable, GpioPins d4, GpioPins d5, GpioPins d6, GpioPins d7) : this(true, rs, rw, enable, GpioPins.GPIO_NONE, GpioPins.GPIO_NONE, GpioPins.GPIO_NONE, GpioPins.GPIO_NONE, d4, d5, d6, d7) { }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/> /// class with a board Revision 1.0 pin and the pin direction. /// </summary> /// <param name="pin"> /// The GPIO pin. /// </param> /// <param name="direction"> /// The I/O pin direction. /// </param> public GpioBase(GpioPins pin, PinDirection direction) : this(pin, direction, false) { }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioFile"/> /// class with the Rev1 pin to access. /// </summary> /// <param name="pin"> /// The pin on the board to access. /// </param> public GpioFile(GpioPins pin) : base(pin, PinMode.OUT, PinState.Low) { }
/// <summary> /// Writes the specified value to the specified GPIO pin. /// </summary> /// <param name="pin"> /// The pin to write the value to. /// </param> /// <param name="value"> /// The value to write to the pin. /// </param> public static void Write(GpioPins pin, PinState value) { String num = GetGpioPinNumber(pin); String name = Enum.GetName(typeof(GpioPins), pin); internal_Write((Int32)pin, value, num, name); }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/> /// class with a board Revision 1.0 GPIO pin, the pin mode, and /// the initial pin value. /// </summary> /// <param name="pin"> /// The GPIO pin. /// </param> /// <param name="mode"> /// The I/O pin mode. /// </param> /// <param name="value"> /// The initial pin value. /// </param> protected GpioBase(GpioPins pin, PinMode mode, PinState value) { this._pin = pin; this._mode = mode; this._initValue = value; this._revision = BoardRevision.Rev2; }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioMem"/> /// class with the pin to initialize, the I/O direction, and the initial /// value to write to the pin. /// </summary> /// <param name="pin"> /// The pin on the board to access. /// </param> /// <param name="mode"> /// The I/0 mode of the pin. /// </param> /// <param name="initialValue"> /// The pin's initial value. /// </param> /// <remarks> /// Access to the specified GPIO setup with the specified direction /// with the specified initial value. /// </remarks> public GpioMem(GpioPins pin, PinMode mode, PinState initialValue) : base(pin, mode, initialValue) { base._initValue = initialValue; }
/// <summary> /// Unexport the GPIO. /// </summary> /// <param name="pin"> /// The pin to unexport. /// </param> private static void UnexportPin(GpioPins pin) { internal_UnexportPin((Int32)pin, GetGpioPinNumber(pin)); }
/// <summary> /// Exports the pin setting the direction. /// </summary> /// <param name="pin"> /// The pin on the board to export. /// </param> /// <param name="mode"> /// The I/0 mode of the pin. /// </param> private static void ExportPin(GpioPins pin, PinMode mode) { internal_ExportPin((Int32)pin, mode); }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/> /// class with a board Revision 1.0 pin and the pin direction. /// </summary> /// <param name="pin"> /// The GPIO pin. /// </param> /// <param name="mode"> /// The I/O pin mode. /// </param> protected GpioBase(GpioPins pin, PinMode mode) : this(pin, mode, PinState.Low) { }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.LCD.GpioMemLcdTransferProvider"/> /// class with the mode flag, register select pin, read/write pin, /// enable pin, and data pins. /// </summary> /// <param name="fourBitMode"> /// If set to true, switch to four bit mode instead of 8 bit mode. /// </param> /// <param name="rs"> /// The number of the CPU pin that is connected to the RS (Register Select) /// pin on the LCD. /// </param> /// <param name="rw"> /// The number of the CPU pin that is connected to the RW (Read/Write) /// pin on the LCD. /// </param> /// <param name="enable"> /// The number of the CPU pin that is connected to the enable pin /// on the LCD. /// </param> /// <param name="d0"> /// Data line 0. /// </param> /// <param name="d1"> /// Data line 1. /// </param> /// <param name="d2"> /// Data line 2. /// </param> /// <param name="d3"> /// Data line 3. /// </param> /// <param name="d4"> /// Data line 4. /// </param> /// <param name="d5"> /// Data line 5. /// </param> /// <param name="d6"> /// Data line 6. /// </param> /// <param name="d7"> /// Data line 7. /// </param> /// <remarks> /// The display can be controlled using 4 or 8 data lines. If the former, /// omit the pin numbers for d0 to d3 and leave those lines disconnected. /// The RW pin can be tied to ground instead of connected to a pin on the /// Arduino; If so, omit it from this constructor's parameters. /// </remarks> /// <exception cref="ArgumentException"> /// <paramref name="rs"/> and <paramref name="enable"/> cannot be set to /// <see cref="GpioPins.GPIO_NONE"/>. /// </exception> public GpioMemLcdTransferProvider(Boolean fourBitMode, GpioPins rs, GpioPins rw, GpioPins enable, GpioPins d0, GpioPins d1, GpioPins d2, GpioPins d3, GpioPins d4, GpioPins d5, GpioPins d6, GpioPins d7) { this._fourBitMode = fourBitMode; if (rs == GpioPins.GPIO_NONE) { throw new ArgumentException("rs"); } this._registerSelectPort = new GpioMem(rs, PinMode.OUT); this._registerSelectPort.Provision(); // We can save a pin by not using RW. Indicate by passing GpioPins.GPIO_NONE // instead of pin # (RW is optional). if (rw != GpioPins.GPIO_NONE) { this._readWritePort = new GpioMem(rw, PinMode.OUT); this._readWritePort.Provision(); } if (enable == GpioPins.GPIO_NONE) { throw new ArgumentException("enable"); } this._enablePort = new GpioMem(enable, PinMode.OUT); this._enablePort.Provision(); GpioPins[] dataPins = { d0, d1, d2, d3, d4, d5, d6, d7 }; this._dataPorts = new GpioMem[8]; for (Int32 i = 0; i < 8; i++) { if (dataPins[i] == GpioPins.GPIO_NONE) { this._dataPorts[i] = new GpioMem(dataPins[i], PinMode.OUT); this._dataPorts[i].Provision(); } } }
/// <summary> /// Exports the GPIO setting the direction. This creates the /// /sys/class/gpio/gpioXX directory. /// </summary> /// <param name="pin"> /// The GPIO pin on the board. /// </param> /// <param name="mode"> /// The I/O mode. /// </param> private static void ExportPin(GpioPins pin, PinMode mode) { String name = Enum.GetName(typeof(GpioPins), pin); internal_ExportPin((Int32)pin, mode, GetGpioPinNumber(pin), name); }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.LCD.GpioFileLcdTransferProvider"/> /// class with the mode, register select pin, read/write pin, enable /// pin, and data lines. /// </summary> /// <param name="fourBitMode"> /// If set to true, then use 4 bit mode instead of 8 bit. /// </param> /// <param name="rs"> /// The number of the CPU pin that is connected to the RS (Register Select) /// pin on the LCD. /// </param> /// <param name="rw"> /// The number of the CPU pin that is connected to the RW (Read/Write) /// pin on the LCD. /// </param> /// <param name="enable"> /// The number of the CPU pin that is connected to the enable pin on /// the LCD. /// </param> /// <param name="d0"> /// Data line 0. /// </param> /// <param name="d1"> /// Data line 1. /// </param> /// <param name="d2"> /// Data line 2. /// </param> /// <param name="d3"> /// Data line 3. /// </param> /// <param name="d4"> /// Data line 4. /// </param> /// <param name="d5"> /// Data line 5. /// </param> /// <param name="d6"> /// Data line 6. /// </param> /// <param name="d7"> /// Data line 7. /// </param> /// <remarks> /// The display can be controlled using 4 or 8 data lines. If the former, /// omit the pin numbers for d0 to d3 and leave those lines disconnected. /// The RW pin can be tied to ground instead of connected to a pin on the /// Arduino; If so, omit it from this constructor's parameters. /// </remarks> /// <exception cref="ArgumentException"> /// <paramref name="rs"/> and <paramref name="enable"/> cannot be set to /// <see cref="GpioPins.GPIO_NONE"/>. /// </exception> public GpioFileLcdTransferProvider(Boolean fourBitMode, GpioPins rs, GpioPins rw, GpioPins enable, GpioPins d0, GpioPins d1, GpioPins d2, GpioPins d3, GpioPins d4, GpioPins d5, GpioPins d6, GpioPins d7) { this._fourBitMode = fourBitMode; if (rs == GpioPins.GPIO_NONE) { throw new ArgumentException("rs"); } this._registerSelectPort = new GpioFile(rs); // We can save 1 pin by not using RW. Indicate this by passing GpioPins.GPIO_NONE // instead of pin #. if (rw != GpioPins.GPIO_NONE) { this._readWritePort = new GpioFile(rw); } if (enable == GpioPins.GPIO_NONE) { throw new ArgumentException("enable"); } this._enablePort = new GpioFile(enable); GpioPins[] dataPins = { d0, d1, d2, d3, d4, d5, d6, d7 }; this._dataPorts = new GpioFile[8]; for (Int32 i = 0; i < 8; i++) { if (dataPins[i] != GpioPins.GPIO_NONE) { this._dataPorts[i] = new GpioFile(dataPins[i]); } } }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioFile"/> /// class with the Rev1 pin to access, the I/O direction, and the initial value. /// </summary> /// <param name="pin"> /// The pin on the board to access. /// </param> /// <param name="mode"> /// The I/0 mode of the pin. /// </param> /// <param name="initialValue"> /// The pin's initial value. /// </param> public GpioFile(GpioPins pin, PinMode mode, PinState initialValue) : base(pin, mode, initialValue) { }
/// <summary> /// Exports the GPIO setting the direction. This creates the /// /sys/class/gpio/gpioXX directory. /// </summary> /// <param name="pin"> /// The GPIO pin on the board. /// </param> /// <param name="direction"> /// The I/O direction. /// </param> private static void ExportPin(GpioPins pin, PinDirection direction) { String name = Enum.GetName(typeof(GpioPins), pin); internal_ExportPin((Int32)pin, direction, GetGpioPinNumber(pin), name); }
/// <summary> /// Gets the GPIO pin number. /// </summary> /// <param name="pin"> /// The GPIO pin. /// </param> /// <returns> /// The GPIO pin number. /// </returns> protected static String GetGpioPinNumber(GpioPins pin) { return ((Int32)pin).ToString(); }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioFile"/> /// class with the Rev1 pin to access and the I/O direction. /// </summary> /// <param name="pin"> /// The pin on the board to access. /// </param> /// <param name="direction"> /// The I/0 direction of the pin. /// </param> public GpioFile(GpioPins pin, PinDirection direction) : base(pin, direction, false) { ExportPin(pin, direction); }
/// <summary> /// Exports the pin setting the direction. /// </summary> /// <param name="pin"> /// The pin on the board to export. /// </param> /// <param name="direction"> /// The I/0 direction of the pin. /// </param> private static void ExportPin(GpioPins pin, PinDirection direction) { internal_ExportPin((Int32)pin, direction); }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.LCD.GpioFileLcdTransferProvider"/> /// class with the register select pin, enable pin, and data lines. /// </summary> /// <param name="rs"> /// The number of the CPU pin that is connected to the RS (Register Select) /// pin on the LCD. /// </param> /// <param name="enable"> /// The number of the CPU pin that is connected to the enable pin on /// the LCD. /// </param> /// <param name="d0"> /// Data line 0. /// </param> /// <param name="d1"> /// Data line 1. /// </param> /// <param name="d2"> /// Data line 2. /// </param> /// <param name="d3"> /// Data line 3. /// </param> /// <param name="d4"> /// Data line 4. /// </param> /// <param name="d5"> /// Data line 5. /// </param> /// <param name="d6"> /// Data line 6. /// </param> /// <param name="d7"> /// Data line 7. /// </param> /// <remarks> /// The display can be controlled using 4 or 8 data lines. If the former, /// omit the pin numbers for d0 to d3 and leave those lines disconnected. /// The RW pin can be tied to ground instead of connected to a pin on the /// Arduino; If so, omit it from this constructor's parameters. /// </remarks> /// <exception cref="ArgumentException"> /// <paramref name="rs"/> and <paramref name="enable"/> cannot be set to /// <see cref="GpioPins.GPIO_NONE"/>. /// </exception> public GpioFileLcdTransferProvider(GpioPins rs, GpioPins enable, GpioPins d0, GpioPins d1, GpioPins d2, GpioPins d3, GpioPins d4, GpioPins d5, GpioPins d6, GpioPins d7) : this(true, rs, GpioPins.GPIO_NONE, enable, d0, d1, d2, d3, d4, d5, d6, d7) { }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/> /// class with a board Revision 1.0 pin. /// </summary> /// <param name="pin"> /// The GPIO pin. /// </param> protected GpioBase(GpioPins pin) : this(pin, PinMode.OUT, PinState.Low) { }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.LCD.GpioFileLcdTransferProvider"/> /// class with the mode, register select pin, read/write pin, enable /// pin, and data lines. /// </summary> /// <param name="rs"> /// The number of the CPU pin that is connected to the RS (Register Select) /// pin on the LCD. /// </param> /// <param name="rw"> /// The number of the CPU pin that is connected to the RW (Read/Write) /// pin on the LCD. /// </param> /// <param name="enable"> /// The number of the CPU pin that is connected to the enable pin on /// the LCD. /// </param> /// <param name="d4"> /// Data line 4. /// </param> /// <param name="d5"> /// Data line 5. /// </param> /// <param name="d6"> /// Data line 6. /// </param> /// <param name="d7"> /// Data line 7. /// </param> /// <remarks> /// The display can be controlled using 4 or 8 data lines. If the former, /// omit the pin numbers for d0 to d3 and leave those lines disconnected. /// The RW pin can be tied to ground instead of connected to a pin on the /// Arduino; If so, omit it from this constructor's parameters. /// </remarks> /// <exception cref="ArgumentException"> /// <paramref name="rs"/> and <paramref name="enable"/> cannot be set to /// <see cref="GpioPins.GPIO_NONE"/>. /// </exception> public GpioFileLcdTransferProvider(GpioPins rs, GpioPins rw, GpioPins enable, GpioPins d4, GpioPins d5, GpioPins d6, GpioPins d7) : this(false, rs, rw, enable, GpioPins.GPIO_NONE, GpioPins.GPIO_NONE, GpioPins.GPIO_NONE, GpioPins.GPIO_NONE, d4, d5, d6, d7) { }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioFile"/> /// class with the Rev1 pin to access, the I/O direction, and the initial value. /// </summary> /// <param name="pin"> /// The pin on the board to access. /// </param> /// <param name="direction"> /// The I/0 direction of the pin. /// </param> /// <param name="initialValue"> /// The pin's initial value. /// </param> public GpioFile(GpioPins pin, PinDirection direction, Boolean initialValue) : base(pin, direction, initialValue) { ExportPin(pin, direction); Write(pin, initialValue); }
/// <summary> /// Unexport the GPIO. This removes the /sys/class/gpio/gpioXX directory. /// </summary> /// <param name="pin"> /// The GPIO pin to unexport. /// </param> private static void UnexportPin(GpioPins pin) { Write(pin, PinState.Low); internal_UnexportPin((Int32)pin, GetGpioPinNumber(pin)); }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioFile"/> /// class with the Rev1 pin to access. /// </summary> /// <param name="pin"> /// The pin on the board to access. /// </param> public GpioFile(GpioPins pin) : base(pin, PinDirection.OUT, false) { }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.LCD.GpioFileLcdTransferProvider"/> /// class with the mode, register select pin, read/write pin, enable /// pin, and data lines. /// </summary> /// <param name="rs"> /// The number of the CPU pin that is connected to the RS (Register Select) /// pin on the LCD. /// </param> /// <param name="enable"> /// The number of the CPU pin that is connected to the enable pin on /// the LCD. /// </param> /// <param name="d4"> /// Data line 4. /// </param> /// <param name="d5"> /// Data line 5. /// </param> /// <param name="d6"> /// Data line 6. /// </param> /// <param name="d7"> /// Data line 7. /// </param> /// <remarks> /// The display can be controlled using 4 or 8 data lines. If the former, /// omit the pin numbers for d0 to d3 and leave those lines disconnected. /// The RW pin can be tied to ground instead of connected to a pin on the /// Arduino; If so, omit it from this constructor's parameters. /// </remarks> /// <exception cref="ArgumentException"> /// <paramref name="rs"/> and <paramref name="enable"/> cannot be set to /// <see cref="GpioPins.GPIO_NONE"/>. /// </exception> public GpioFileLcdTransferProvider(GpioPins rs, GpioPins enable, GpioPins d4, GpioPins d5, GpioPins d6, GpioPins d7) : this(false, rs, GpioPins.GPIO_NONE, enable, GpioPins.GPIO_NONE, GpioPins.GPIO_NONE, GpioPins.GPIO_NONE, GpioPins.GPIO_NONE, d4, d5, d6, d7) { }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioMem"/> /// class with the pin to initialize. /// </summary> /// <param name="pin"> /// The pin on the board to access. /// </param> /// <remarks> /// Access to the specified GPIO setup as an output port with an initial /// value of false (0). /// </remarks> public GpioMem(GpioPins pin) : base(pin, PinMode.OUT, PinState.Low) { }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.LCD.GpioMemLcdTransferProvider"/> /// class with the mode flag, register select pin, read/write pin, /// enable pin, and data pins. /// </summary> /// <param name="rs"> /// The number of the CPU pin that is connected to the RS (Register Select) /// pin on the LCD. /// </param> /// <param name="rw"> /// The number of the CPU pin that is connected to the RW (Read/Write) /// pin on the LCD. /// </param> /// <param name="enable"> /// The number of the CPU pin that is connected to the enable pin /// on the LCD. /// </param> /// <param name="d0"> /// Data line 0. /// </param> /// <param name="d1"> /// Data line 1. /// </param> /// <param name="d2"> /// Data line 2. /// </param> /// <param name="d3"> /// Data line 3. /// </param> /// <param name="d4"> /// Data line 4. /// </param> /// <param name="d5"> /// Data line 5. /// </param> /// <param name="d6"> /// Data line 6. /// </param> /// <param name="d7"> /// Data line 7. /// </param> /// <remarks> /// The display can be controlled using 4 or 8 data lines. If the former, /// omit the pin numbers for d0 to d3 and leave those lines disconnected. /// The RW pin can be tied to ground instead of connected to a pin on the /// Arduino; If so, omit it from this constructor's parameters. /// </remarks> /// <exception cref="ArgumentException"> /// <paramref name="rs"/> and <paramref name="enable"/> cannot be set to /// <see cref="GpioPins.GPIO_NONE"/>. /// </exception> public GpioMemLcdTransferProvider(GpioPins rs, GpioPins rw, GpioPins enable, GpioPins d0, GpioPins d1, GpioPins d2, GpioPins d3, GpioPins d4, GpioPins d5, GpioPins d6, GpioPins d7) : this(false, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7) { }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.LCD.GpioMemLcdTransferProvider"/> /// class with the mode flag, register select pin, read/write pin, /// enable pin, and data pins. /// </summary> /// <param name="rs"> /// The number of the CPU pin that is connected to the RS (Register Select) /// pin on the LCD. /// </param> /// <param name="enable"> /// The number of the CPU pin that is connected to the enable pin /// on the LCD. /// </param> /// <param name="d4"> /// Data line 4. /// </param> /// <param name="d5"> /// Data line 5. /// </param> /// <param name="d6"> /// Data line 6. /// </param> /// <param name="d7"> /// Data line 7. /// </param> /// <remarks> /// The display can be controlled using 4 or 8 data lines. If the former, /// omit the pin numbers for d0 to d3 and leave those lines disconnected. /// The RW pin can be tied to ground instead of connected to a pin on the /// Arduino; If so, omit it from this constructor's parameters. /// </remarks> /// <exception cref="ArgumentException"> /// <paramref name="rs"/> and <paramref name="enable"/> cannot be set to /// <see cref="GpioPins.GPIO_NONE"/>. /// </exception> public GpioMemLcdTransferProvider(GpioPins rs, GpioPins enable, GpioPins d4, GpioPins d5, GpioPins d6, GpioPins d7) : this(true, rs, GpioPins.GPIO_NONE, enable, GpioPins.GPIO_NONE, GpioPins.GPIO_NONE, GpioPins.GPIO_NONE, GpioPins.GPIO_NONE, d4, d5, d6, d7) { }
/// <summary> /// Gets the GPIO pin number. /// </summary> /// <param name="pin"> /// The GPIO pin. /// </param> /// <returns> /// The GPIO pin number. /// </returns> protected static String GetGpioPinNumber(GpioPins pin) { return(((Int32)pin).ToString()); }
/// <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(GpioPins pin, PinState value) { String name = Enum.GetName(typeof(GpioPins), pin); internal_Write((Int32)pin, value, name); }
/// <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(GpioPins pin) { String name = Enum.GetName(typeof(GpioPins), pin); return(internal_Read((Int32)pin, name)); }
/// <summary> /// Read a value from the specified pin. /// </summary> /// <param name="pin"> /// The pin to read from. /// </param> /// <returns> /// The value read from the pin (high or low). /// </returns> /// <exception cref="IOException"> /// The specified pin could not be read (device does path does not exist). /// </exception> public static PinState Read(GpioPins pin) { String num = GetGpioPinNumber(pin); String name = Enum.GetName(typeof(GpioPins), pin); return internal_Read((Int32)pin, num, name); }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioFile"/> /// class with the Rev1 pin to access and the I/O direction. /// </summary> /// <param name="pin"> /// The pin on the board to access. /// </param> /// <param name="mode"> /// The I/0 mode of the pin. /// </param> public GpioFile(GpioPins pin, PinMode mode) : base(pin, mode, PinState.Low) { }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioMem"/> /// class with the pin to initialize and the I/O direction. /// </summary> /// <param name="pin"> /// The pin on the board to access. /// </param> /// <param name="mode"> /// The I/0 mode of the pin. /// </param> /// <remarks> /// Access to the specified GPIO setup with the specified direction /// with an initial value of LOW (0). /// </remarks> public GpioMem(GpioPins pin, PinMode mode) : base(pin, mode, PinState.Low) { }
/// <summary> /// Releases all resource used by the <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/> /// object. /// </summary> /// <remarks> /// Call <see cref="Dispose"/> when you are finished using the /// <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/>.The <see cref="Dispose"/> /// method leaves the <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/> in an /// unusable state. After calling <see cref="Dispose"/>, you must release /// all references to the <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/> so /// the garbage collector can reclaim the memory that the /// <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/> was occupying. /// </remarks> public virtual void Dispose() { if (this._isDisposed) { return; } _exportedPins.Clear(); _exportedPins = null; this.StateChanged = null; this._pin = GpioPins.GPIO_NONE; this._isDisposed = true; }
public SparkFunRainGaugeDriver(GpioController gpioController, GpioPins gpioPin) { _gpioController = gpioController; _gpioPin = gpioPin; Init(); }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/> /// class with a board Revision 1.0 GPIO pin, the pin direction, and /// the initial pin value. /// </summary> /// <param name="pin"> /// The GPIO pin. /// </param> /// <param name="direction"> /// The I/O pin direction. /// </param> /// <param name="value"> /// The initial pin value. /// </param> public GpioBase(GpioPins pin, PinDirection direction, Boolean value) { this._pin = pin; this._direction = direction; this._revision = BoardRevision.Rev2; }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.GpioBase"/> /// class with a board Revision 1.0 pin. /// </summary> /// <param name="pin"> /// The GPIO pin. /// </param> public GpioBase(GpioPins pin) : this(pin, PinDirection.OUT, false) { }
/// <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(GpioPins pin, Boolean value) { String name = Enum.GetName(typeof(GpioPins), pin); internal_Write((Int32)pin, value, name); }