Abstract base class for the GPIO connector on the Pi (P1) (as found next to the yellow RCA video socket on the Rpi circuit board).
Inheritance: IRaspiGpio
コード例 #1
0
ファイル: MCP3008.cs プロジェクト: kashmervil/MonoPi
 /// <summary>
 /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.SPI.MCP3008"/>
 /// class the analog-to-digital channel, clock pin, SPI Master Output/
 /// Slave Input (MOSI), SPI Master Input/Slave Output (MISO), and SPI
 /// chip select pin.
 /// </summary>
 /// <param name="channel">
 /// MCP3008 channel number 0 - 7 (pin 1 -8 on chip).
 /// </param>
 /// <param name="spiclk">
 /// SPI clock pin.
 /// </param>
 /// <param name="mosi">
 /// Master Output, Slave Input (MOSI).
 /// </param>
 /// <param name="miso">
 /// Master Input, Slave Output (MISO).
 /// </param>
 /// <param name="cs">
 /// Chip Select pin.
 /// </param>
 public MCP3008(AdcChannels channel, GpioBase spiclk, GpioBase mosi, GpioBase miso, GpioBase cs)
 {
     this._channel = channel;
     this._clock = spiclk;
     this._masterOutSlaveIn = mosi;
     this._masterInSlaveOut = miso;
     this._chipSelect = cs;
 }
コード例 #2
0
ファイル: MotionSensorBase.cs プロジェクト: kashmervil/MonoPi
 /// <summary>
 /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Components.Sensors.MotionSensorBase"/>
 /// class.
 /// </summary>
 /// <param name="pin">
 /// The pin being used to read the sensor input.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="pin"/> cannot be null.
 /// </exception>
 protected MotionSensorBase(GpioBase pin)
 {
     if (pin == null) {
         throw new ArgumentNullException("pin");
     }
     this._pin = pin;
     this._props = new Dictionary<String, String>();
 }
コード例 #3
0
ファイル: LightComponent.cs プロジェクト: kashmervil/MonoPi
 /// <summary>
 /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Components.Lights.LightComponent"/>
 /// class with the pin controlling the light.
 /// </summary>
 /// <param name="pin">
 /// The output pin the light is wired to.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// The pin cannot be null.
 /// </exception>
 public LightComponent(GpioBase pin)
     : base()
 {
     if (pin == null) {
         throw new ArgumentNullException("pin");
     }
     this._pin = pin;
 }
コード例 #4
0
ファイル: SwitchComponent.cs プロジェクト: kashmervil/MonoPi
 /// <summary>
 /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Components.Switches.SwitchComponent"/>
 /// class with the pin the switch is wired to.
 /// </summary>
 /// <param name="pin">
 /// The input pin to check switch state on.
 /// </param>
 public SwitchComponent(GpioBase pin)
     : base()
 {
     if (pin == null) {
         throw new ArgumentNullException("pin");
     }
     this._pin = pin;
     this._pin.StateChanged += this.OnStateChanged;
 }
