Beispiel #1
0
        /// <summary>
        /// Creates an instance of the correct type depending on the Navio model.
        /// </summary>
        public NavioFramDevice(NavioHardwareModel model)
        {
            // Connect to I2C device
            var device = NavioHardwareProvider.ConnectI2c(I2cControllerIndex, I2cAddress, true, true);

            if (device == null)
            {
                // Initialization error
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
                                                                  Resources.Strings.I2cErrorDeviceNotFound, I2cAddress, I2cControllerIndex));
            }

            // Create model specific device
            switch (model)
            {
            case NavioHardwareModel.Navio:

                // Connect to upper I2C device
                var upperAddress = Mb85rc04vDevice.GetUpperI2cAddress(I2cAddress);
                var upperDevice  = NavioHardwareProvider.ConnectI2c(I2cControllerIndex, upperAddress, true, true);
                if (device == null)
                {
                    // Initialization error
                    throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
                                                                      Resources.Strings.I2cErrorDeviceNotFound, upperAddress, I2cControllerIndex));
                }

                // Create 512 byte device for Navio
                Hardware = new Mb85rc04vDevice(device, upperDevice);
                break;

            case NavioHardwareModel.NavioPlus:

                // Create 32KiB device for Navio+
                Hardware = new Mb85rc256vDevice(device);
                break;

            default:
                throw new NotImplementedException();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates an instance of the correct type depending on the Navio model.
        /// </summary>
        public Navio1FramDevice(NavioHardwareModel model)
        {
            // Create model specific device
            switch (model)
            {
            case NavioHardwareModel.Navio1:

                // Create 512 byte device for Navio
                _device = new Mb85rc04vDevice(I2cControllerIndex, ChipNumber);
                break;

            case NavioHardwareModel.Navio1Plus:

                // Create 32KiB device for Navio+
                _device = new Mb85rc256vDevice(I2cControllerIndex, ChipNumber);
                break;

            default:
                throw new NotImplementedException();
            }
        }