/// <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> /// Gets an open I2C connection instance. /// </summary> /// <param name="boardRev"> /// Specifies the revision of the RPi board in use. This /// used to determine the path to the system file associated /// with the i2c bus. /// </param> /// <returns> /// An open I2C connection instance. /// </returns> /// <exception cref="ObjectDisposedException"> /// This instance has been disposed. /// </exception> /// <exception cref="IOException"> /// Unable to open the bus connection. /// </exception> public static I2CBus Open(BoardRevision boardRev) { I2CBus bus = new I2CBus(boardRev); bus.Open(); return(bus); }
static SystemInfo() { HardwareRevision = Utilities.GpioHardwareRevision(); _libVersion = new Version(Convert.ToInt32(Utilities.GpioVersion()), 0); _boardRevision = Constants.GetBoardRevision(HardwareRevision); BoardType = Constants.GetBoardType(HardwareRevision); }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.I2C.I2CBus"/> /// class with the path the I2C bus. /// </summary> /// <param name="boardRev"> /// Specifies the revision of the RPi board in use. This /// used to determine the path to the system file associated /// with the i2c bus. /// </param> public I2CBus(BoardRevision boardRev) { if (boardRev == BoardRevision.Rev1) { this._busPath = "/dev/i2c-0"; } else { this._busPath = "/dev/i2c-1"; } }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.I2C.I2CBus"/> /// class with the path the I2C bus. /// </summary> /// <param name="boardRev"> /// Specifies the revision of the RPi board in use. This /// used to determine the path to the system file associated /// with the i2c bus. /// </param> public I2CBus(BoardRevision boardRev) { if (boardRev == BoardRevision.Rev1) { this._busPath = "/dev/i2c-0"; } else { this._busPath = "/dev/i2c-1"; } }
internal static BoardRevision GetBoardRevision() { lock (Lock) { if (_revGetted) { return(_boardRevision); } var val = WiringPi.PiBoardRev(); _boardRevision = val == 1 ? BoardRevision.Rev1 : BoardRevision.Rev2; _revGetted = true; } return(_boardRevision); }
// Encodes the label information to the required specifications of Lowes and returns the encoded string public string EncodeLowesManufacturingInformation() { int modelEncodingNumber = 0; ulong encodedLabelNumber = 0; // Check to see if this is a test label if (!this.Product.SKU.Equals(TestSku)) { modelEncodingNumber = (int)Product.ModelEncodingNumber; if (modelEncodingNumber == InvalidModelEncodingNumber) { return(string.Empty); } } // Takes the information of the label and encodes it into the required Lowes format encodedLabelNumber |= ((ulong)this.Tester); encodedLabelNumber |= ((ulong)this.Station << StationOffset); encodedLabelNumber |= ((ulong)this.Site << SiteOffset); // Get the last two digits of the year (2015 = 15) encodedLabelNumber |= ((ulong)(this.Date.Year % 100) << DateYearOffset); encodedLabelNumber |= ((ulong)this.Date.Day << DateDayOffset); // Month encoding starts at 0 (Jan) encodedLabelNumber |= ((ulong)(this.Date.Month - 1) << DateMonthOffset); // Board Revision is being passed in as a character, and therefore needs to be converted back to an int encodedLabelNumber |= ((ulong)(BoardRevision.CharToRevision((char)this.HardwareVersion)) << HWRevisionOffset); encodedLabelNumber |= ((ulong)modelEncodingNumber << ModelEncodingNumberOffset); byte[] encodedLabelNumberBytesArray = BitConverter.GetBytes(encodedLabelNumber); // Put the encodedLabelNumberBytesArray into a big endian format Array.Reverse(encodedLabelNumberBytesArray); // Array for final encoded information byte[] euiEncodedLabelNumber = new byte[encodedLabelNumberBytesArray.Length + EUI.Length]; // Concatenate the two arrays together EUI.CopyTo(euiEncodedLabelNumber, 0); encodedLabelNumberBytesArray.CopyTo(euiEncodedLabelNumber, EUI.Length); // Convert the Byte array into a string of hex digits return(BitConverter.ToString(euiEncodedLabelNumber).Replace("-", "")); }
/// <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> /// Changes the board revision. /// </summary> /// <param name="revision"> /// The board revision. Default is <see cref="BoardRevision.Rev2"/>. /// </param> public void ChangeBoardRevision(BoardRevision revision) { this._revision = revision; }
/// <summary> /// BCMs to physical pin number. /// </summary> /// <param name="rev">The rev.</param> /// <param name="bcmPin">The BCM pin.</param> /// <returns>The physical pin number.</returns> public static int BcmToPhysicalPinNumber(BoardRevision rev, BcmPin bcmPin) => rev == BoardRevision.Rev1 ? GpioToPhysR1[(int)bcmPin] : GpioToPhysR2[(int)bcmPin];
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.PCA.PCA9685GpioProvider"/> /// class with the Raspberry Pi board revision and address of the /// PCA9685 on the I2C bus. /// </summary> /// <param name="rev"> /// The Raspiberry Pi board revision being used. This is used to determine /// which bus to use for I2C. /// </param> /// <param name="address"> /// The address of the PCA9685 on the I2C bus. /// </param> /// <exception cref="IOException"> /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. /// </exception> public PCA9685GpioProvider(BoardRevision rev, Int32 address) : this(new I2CBus(rev), address) { }
/// <summary> /// Gets an open I2C connection instance. /// </summary> /// <param name="boardRev"> /// Specifies the revision of the RPi board in use. This /// used to determine the path to the system file associated /// with the i2c bus. /// </param> /// <returns> /// An open I2C connection instance. /// </returns> /// <exception cref="ObjectDisposedException"> /// This instance has been disposed. /// </exception> /// <exception cref="IOException"> /// Unable to open the bus connection. /// </exception> public static I2CBus Open(BoardRevision boardRev) { I2CBus bus = new I2CBus(boardRev); bus.Open(); return bus; }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.IO.PCA.PCA9685GpioProvider"/> /// class with the Raspberry Pi board revision and address of the /// PCA9685 on the I2C bus. /// </summary> /// <param name="rev"> /// The Raspiberry Pi board revision being used. This is used to determine /// which bus to use for I2C. /// </param> /// <param name="address"> /// The address of the PCA9685 on the I2C bus. /// </param> /// <exception cref="IOException"> /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. /// </exception> public PCA9685GpioProvider(BoardRevision rev, Int32 address) : this(new I2CBus(rev), address) { }
/// <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> /// Changes the board revision. /// </summary> /// <param name="revision"> /// The board revision. Default is <see cref="BoardRevision.Rev2"/>. /// </param> public void ChangeBoardRevision(BoardRevision revision) { this._revision = revision; }