private void configurePin() {
    Pin pin = (Pin) findPin(config.pinNumber().getVal());

    unprovision(pin);
    switch (config.pinType()) { // Get request sets the input pin
      case input:
        GpioPinDigitalInput digitalIn = this.gpioContoller.provisionDigitalInputPin(pin);
        switch (config.pinLevel()) {
          case high:
            digitalIn.setPullResistance(PinPullResistance.PULL_UP);
            break;

          case low:
            digitalIn.setPullResistance(PinPullResistance.PULL_DOWN);
            break;
        }
        break;
        // Post request sets the output pin
      case output:
        GpioPinDigitalOutput digitalOut = this.gpioContoller.provisionDigitalOutputPin(pin);

        switch (config.pinLevel()) {
          case high:
            digitalOut.setState(true);
            break;
          case low:
            digitalOut.setState(false);
            break;
        }
        break;
    }
  }
Example #2
0
  @Override
  public GpioPinDigitalInput provisionDigitalInputPin(
      GpioProvider provider, Pin pin, String name, PinPullResistance resistance) {
    // create new GPIO pin instance
    GpioPinDigitalInput gpioPin = provisionDigitalInputPin(provider, pin, name);

    // set the gpio pull resistor
    if (resistance != null) {
      gpioPin.setPullResistance(resistance);
    }
    // return new new pin instance
    return gpioPin;
  }