pollMultiple static method
Polls multiple GPIOs for an edge event configured with GPIO.setGPIOedge.
For character device GPIOs, the edge event should be consumed with
GPIO.readEvent. For sysfs GPIOs, the edge event should be consumed
with GPIO.read. timeoutMillis can be positive for a timeout
in milliseconds, zero for a non-blocking poll, or
negative for a blocking poll. Returns a PollMultipleEvent()
Implementation
static PollMultipleEvent pollMultiple(List<GPIO> gpios, int timeoutMillis) {
final ptr = malloc<Pointer<Void>>(gpios.length);
final result = malloc<Int8>(gpios.length);
try {
var index = 0;
for (var g in gpios) {
g._checkStatus();
ptr[index++] = g._gpioHandle;
}
_checkError(
_nativeGPIOmultiplePoll(ptr, gpios.length, timeoutMillis, result));
var list = List<bool>.filled(gpios.length, false);
var counter = 0;
for (var i = 0; i < gpios.length; ++i) {
list[i] = result[i] == 1 ? true : false;
if (list[i]) {
++counter;
}
}
return PollMultipleEvent(gpios, counter, list);
} finally {
malloc.free(ptr);
malloc.free(result);
}
}