/** * default constructor; using this constructor assumes that: * (1) a pin state of HIGH is BUTTON PRESSED * (2) a pin state of LOW is BUTTON RELEASED * * @param pin GPIO digital input pin */ public GpioButtonComponent(GpioPinDigitalInput pin) { this.pin = pin; // add pin listener this.pin.addListener(pinListener); }
/** * default constructor; using this constructor assumes that: * (1) a pin state of HIGH is SWITCH CLOSED/ON * (2) a pin state of LOW is SWITCH OPEN/OFF * * @param pin GPIO digital input pin */ public GpioToggleSwitchComponent(GpioPinDigitalInput pin) { this.pin = pin; // add pin listener this.pin.addListener(pinListener); }
/** * default constructor; using this constructor assumes that: * (1) a pin state of HIGH is SWITCH CLOSED/ON * (2) a pin state of LOW is SWITCH OPEN/OFF * * @param pin GPIO digital input pin */ public GpioMomentarySwitchComponent(GpioPinDigitalInput pin) { this.pin = pin; // add pin listener this.pin.addListener(pinListener); }
/** * default constructor; using this constructor assumes that: * (1) a pin state of HIGH is SWITCH CLOSED/ON * (2) a pin state of LOW is SWITCH OPEN/OFF * * @param pin GPIO digital input pin */ public GpioToggleSwitchComponent(GpioPinDigitalInput pin) { this.pin = pin; // add pin listener this.pin.addListener(pinListener); }
/** * default constructor; using this constructor assumes that: * (1) a pin state of HIGH is MOTION DETECTED * * @param pin GPIO digital input pin */ public GpioMotionSensorComponent(GpioPinDigitalInput pin) { this.pin = pin; // add pin listener this.pin.addListener(pinListener); }
/** * default constructor; using this constructor assumes that: * (1) a pin state of HIGH is SENSOR CLOSED * (2) a pin state of LOW is SENSOR OPEN * * @param pin GPIO digital input pin */ public GpioSensorComponent(GpioPinDigitalInput pin) { this.pin = pin; this.pin.addListener(pinListener); }
/** * using this constructor requires that the consumer * define the MOTION DETECTED pin state * * @param pin GPIO digital input pin * @param motionDetectedState pin state to set when SENSOR DETECTS MOTION */ public GpioMotionSensorComponent(GpioPinDigitalInput pin, PinState motionDetectedState) { this.pin = pin; this.motionDetectedState = motionDetectedState; // add pin listener this.pin.addListener(pinListener); }
/** * default constructor; using this constructor assumes that: * (1) a pin state of HIGH is SWITCH CLOSED/ON * (2) a pin state of LOW is SWITCH OPEN/OFF * * @param pin GPIO digital input pin */ public GpioSwitchComponent(GpioPinDigitalInput pin) { this.pin = pin; // add pin listener this.pin.addListener(pinListener); }
/** * default constructor; using this constructor assumes that: * (1) a pin state of HIGH is BUTTON PRESSED * (2) a pin state of LOW is BUTTON RELEASED * * @param pin GPIO digital input pin */ public GpioButtonComponent(GpioPinDigitalInput pin) { this.pin = pin; // add pin listener this.pin.addListener(pinListener); }
/** * default constructor; using this constructor assumes that: * (1) a pin state of HIGH is MOTION DETECTED * * @param pin GPIO digital input pin */ public GpioMotionSensorComponent(GpioPinDigitalInput pin) { this.pin = pin; // add pin listener this.pin.addListener(pinListener); }
/** * default constructor; using this constructor assumes that: * (1) a pin state of HIGH is SENSOR CLOSED * (2) a pin state of LOW is SENSOR OPEN * * @param pin GPIO digital input pin */ public GpioSensorComponent(GpioPinDigitalInput pin) { this.pin = pin; this.pin.addListener(pinListener); }
/** * default constructor; using this constructor assumes that: * (1) a pin state of HIGH is SWITCH CLOSED/ON * (2) a pin state of LOW is SWITCH OPEN/OFF * * @param pin GPIO digital input pin */ public GpioMomentarySwitchComponent(GpioPinDigitalInput pin) { this.pin = pin; // add pin listener this.pin.addListener(pinListener); }
/** * default constructor; using this constructor assumes that: * (1) a pin state of HIGH is SWITCH CLOSED/ON * (2) a pin state of LOW is SWITCH OPEN/OFF * * @param pin GPIO digital input pin */ public GpioSwitchComponent(GpioPinDigitalInput pin) { this.pin = pin; // add pin listener this.pin.addListener(pinListener); }
/** * using this constructor requires that the consumer * define the MOTION DETECTED pin state * * @param pin GPIO digital input pin * @param motionDetectedState pin state to set when SENSOR DETECTS MOTION */ public GpioMotionSensorComponent(GpioPinDigitalInput pin, PinState motionDetectedState) { this.pin = pin; this.motionDetectedState = motionDetectedState; // add pin listener this.pin.addListener(pinListener); }
/** * using this constructor requires that the consumer * define the BUTTON PRESSED/RELEASED pin states * * @param pin GPIO digital input pin * @param releasedState pin state to set when BUTTON is RELEASED * @param pressedState pin state to set when BUTTON is PRESSED */ public GpioButtonComponent(GpioPinDigitalInput pin, PinState releasedState, PinState pressedState) { this.pin = pin; this.pressedState = pressedState; this.releasedState = releasedState; // add pin listener this.pin.addListener(pinListener); }
/** * using this constructor requires that the consumer * define the SWITCH OPEN/OFF and SWITCH CLOSED/ON pin states * * @param pin GPIO digital input pin * @param offState pin state to set when SWITCH is OPEN/OFF * @param onState pin state to set when SWITCH is CLOSED/ON */ public GpioSwitchComponent(GpioPinDigitalInput pin, PinState offState, PinState onState) { this.pin = pin; this.onState = onState; this.offState = offState; // add pin listener this.pin.addListener(pinListener); }
/** * using this constructor requires that the consumer * define the SWITCH OPEN/OFF and SWITCH CLOSED/ON pin states * * @param pin GPIO digital input pin * @param offState pin state to set when SWITCH is OPEN/OFF * @param onState pin state to set when SWITCH is CLOSED/ON */ public GpioMomentarySwitchComponent(GpioPinDigitalInput pin, PinState offState, PinState onState) { this.pin = pin; this.onState = onState; this.offState = offState; // add pin listener this.pin.addListener(pinListener); }
/** * using this constructor requires that the consumer * define the BUTTON PRESSED/RELEASED pin states * * @param pin GPIO digital input pin * @param releasedState pin state to set when BUTTON is RELEASED * @param pressedState pin state to set when BUTTON is PRESSED */ public GpioButtonComponent(GpioPinDigitalInput pin, PinState releasedState, PinState pressedState) { this.pin = pin; this.pressedState = pressedState; this.releasedState = releasedState; // add pin listener this.pin.addListener(pinListener); }
@Override public void enableListener() { digitalInputPin.removeAllListeners(); digitalInputPin.addListener(this); }
public void test(int gpio) { GpioFactory.setDefaultProvider(new RaspiGpioProvider(RaspiPinNumberingScheme.BROADCOM_PIN_NUMBERING)); GpioController gpio_controller = GpioFactory.getInstance(); Pin pin = RaspiBcmPin.getPinByAddress(gpio); GpioPinDigitalInput digitalInputPin = gpio_controller.provisionDigitalInputPin(pin, "Digital Input for BCM GPIO " + gpio, PinPullResistance.PULL_UP); GpioUtil.setEdgeDetection(pin.getAddress(), PinEdge.BOTH.getValue()); digitalInputPin.addListener(this); System.out.println("Waiting 20s for events..., thread name=" + Thread.currentThread().getName()); SleepUtil.sleepSeconds(20); gpio_controller.unprovisionPin(digitalInputPin); gpio_controller.shutdown(); }