@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); } }
@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; }
/** * Set the shutdown/terminate value that the DAC should apply to the given GPIO pin * when the class is destroyed/terminated. * * @param value the shutdown value to apply to the given pin(s) * @param pin analog output pin (vararg: one or more pins) */ public void setShutdownValue(Number value, GpioPinAnalogOutput ... pin){ for(GpioPinAnalogOutput p : pin) { setShutdownValue(value, p.getPin()); } }
@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; }
/** * Get the shutdown/terminate value that the DAC should apply to the given GPIO pin * when the class is destroyed/terminated. * * @param pin analog output pin * @return return the shutdown value if one has been defined, else NULL. */ public Number getShutdownValue(GpioPinAnalogOutput pin){ return getShutdownValue(pin.getPin()); } }
@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); } }
/** * Set the current analog value as a percentage of the available range instead of a raw value. * Thr framework will automatically convert the percentage to a scaled number in the ADC's value range. * * @return percentage value between 0 and 100. */ @Override public void setPercentValue(GpioPinAnalogOutput pin, Number percent){ setPercentValue(pin.getPin(), percent); }
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; } }