@Override public void pinStateChange(GpioInterruptEvent event) { // iterate over the pin listeners map for (Pin pin : listeners.keySet()) { // dispatch this event to the listener // if a matching pin address is found if (pin.getAddress() == event.getPin()) { dispatchPinDigitalStateChangeEvent(pin, PinState.getState(event.getState())); } } }
@Override public void pinStateChange(GpioInterruptEvent event) { // iterate over the pin listeners map for (Pin pin : listeners.keySet()) { // dispatch this event to the listener // if a matching pin address is found if (pin.getAddress() == event.getPin()) { dispatchPinDigitalStateChangeEvent(pin, PinState.getState(event.getState())); } } }
@Override public void setState(Pin pin, PinState state) { // validate pin if (!hasPin(pin)) { throw new InvalidPinException(pin); } // only permit invocation on pins set to DIGITAL_OUTPUT modes if (pinModeCache[pin.getAddress()] != PinMode.DIGITAL_OUTPUT) { throw new InvalidPinModeException(pin, "Invalid pin mode on pin [" + pin.getName() + "]; cannot setState() when pin mode is [" + pinModeCache[pin.getAddress()].getName() + "]"); } // control GPIO pin com.pi4j.wiringpi.Gpio.digitalWrite(pin.getAddress(), state.getValue()); // for digital output pins, we will echo the event feedback dispatchPinDigitalStateChangeEvent(pin, state); // for the Raspberry pi, we will not cache pin state since we never use the cache to get state. }
@Override public void setState(Pin pin, PinState state) { // validate pin if (!hasPin(pin)) { throw new InvalidPinException(pin); } // only permit invocation on pins set to DIGITAL_OUTPUT modes if (pinModeCache[pin.getAddress()] != PinMode.DIGITAL_OUTPUT) { throw new InvalidPinModeException(pin, "Invalid pin mode on pin [" + pin.getName() + "]; cannot setState() when pin mode is [" + pinModeCache[pin.getAddress()].getName() + "]"); } // control GPIO pin com.pi4j.wiringpi.Gpio.digitalWrite(pin.getAddress(), state.getValue()); // for digital output pins, we will echo the event feedback dispatchPinDigitalStateChangeEvent(pin, state); // for the Raspberry pi, we will not cache pin state since we never use the cache to get state. }