GpioLine class

Provides access to a single GPIO line / pin.

Basically has 5 states that define the methods you can call:

The info can be retrieved in all states.

Example usage of GpioLine:

import 'package:flutter_gpiod/flutter_gpiod.dart';

// find the chip with label 'pinctrl-bcm2835'
// (the main Raspberry Pi IO chip)
final chip = FlutterGpiod.instance.chips.singleWhere(
  (chip) => chip.label == 'pinctrl-bcm2835'
);

// get line 22 of that chip
final line = chip.lines[22];

print("pinctrl-bcm2835, line 22: $(line.info)");

// request is as output and initialize it with false
await line.requestOutput(
  consumer: "flutter_gpiod output test",
  initialValue: false
);

// set the line active
line.setValue(true);

await Future.delayed(Duration(milliseconds: 500));

// set the line inactive again
line.setValue(false);

line.release();

// request the line as input, and listen for both edges
// we don't use `line.reconfigure` because that doesn't
// allow us to specify triggers.
line.requestInput(
  consumer: "flutter_gpiod input test",
  triggers: const {SignalEdge.rising, SignalEdge.falling}
));

// print line events for eternity
await for (final event in line.onEvent) {
  print("gpio line signal event: $event");
}

// line.release();

Properties

hashCode int
The hash code for this object.
no setterinherited
info LineInfo
Returns the line info for this line.
no setter
onEdge Stream<SignalEdge>
Broadcast stream of signal edges.
no setter
onEvent Stream<SignalEvent>
Gets a broadcast stream of SignalEvents for this line.
no setter
requested bool
Whether this line is requested (owned by you) right now.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
triggers Set<SignalEdge>
The signal edges that this line is listening on right now, or equivalently, the signal edges that will trigger a SignalEvent that can be retrieved by listening on GpioLine.onEvent.
no setter

Methods

getValue() bool
Reads the value of the line (active / inactive)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reconfigureInput({Bias? bias, ActiveState activeState = ActiveState.high}) → void
Reconfigures the line as input with the given configuration.
reconfigureOutput({OutputMode outputMode = OutputMode.pushPull, Bias? bias, ActiveState activeState = ActiveState.high, required bool initialValue}) → void
Reconfigures the line as output with the given configuration.
release() → void
Releases the line, so you don't own it anymore.
requestInput({required String consumer, Bias? bias, ActiveState activeState = ActiveState.high, Set<SignalEdge> triggers = const {}}) → void
Requests ownership of a GPIO line with the given configuration.
requestOutput({required String consumer, OutputMode outputMode = OutputMode.pushPull, Bias? bias, ActiveState activeState = ActiveState.high, required bool initialValue}) → void
Requests ownership of a GPIO line with the given configuration.
setValue(bool value) → void
Sets the value of the line to active (true) or inactive (false).
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited