コード例 #1
0
        private static double ReadAxis(byte register)
        {
            byte[] data = new byte[2];
            _i2c.WriteRead(new byte[1] {
                register
            }, ref data);

            double value = data[0] << 2 | data[1] >> 6;

            if ((value > 511.0))
            {
                value -= 1024.0;
            }
            value /= 512.0;
            return(value);
        }
コード例 #2
0
        private byte[] CommandRead(int reg, int numberOfBytes)
        {
            byte[] writeBuffer = new byte[2];
            byte[] readBuffer  = new byte[numberOfBytes];

            writeBuffer[0] = (byte)(reg >> 8);
            writeBuffer[1] = (byte)(reg & 0xFF);

            readBuffer = i2c.WriteRead(writeBuffer, 1);
            if (readBuffer != null)
            {
                return(readBuffer);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        public void StartMeasurement()
        {
            byte[] configurationRegister;

            configurationRegister    = bmeSensor.WriteRead(new byte[] { (byte)Register.CONFIGURATION }, 1);
            configurationRegister[0] = (byte)((configurationRegister[0] & 0xFC) | (byte)MODE.FORCED);
            WriteRegister((byte)Register.CONFIGURATION, configurationRegister[0]);
        }