// Read a series of bytes from the accelerometer private byte[] readBytesACC(byte regAddr, int length) { byte[] values = new byte[length]; byte[] buffer = new byte[1]; buffer[0] = (byte)(0x80 | regAddr); I2CACC.WriteRead(buffer, values); return(values); }
// Read a series of bytes from the magnetometer private byte[] readBytesMAG(byte regAddr, int length) { byte[] values = new byte[length]; byte[] buffer = new byte[1]; buffer[0] = (byte)(0x80 | regAddr); I2CACC.WriteRead(buffer, values); // The magnetometer uses the same I2C slave address as the accelerometer return(values); }
// Write a byte to the magnetometer private void writeByteMAG(byte regAddr, byte value) { byte[] values = new byte[value]; byte[] WriteBuf = new byte[] { regAddr, value }; I2CACC.Write(WriteBuf); // The magnetometer uses the same I2C slave address as the accelerometer }
// Write a byte to the accelerometer private void writeByteACC(byte regAddr, byte value) { byte[] values = new byte[value]; byte[] WriteBuf = new byte[] { regAddr, value }; I2CACC.Write(WriteBuf); }
private void MainPage_Unloaded(object sender, object args) { // Cleanup I2CGYR.Dispose(); I2CACC.Dispose(); }