Rangefinder.parse constructor

Rangefinder.parse(
  1. ByteData data_
)

Implementation

factory Rangefinder.parse(ByteData data_) {
  if (data_.lengthInBytes < Rangefinder.mavlinkEncodedLength) {
    var len = Rangefinder.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var distance = data_.getFloat32(0, Endian.little);
  var voltage = data_.getFloat32(4, Endian.little);

  return Rangefinder(distance: distance, voltage: voltage);
}