reconfigureOutput method

void reconfigureOutput({
  1. OutputMode outputMode = OutputMode.pushPull,
  2. Bias? bias,
  3. ActiveState activeState = ActiveState.high,
  4. required bool initialValue,
})

Reconfigures the line as output with the given configuration.

If FlutterGpiod.supportsBias is false, bias must be null, otherwise a UnsupportedError will be thrown.

This will throw a UnsupportedError if FlutterGpiod.supportsLineReconfiguration is false.

Implementation

void reconfigureOutput({
  OutputMode outputMode = OutputMode.pushPull,
  Bias? bias,
  ActiveState activeState = ActiveState.high,
  required bool initialValue,
}) {
  ArgumentError.checkNotNull(outputMode, "outputMode");
  _checkSupportsBiasValue(bias);
  ArgumentError.checkNotNull(activeState, "activeState");
  ArgumentError.checkNotNull(initialValue, "initialValue");
  _checkSupportsLineReconfiguration();

  _info = null;
  _value = null;

  if (!_requested) {
    throw StateError("Can't reconfigured line because it is not requested.");
  }

  PlatformInterface.instance.reconfigureLine(
    lineHandle: _lineHandle,
    direction: LineDirection.output,
    outputMode: outputMode,
    bias: bias,
    activeState: activeState,
    initialValue: initialValue,
  );

  _value = initialValue;
  _info = PlatformInterface.instance.getLineInfo(_lineHandle);
}