コード例 #5
0
ファイル: DS1302.cs プロジェクト: kashmervil/MonoPi
 /// <summary>
 /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.RTC.DS1302"/>
 /// class with the clock, data, and chip-select pins.
 /// </summary>
 /// <param name="clockPin">
 /// The GPIO pin to use for the clock.
 /// </param>
 /// <param name="dataPin">
 /// The GPIO pin to use for data.
 /// </param>
 /// <param name="csPin">
 /// The GPIO pin to use for chip-select.
 /// </param>
 public DS1302(GpioBase clockPin, GpioBase dataPin, GpioBase csPin)
 {
     this._clockPin = clockPin;
     this._dataPin = dataPin;
     this._csPin = csPin;
     UnsafeNativeMethods.ds1302setup((Int32)this._clockPin.InnerPin,
                                     (Int32)this._dataPin.InnerPin,
                                     (Int32)this._csPin.InnerPin);
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Components.Lights.DimmableLightComponent"/>
 /// class with the pin controlling the light and the minimum and
 /// maximum light level.
 /// </summary>
 /// <param name="pin">
 /// The pin used to control the dimmable light.
 /// </param>
 /// <param name="min">
 /// The minimum brightness level.
 /// </param>
 /// <param name="max">
 /// The maximum brightness level.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// The pin cannot be null.
 /// </exception>
 public DimmableLightComponent(GpioBase pin, Int32 min, Int32 max)
     : base()
 {
     if (pin == null) {
         throw new ArgumentNullException("pin");
     }
     this._pin = pin;
     this._min = min;
     this._max = max;
 }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Components.Temperature.TemperatureSensorBase"/>
        /// class with the clock, data, and reset pins needed for the sensor.
        /// </summary>
        /// <param name="clock">
        /// The GPIO pin used for the clock.
        /// </param>
        /// <param name="data">
        /// The GPIO pin used for data.
        /// </param>
        /// <param name="reset">
        /// The GPIO pin used to trigger reset.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Pins cannot be null.
        /// </exception>
        protected TemperatureSensorBase(GpioBase clock, GpioBase data, GpioBase reset)
            : base()
        {
            if (clock == null) {
                throw new ArgumentNullException("clock");
            }

            if (data == null) {
                throw new ArgumentNullException("data");
            }

            if (reset == null) {
                throw new ArgumentNullException("reset");
            }

            this._tempSensor = new DS1620(clock, data, reset);
        }
コード例 #8
0
ファイル: MCP3008.cs プロジェクト: kashmervil/MonoPi
        /// <summary>
        /// Releases all resource used by the <see cref="CyrusBuilt.MonoPi.SPI.MCP3008"/> object.
        /// </summary>
        /// <remarks>
        /// Call <see cref="Dispose"/> when you are finished using the <see cref="CyrusBuilt.MonoPi.SPI.MCP3008"/>. The
        /// <see cref="Dispose"/> method leaves the <see cref="CyrusBuilt.MonoPi.SPI.MCP3008"/> in an unusable state. After
        /// calling <see cref="Dispose"/>, you must release all references to the <see cref="CyrusBuilt.MonoPi.SPI.MCP3008"/>
        /// so the garbage collector can reclaim the memory that the <see cref="CyrusBuilt.MonoPi.SPI.MCP3008"/> was occupying.
        /// </remarks>
        public void Dispose()
        {
            this._channel = AdcChannels.None;
            if (this._chipSelect != null) {
                this._chipSelect.Dispose();
                this._chipSelect = null;
            }

            if (this._clock != null) {
                this._clock.Dispose();
                this._clock = null;
            }

            if (this._masterInSlaveOut != null) {
                this._masterInSlaveOut.Dispose();
                this._masterInSlaveOut = null;
            }

            if (this._masterOutSlaveIn != null) {
                this._masterOutSlaveIn.Dispose();
                this._masterOutSlaveIn = null;
            }
        }
コード例 #9
0
        /// <summary>
        /// Releases all resource used by the <see cref="CyrusBuilt.MonoPi.Components.Lights.DimmableLightComponent"/>
        /// object.
        /// </summary>
        /// <remarks>
        /// Call <see cref="Dispose"/> when you are finished using the
        /// <see cref="CyrusBuilt.MonoPi.Components.Lights.DimmableLightComponent"/>. The
        /// <see cref="Dispose"/> method leaves the
        /// <see cref="CyrusBuilt.MonoPi.Components.Lights.DimmableLightComponent"/> in an
        /// unusable state. After calling <see cref="Dispose"/>, you must release all
        /// references to the <see cref="CyrusBuilt.MonoPi.Components.Lights.DimmableLightComponent"/>
        /// so the garbage collector can reclaim the memory that the
        /// <see cref="CyrusBuilt.MonoPi.Components.Lights.DimmableLightComponent"/> was occupying.
        /// </remarks>
        public override void Dispose()
        {
            if (base.IsDisposed) {
                return;
            }

            if (this._pin != null) {
                this._pin.Dispose();
                this._pin = null;
            }
            base.Dispose();
        }
コード例 #10
0
ファイル: DS1620.cs プロジェクト: kashmervil/MonoPi
        /// <summary>
        /// Releases all resource used by the <see cref="CyrusBuilt.MonoPi.Sensors.DS1620"/> object.
        /// </summary>
        /// <remarks>
        /// Call <see cref="Dispose"/> when you are finished using the <see cref="CyrusBuilt.MonoPi.Sensors.DS1620"/>. The
        /// <see cref="Dispose"/> method leaves the <see cref="CyrusBuilt.MonoPi.Sensors.DS1620"/> in an unusable state. After calling
        /// <see cref="Dispose"/>, you must release all references to the <see cref="CyrusBuilt.MonoPi.Sensors.DS1620"/> so the
        /// garbage collector can reclaim the memory that the <see cref="CyrusBuilt.MonoPi.Sensors.DS1620"/> was occupying.
        /// </remarks>
        public void Dispose()
        {
            if (this._clock != null) {
                this._clock.Dispose();
                this._clock = null;
            }

            if (this._data != null) {
                this._data.Dispose();
                this._data = null;
            }

            if (this._reset != null) {
                this._reset.Dispose();
                this._reset = null;
            }
        }
コード例 #11
0
ファイル: SwitchComponent.cs プロジェクト: kashmervil/MonoPi
 /// <summary>
 /// Releases all resource used by the <see cref="CyrusBuilt.MonoPi.Components.Switches.SwitchComponent"/>
 /// object.
 /// </summary>
 /// <remarks>
 /// Call <see cref="Dispose"/> when you are finished using the
 /// <see cref="CyrusBuilt.MonoPi.Components.Switches.SwitchComponent"/>. The
 /// <see cref="Dispose"/> method leaves the
 /// <see cref="CyrusBuilt.MonoPi.Components.Switches.SwitchComponent"/> in an
 /// unusable state. After calling
 /// <see cref="Dispose"/>, you must release all references to the
 /// <see cref="CyrusBuilt.MonoPi.Components.Switches.SwitchComponent"/> so the
 /// garbage collector can reclaim the
 /// memory that the <see cref="CyrusBuilt.MonoPi.Components.Switches.SwitchComponent"/>
 /// was occupying.
 /// </remarks>
 public override void Dispose()
 {
     if (this._pin != null) {
         this._pin.Dispose();
         this._pin = null;
     }
     base.Dispose();
 }
コード例 #12
0
ファイル: DS1620.cs プロジェクト: kashmervil/MonoPi
 /// <summary>
 /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Sensors.DS1620"/>
 /// class with the clock, data, and reset GPIO pins.
 /// </summary>
 /// <param name="clock">
 /// The clock pin.
 /// </param>
 /// <param name="data">
 /// The data pin.
 /// </param>
 /// <param name="reset">
 /// The reset pin.
 /// </param>
 public DS1620(GpioBase clock, GpioBase data, GpioBase reset)
 {
     this._clock = clock;
     this._data = data;
     this._reset = reset;
 }
コード例 #13
0
ファイル: MotionSensorBase.cs プロジェクト: kashmervil/MonoPi
        /// <summary>
        /// Releaseses all resources used this object.
        /// </summary>
        /// <param name="disposing">
        /// Set true if disposing managed resources in addition to unmanaged.
        /// </param>
        protected virtual void Dispose(Boolean disposing)
        {
            if (this._isDisposed) {
                return;
            }

            if (disposing) {
                this._name = null;
                this._tag = null;
                if (this._pin != null) {
                    this._pin.Dispose();
                    this._pin = null;
                }

                if (this._props != null) {
                    this._props.Clear();
                    this._props = null;
                }
            }

            this.MotionDetectionStateChanged = null;
            this._isDisposed = true;
        }
コード例 #14
0
ファイル: TM1638.cs プロジェクト: kashmervil/MonoPi
 /// <summary>
 /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.LED.TM1638"/>
 /// class with the data pin, clock pin, strobe pin, a flag to set the
 /// display active, and the display intensity (brightness).
 /// </summary>
 /// <param name="data">
 /// The data pin.
 /// </param>
 /// <param name="clock">
 /// The clock pin.
 /// </param>
 /// <param name="strobe">
 /// The strobe pin.
 /// </param>
 /// <param name="active">
 /// Set true to activate the display.
 /// </param>
 /// <param name="intensity">
 /// The display intensity (brightness).
 /// </param>
 public TM1638(GpioBase data, GpioBase clock, GpioBase strobe, Boolean active, Byte intensity)
     : base(data, clock, strobe, 8, active, intensity)
 {
 }
コード例 #15
0
ファイル: TM16XXBase.cs プロジェクト: kashmervil/MonoPi
        /// <summary>
        /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.LED.TM16XXBase"/>
        /// class with the data pin, clock pin, strobe pin, the number of
        /// supported characters, activation flag, and intensity level.
        /// </summary>
        /// <param name="data">
        /// The data pin.
        /// </param>
        /// <param name="clock">
        /// The clock pin.
        /// </param>
        /// <param name="strobe">
        /// The strobe pin.
        /// </param>
        /// <param name="displays">
        /// The number of characters to display.
        /// </param>
        /// <param name="activate">
        /// Set true to activate the display.
        /// </param>
        /// <param name="intensity">
        /// The display intensity (brightness) level.
        /// </param>
        public TM16XXBase(GpioBase data, GpioBase clock, GpioBase strobe, Int32 displays, Boolean activate, Int32 intensity)
        {
            this._data = data;
            this._clock = clock;
            this._strobe = strobe;

            // TODO What is the acceptable range?
            this._displays = displays;

            this._strobe.Write(true);
            this._clock.Write(true);

            // TODO What is the acceptable range of "intensity"?
            this.SendCommand(0x40);
            this.SendCommand((Byte)(0x80 | (activate ? 0x08 : 0x00) | Math.Min(7, intensity)));

            this._strobe.Write(false);
            this.Send(0xC0);
            for (Int32 i = 0; i < 16; i++) {
                this.Send(0x00);
            }

            this._strobe.Write(true);
        }
コード例 #16
0
ファイル: TM16XXBase.cs プロジェクト: kashmervil/MonoPi
        /// <summary>
        /// Releases all resource used by the <see cref="CyrusBuilt.MonoPi.LED.TM16XXBase"/> object.
        /// </summary>
        /// <remarks>
        /// Call <see cref="Dispose"/> when you are finished using the <see cref="CyrusBuilt.MonoPi.LED.TM16XXBase"/>. The
        /// <see cref="Dispose"/> method leaves the <see cref="CyrusBuilt.MonoPi.LED.TM16XXBase"/> in an unusable state. After
        /// calling <see cref="Dispose"/>, you must release all references to the
        /// <see cref="CyrusBuilt.MonoPi.LED.TM16XXBase"/> so the garbage collector can reclaim the memory that the
        /// <see cref="CyrusBuilt.MonoPi.LED.TM16XXBase"/> was occupying.
        /// </remarks>
        public void Dispose()
        {
            this.ActivateDisplay(false);
            if (this._clock != null) {
                this._clock.Dispose();
                this._clock = null;
            }

            if (this._data != null) {
                this._data.Dispose();
                this._data = null;
            }

            if (this._strobe != null) {
                this._strobe.Dispose();
                this._strobe = null;
            }
        }
コード例 #17
0
ファイル: DS1302.cs プロジェクト: kashmervil/MonoPi
        /// <summary>
        /// Releases all resource used by the <see cref="CyrusBuilt.MonoPi.RTC.DS1302"/>
        /// object.
        /// </summary>
        /// <remarks>Call <see cref="Dispose"/> when you are finished using the
        /// <see cref="CyrusBuilt.MonoPi.RTC.DS1302"/>. The <see cref="Dispose"/>
        /// method leaves the <see cref="CyrusBuilt.MonoPi.RTC.DS1302"/> in an
        /// unusable state. After calling <see cref="Dispose"/>, you must release
        /// all references to the <see cref="CyrusBuilt.MonoPi.RTC.DS1302"/>
        /// so the garbage collector can reclaim the memory that the
        /// <see cref="CyrusBuilt.MonoPi.RTC.DS1302"/> was occupying.
        /// </remarks>
        public void Dispose()
        {
            if (this._isDisposed) {
                return;
            }

            if (this._clockPin != null) {
                this._clockPin.Write(false);
                this._clockPin.Dispose();
                this._clockPin = null;
            }

            if (this._dataPin != null) {
                this._dataPin.Write(false);
                this._dataPin.Dispose();
                this._dataPin = null;
            }

            if (this._csPin != null) {
                this._csPin.Write(false);
                this._csPin.Dispose();
                this._csPin = null;
            }
            this._isDisposed = true;
        }