Пример #1
0
 /// <summary>
 /// CMPS03 Compass Module
 /// </summary>
 /// <param name="deviceAddress">7bit address of the sonar</param>
 public CMPS03Compass(byte deviceAddress)
 {
     this._slave = new I2CSlave(deviceAddress);
 }
Пример #2
0
        /// <summary>
        /// Changes address of the I2C device.
        /// Works only for revision 14 and above
        /// </summary>
        /// <param name="newAddress">New 7bit address</param>
        public void ChangeI2CAddress(byte newAddress)
        {
            byte[] data = new byte[4] {
                I2CSlave.ADDRESS_CHANGE_1,
                I2CSlave.ADDRESS_CHANGE_2,
                I2CSlave.ADDRESS_CHANGE_3,
                (byte)(newAddress << 1),
            };

            _slave.WriteRegister(CMPS03Compass.REG_UNLOCK_1, data);
            _slave.Dispose();

            // Wait a few miliseconds to make things "sattle", otherwise it will fail
            Thread.Sleep(50);

            // Create _slave with new address
            _slave = new I2CSlave(newAddress);
        }
Пример #3
0
 /// <summary>
 /// SRF02 Range Finder
 /// </summary>
 /// <param name="deviceAddress">7bit address of the sonar</param>
 public SRF02Sonar(byte deviceAddress)
 {
     this._slave = new I2CSlave(deviceAddress);
 }
Пример #4
0
 /// <summary>
 /// SD20 Servo Driver
 /// </summary>
 /// <param name="deviceAddress">7bit address of the SD20</param>
 public SD20ServoDriver(byte deviceAddress)
 {
     this._slave = new I2CSlave(deviceAddress);
 }
Пример #5
0
        /// <summary>
        /// Changes address of the I2C device
        /// </summary>
        /// <param name="newAddress">New 7bit address</param>
        public void ChangeI2CAddress(byte newAddress)
        {
            _slave.ChangeI2CAddress(SRF02Sonar.REG_COMMAND_REVISION, newAddress);

            _slave.Dispose();

            // Wait a few miliseconds to make things "sattle", otherwise it will fail
            Thread.Sleep(50);

            // Create _slave with new address
            _slave = new I2CSlave(newAddress);
        }