powerState method

  1. @override
Future<PowerState> powerState({
  1. Map<String, dynamic>? extra,
})
override

Returns whether or not the motor is currently powered, and the portion of max power (between 0 and 1; 0 indicates that power is off). Stepper motors report true if they are being powered while holding a position, as well as when they are turning themselves.

// Check whether the motor is currently powered and
// check the percentage of max power to the motor.
var powerState = await myMotor.powerState();
var powered = powerState.isOn;
var pct = powerState.powerPct;

For more information, see Motor component.

Implementation

@override
Future<PowerState> powerState({Map<String, dynamic>? extra}) async {
  final request = IsPoweredRequest()
    ..name = name
    ..extra = extra?.toStruct() ?? Struct();
  final result = await client.isPowered(request);
  return PowerState.fromProto(result);
}