示例#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);
        }
示例#2
0
 static Accelerometer()
 {
     _i2c = new I2C(0x1c);
     _i2c.Write(new byte[2] {
         0x2a, 0x01
     });
 }
示例#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);
        }
示例#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);
        }
示例#5
0
 static Accelerometer()
 {
     _i2c = new I2C(0x1c);
     _i2c.Write(new byte[2] { 0x2a, 0x01 });
 }
示例#6
0
 private void WriteRegister(byte reg, byte data)
 {
     byte[] command = { reg, data };
     bmeSensor.Write(command);
 }
示例#7
0
 protected void Write(Register register)
 {
     Buffer[0] = (byte)register;
     I2c.Write(I2C.Speed.OneHundredkHz, (UInt16)SensorAddress, Buffer, length: 1);
 }
示例#8
0
 protected void Write(Register register, byte data)
 {
     Buffer[0] = (byte)register;
     Buffer[1] = data;
     I2c.Write(I2C.Speed.FourHundredkHz, Address, Buffer);
 }
示例#9
0
 public void Read()
 {
     I2c.Write(I2C.Speed.FourHundredkHz, Address, Buffer, length: 0);
     Thread.Sleep(60);
     I2c.Read(I2C.Speed.FourHundredkHz, Address, Buffer);
 }