Example #1
0
 public I2CSensor(SensorPort port, byte address, I2CMode mode)
 {
     this.port       = port;
     this.I2CAddress = address;
     I2CDevice       = SensorManager.Instance.I2CDevice;
     this.mode       = mode;
     SensorManager.Instance.SetAnalogMode((AnalogMode)mode, port);
 }
Example #2
0
 public I2CSensor(SensorPort port, byte address, I2CMode mode)
 {
     this.port = port;
     this.I2CAddress = address;
     I2CDevice = SensorManager.Instance.I2CDevice;
     this.mode = mode;
     SensorManager.Instance.SetAnalogMode((AnalogMode)mode, port);
 }
Example #3
0
File: PMW.cs Project: Edll/iow
 /// <summary>
 /// Neue Instanz des PMW Moduls
 /// </summary>
 /// <param name="device">Device welches genutzt werden soll</param>
 /// <param name="i2cAdress">I2C Adresse auf dem Bus</param>
 public PMW(Device device, byte i2cAdress)
 {
     this._device   = device;
     this._i2cAddrs = i2cAdress;
     if (_device.Modes is I2CMode)
     {
         _i2cMode = _device.Modes as I2CMode;
     }
     else
     {
         _device.AddDeviceError("Device ist nicht im I2C Mode");
     }
 }
Example #4
0
        /// <summary>
        /// Neue Instanz des PMW Moduls
        /// </summary>
        /// <param name="device">Device welches genutzt werden soll</param>
        /// <param name="i2CAddrs">I2C Adresse auf dem Bus</param>
        /// <param name="axisNumber">Nummer der Achse am Arm. Ist 0 Basierend</param>
        public Axis(Device device, byte i2CAddrs, int axisNumber)
        {
            AxisNumber = axisNumber;
            _i2CAddrs  = i2CAddrs;

            I2CMode i2CMode = device.Modes as I2CMode;

            if (i2CMode != null)
            {
                _i2CMode = i2CMode;
            }
            else
            {
                device.AddDeviceError("Device ist nicht im I2C Mode");
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MonoBrick.NXT.I2CSensor"/> class.
 /// </summary>
 /// <param name='mode'>
 /// I2C mode
 /// </param>
 /// <param name='sensorAddress'>
 /// I2C address.
 /// </param>
 /// <param name='pollInterval'>
 /// Poll interval between checking for new values. This may need some tweaking depending on the sensor
 /// </param>
 public I2CBase(I2CMode mode, byte sensorAddress, int pollInterval) : base((SensorType)mode, SensorMode.Raw)
 {
     address  = sensorAddress;
     pollTime = pollInterval;
 }
        private const int I2CTimeOut = 500;//in MS

        /// <summary>
        /// Initializes a new instance of the <see cref="MonoBrick.NXT.I2CSensor"/> class.
        /// </summary>
        /// <param name='mode'>
        /// I2C mode
        /// </param>
        /// <param name='sensorAddress'>
        /// I2C address.
        /// </param>
        public I2CBase(I2CMode mode, byte sensorAddress) : base((SensorType)mode, SensorMode.Raw)
        {
            address  = sensorAddress;
            pollTime = 0;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MonoBrick.NXT.I2CSensor"/> class.
 /// </summary>
 /// <param name='mode'>
 /// 9v or normal mode
 /// </param>
 /// <param name='sensorAddress'>
 /// Sensor I2C address.
 /// </param>
 /// <param name='pollInterval'>
 /// Poll interval between checking for new values. This may need some tweaking depending on the sensor
 /// </param>
 public I2CSensor(I2CMode mode, byte sensorAddress, int pollInterval) : base(mode, sensorAddress, pollInterval)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MonoBrick.NXT.I2CSensor"/> class.
 /// </summary>
 /// <param name='mode'>
 /// 9v or normal mode
 /// </param>
 /// <param name='sensorAddress'>
 /// Sensor I2C address
 /// </param>
 public I2CSensor(I2CMode mode, byte sensorAddress) : base(mode, sensorAddress)
 {
 }
Example #9
0
        /* I2C read/write request
         * -------------------------------
         * 0  START_SYSEX (0xF0) (MIDI System Exclusive)
         * 1  I2C_REQUEST (0x76)
         * 2  slave address (LSB)
         * 3  slave address (MSB) + read/write and address mode bits
          {7: always 0} + {6: reserved} + {5: address mode, 1 means 10-bit mode} +
          {4-3: read/write, 00 => write, 01 => read once, 10 => read continuously, 11 => stop reading} +
          {2-0: slave address MSB in 10-bit mode, not used in 7-bit mode}
         * 4  data 0 (LSB)
         * 5  data 0 (MSB)
         * 6  data 1 (LSB)
         * 7  data 1 (MSB)
         * ...
         * n  END_SYSEX (0xF7)
         */
        public static byte[] I2CRequest(int slaveAddress, int[] data=null, I2CMode mode=I2CMode.READ)
        {
            int size = (data!=null ? data.Length : 0 ) + 1;
              int[] _data = new int[size];

              slaveAddress &= 0x3FFF; // Use only 14 bits
              slaveAddress = (mode & I2CMode.TENBIT)>0 ? slaveAddress & 0x03FF : slaveAddress & 0x007F;

              slaveAddress |= (int) mode << 7;
              _data[0] = slaveAddress;

              if(data!=null) {
            for(int i=1; i < size; i++) {
              _data[i] = data[i-1];
            }
              }

              return SysexCommand(Command.I2C_REQUEST, _data);
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="MonoBrick.NXT.I2CSensor"/> class.
		/// </summary>
		/// <param name='mode'>
		/// I2C mode
		/// </param>
		/// <param name='sensorAddress'>
		/// I2C address.
		/// </param>
		/// <param name='pollInterval'>
		/// Poll interval between checking for new values. This may need some tweaking depending on the sensor
		/// </param>
		public I2CBase(I2CMode mode, byte sensorAddress, int pollInterval) : base((SensorType) mode, SensorMode.Raw) {
            address = sensorAddress;
            pollTime = pollInterval;
        }
        private const int I2CTimeOut = 500;//in MS
        
		/// <summary>
		/// Initializes a new instance of the <see cref="MonoBrick.NXT.I2CSensor"/> class.
		/// </summary>
		/// <param name='mode'>
		/// I2C mode
		/// </param>
		/// <param name='sensorAddress'>
		/// I2C address.
		/// </param>
		public I2CBase(I2CMode mode, byte sensorAddress) : base((SensorType) mode, SensorMode.Raw) {
			address = sensorAddress;
            pollTime = 0;
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="MonoBrick.NXT.I2CSensor"/> class.
		/// </summary>
		/// <param name='mode'>
		/// 9v or normal mode
		/// </param>
		/// <param name='sensorAddress'>
		/// Sensor I2C address.
		/// </param>
		/// <param name='pollInterval'>
		/// Poll interval between checking for new values. This may need some tweaking depending on the sensor
		/// </param>
		public I2CSensor(I2CMode mode, byte sensorAddress, int pollInterval) : base(mode, sensorAddress,pollInterval) {
		
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="MonoBrick.NXT.I2CSensor"/> class.
		/// </summary>
		/// <param name='mode'>
		/// 9v or normal mode
		/// </param>
		/// <param name='sensorAddress'>
		/// Sensor I2C address
		/// </param>
		public I2CSensor(I2CMode mode, byte sensorAddress) : base(mode, sensorAddress) {
		
		}
Example #14
0
 public I2CRequest()
 {
     Mode = I2CMode.READ;
       Data = new int[ Defaults.MaxDataBytes ];
       Use10BitAddress = false;
 }