예제 #1
0
  @Override
  public GpioPinAnalogOutput provisionAnalogOutputPin(
      GpioProvider provider, Pin pin, String name, double defaultValue) {
    // create new GPIO pin instance
    GpioPinAnalogOutput gpioPin = provisionAnalogOutputPin(provider, pin, name);

    // apply default value
    gpioPin.setValue(defaultValue);

    // return new new pin instance
    return gpioPin;
  }
예제 #2
0
 @Override
 public void setValue(double value, GpioPinAnalogOutput... pin) {
   if (pin == null || pin.length == 0) {
     throw new IllegalArgumentException("Missing pin argument.");
   }
   for (GpioPinAnalogOutput p : pin) {
     // ensure the requested pin has been provisioned
     if (!pins.contains(p)) {
       throw new GpioPinNotProvisionedException(p.getPin());
     }
     // set pin PWM value
     p.setValue(value);
   }
 }
예제 #3
0
  private void output(Exchange exchange, Object value) {

    //
    PinMode mode = pin.getMode();
    log.debug("Mode > " + mode + " for " + pin);

    // Check mode
    switch (mode) {
      case DIGITAL_OUTPUT:
        Boolean outputBoolean =
            exchange.getContext().getTypeConverter().convertTo(Boolean.class, value);
        ((GpioPinDigitalOutput) pin).setState(outputBoolean);
        break;

      case ANALOG_OUTPUT:
        Double outputDouble =
            exchange.getContext().getTypeConverter().convertTo(Double.class, value);
        ((GpioPinAnalogOutput) pin).setValue(outputDouble);
        break;

      case PWM_OUTPUT:
        Integer outputInt =
            exchange.getContext().getTypeConverter().convertTo(Integer.class, value);
        ((GpioPinPwmOutput) pin).setPwm(outputInt);

        break;

      case ANALOG_INPUT:
      case DIGITAL_INPUT:
        log.error("Cannot output with INPUT PinMode");
        break;

      default:
        log.error("Any PinMode found");
        break;
    }
  }