Battery2.parse constructor

Battery2.parse(
  1. ByteData data_
)

Implementation

factory Battery2.parse(ByteData data_) {
  if (data_.lengthInBytes < Battery2.mavlinkEncodedLength) {
    var len = Battery2.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var voltage = data_.getUint16(0, Endian.little);
  var currentBattery = data_.getInt16(2, Endian.little);

  return Battery2(voltage: voltage, currentBattery: currentBattery);
}