VfrHud.parse constructor

VfrHud.parse(
  1. ByteData data_
)

Implementation

factory VfrHud.parse(ByteData data_) {
  if (data_.lengthInBytes < VfrHud.mavlinkEncodedLength) {
    var len = VfrHud.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var airspeed = data_.getFloat32(0, Endian.little);
  var groundspeed = data_.getFloat32(4, Endian.little);
  var alt = data_.getFloat32(8, Endian.little);
  var climb = data_.getFloat32(12, Endian.little);
  var heading = data_.getInt16(16, Endian.little);
  var throttle = data_.getUint16(18, Endian.little);

  return VfrHud(
      airspeed: airspeed,
      groundspeed: groundspeed,
      alt: alt,
      climb: climb,
      heading: heading,
      throttle: throttle);
}