allocatePin method

void allocatePin(
  1. int physicalPin
)

Check that the pin can be used for GPIO and that is has not already been allocated. This should be called by subclasses not clients.

Implementation

void allocatePin(int physicalPin) {
  if (physicalPin < 0 ||
      physicalPin >= physToBcmGpioRPi2.length ||
      physToBcmGpioRPi2[physicalPin] < 0) {
    throw GpioException('Invalid pin', physicalPin);
  }
  if (_allocatedPins.contains(physicalPin)) {
    throwPinAlreadyAllocated(physicalPin);
  }
  _allocatedPins.add(physicalPin);
}