SensorOffsets.parse constructor

SensorOffsets.parse(
  1. ByteData data_
)

Implementation

factory SensorOffsets.parse(ByteData data_) {
  if (data_.lengthInBytes < SensorOffsets.mavlinkEncodedLength) {
    var len = SensorOffsets.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var magDeclination = data_.getFloat32(0, Endian.little);
  var rawPress = data_.getInt32(4, Endian.little);
  var rawTemp = data_.getInt32(8, Endian.little);
  var gyroCalX = data_.getFloat32(12, Endian.little);
  var gyroCalY = data_.getFloat32(16, Endian.little);
  var gyroCalZ = data_.getFloat32(20, Endian.little);
  var accelCalX = data_.getFloat32(24, Endian.little);
  var accelCalY = data_.getFloat32(28, Endian.little);
  var accelCalZ = data_.getFloat32(32, Endian.little);
  var magOfsX = data_.getInt16(36, Endian.little);
  var magOfsY = data_.getInt16(38, Endian.little);
  var magOfsZ = data_.getInt16(40, Endian.little);

  return SensorOffsets(
      magDeclination: magDeclination,
      rawPress: rawPress,
      rawTemp: rawTemp,
      gyroCalX: gyroCalX,
      gyroCalY: gyroCalY,
      gyroCalZ: gyroCalZ,
      accelCalX: accelCalX,
      accelCalY: accelCalY,
      accelCalZ: accelCalZ,
      magOfsX: magOfsX,
      magOfsY: magOfsY,
      magOfsZ: magOfsZ);
}