Exemple #1
0
        public bool Write(byte address, byte value)
        {
            bool success;

            lock (lockObject)
            {
                success = port.Write(address | 0x80, value);
            }
            if (!success && trace)
            {
                Console.WriteLine("navX-MXP I2C Write Error");
            }
            return(success);
        }
Exemple #2
0
 static Accelerometer()
 {
     _i2c = new I2C(0x1c);
     _i2c.Write(new byte[2] {
         0x2a, 0x01
     });
 }
Exemple #3
0
        private int CommandWrite(int reg, byte data)
        {
            int success = 0;

            byte[] commandArray = new byte[3];

            commandArray[0] = (byte)(reg >> 8);
            commandArray[1] = (byte)(reg & 0xFF);
            commandArray[2] = data;

            success = i2c.Write(commandArray);

            return(success);
        }
Exemple #4
0
        public static void Init()
        {
            _device75 = new I2C(0x75);
            if (I2C.I2CGlobalError)
            {
                return;
            }

            _device75.Write(6, 0xFBF8); //0x0100
            _device75.Read(0);

            _interputPin         = Pi.Gpio[30];
            _interputPin.PinMode = GpioPinDriveMode.Input;
            _interputPin.RegisterInterruptCallback(EdgeDetection.FallingEdge, ButtonPressCallback);
        }
Exemple #5
0
 static Accelerometer()
 {
     _i2c = new I2C(0x1c);
     _i2c.Write(new byte[2] { 0x2a, 0x01 });
 }
Exemple #6
0
 private void WriteRegister(byte reg, byte data)
 {
     byte[] command = { reg, data };
     bmeSensor.Write(command);
 }
Exemple #7
0
 protected void Write(Register register)
 {
     Buffer[0] = (byte)register;
     I2c.Write(I2C.Speed.OneHundredkHz, (UInt16)SensorAddress, Buffer, length: 1);
 }
 protected void Write(Register register, byte data)
 {
     Buffer[0] = (byte)register;
     Buffer[1] = data;
     I2c.Write(I2C.Speed.FourHundredkHz, Address, Buffer);
 }
Exemple #9
0
 public void Read()
 {
     I2c.Write(I2C.Speed.FourHundredkHz, Address, Buffer, length: 0);
     Thread.Sleep(60);
     I2c.Read(I2C.Speed.FourHundredkHz, Address, Buffer);
 }