@Converter public static boolean pinStateToBoolean(PinState state) { return state.isHigh(); }
@Converter public static PinState booleanToPinState(boolean state) { return getState(state); }
"\",\"pull\":\"" + pin.getPullResistance().getName() + "\"},\"state\":{" + "\"name\":\"" + state.getName() + "\",\"value\":\"" + state.getValue() + "\",\"is-high\":\"" + state.isHigh() + "\",\"is-low\":\"" + state.isLow() + "\"},\"timestamp\":\"" + df.format(new Date()) + "\"}"; Integer.toString(state.getValue()), // VALUE 2
@Override public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) { System.out.println("handleGpioPinDigitalStateChangeEvent(" + event.getState().getValue() + ")"); } }
@Override public String toString() { return "PIN [" + pin.getName() + "] CACHE :: mode=" + mode.getName() + "; state=" + state.getName(); }
public synchronized static Future<?> pulse(GpioPinDigitalOutput pin, long duration, PinState pulseState, Callable<?> callback) { // create future return object ScheduledFuture<?> scheduledFuture = null; // perform the initial startup and cleanup for this pin init(pin); // we only pulse for requests with a valid duration in milliseconds if (duration > 0) { // set the active state pin.setState(pulseState); // create future job to return the pin to the low state scheduledFuture = scheduledExecutorService .schedule(new GpioPulseTaskImpl(pin, PinState.getInverseState(pulseState), callback), duration, TimeUnit.MILLISECONDS); // get pending tasks for the current pin ArrayList<ScheduledFuture<?>> tasks; if (!pinTaskQueue.containsKey(pin)) { pinTaskQueue.put(pin, new ArrayList<ScheduledFuture<?>>()); } tasks = pinTaskQueue.get(pin); // add the new scheduled task to the tasks collection tasks.add(scheduledFuture); // create future task to clean up completed tasks createCleanupTask(duration + 500); } // return future task return scheduledFuture; }
public GpioTriggerBase() { addPinState(PinState.allStates()); }
public static PinState[] allStates() { return PinState.values(); }
"\",\"pull\":\"" + pin.getPullResistance().getName() + "\"},\"state\":{" + "\"name\":\"" + state.getName() + "\",\"value\":\"" + state.getValue() + "\",\"is-high\":\"" + state.isHigh() + "\",\"is-low\":\"" + state.isLow() + "\"},\"timestamp\":\"" + df.format(new Date()) + "\"}"; Integer.toString(state.getValue()), // VALUE 2
@Override public double getValue(Pin pin) { // the getMode() will validate the pin exists with the hasPin() function PinMode mode = getMode(pin); if (mode == PinMode.DIGITAL_OUTPUT) { return getState(pin).getValue(); } // return cached pin analog value return getPinCache(pin).getAnalogValue(); }
@Override public String toString() { return "PIN [" + pin.getName() + "] CACHE :: mode=" + mode.getName() + "; state=" + state.getName(); }
public synchronized static Future<?> pulse(GpioPinDigitalOutput pin, long duration, PinState pulseState, Callable<?> callback) { // create future return object ScheduledFuture<?> scheduledFuture = null; // perform the initial startup and cleanup for this pin init(pin); // we only pulse for requests with a valid duration in milliseconds if (duration > 0) { // set the active state pin.setState(pulseState); // create future job to return the pin to the low state scheduledFuture = scheduledExecutorService .schedule(new GpioPulseTaskImpl(pin, PinState.getInverseState(pulseState), callback), duration, TimeUnit.MILLISECONDS); // get pending tasks for the current pin ArrayList<ScheduledFuture<?>> tasks; if (!pinTaskQueue.containsKey(pin)) { pinTaskQueue.put(pin, new ArrayList<>()); } tasks = pinTaskQueue.get(pin); // add the new scheduled task to the tasks collection tasks.add(scheduledFuture); // create future task to clean up completed tasks createCleanupTask(duration + 500); } // return future task return scheduledFuture; }
public GpioTriggerBase() { addPinState(PinState.allStates()); }
public static PinState[] allStates() { return PinState.values(); }
@Override public boolean getValue() throws RuntimeIOException { return digitalInputOutputPin.getState().isHigh(); }