public void setProgrammableGainAmplifier(ProgrammableGainAmplifierValue pga, Pin...pin){ for(Pin p : pin){ this.pga[p.getAddress()] = pga; } }
public static Pin getPinByAddress(int address) { for(Pin pin : pins.values()){ if(pin.getAddress() == address){ return pin; } } return null; }
private void setPullResistanceA(Pin pin, PinPullResistance resistance) throws IOException { // determine pin address int pinAddress = pin.getAddress() - GPIO_A_OFFSET; // determine pull up value for pin bit if (resistance == PinPullResistance.PULL_UP) { currentPullupA |= pinAddress; } else { currentPullupA &= ~pinAddress; } // next update pull up resistor value device.write(REGISTER_GPPU_A, (byte) currentPullupA); }
private void setPullResistanceB(Pin pin, PinPullResistance resistance) throws IOException { // determine pin address int pinAddress = pin.getAddress() - GPIO_B_OFFSET; // determine pull up value for pin bit if (resistance == PinPullResistance.PULL_UP) { currentPullupB |= pinAddress; } else { currentPullupB &= ~pinAddress; } // next update pull up resistor value write(REGISTER_GPPU_B, (byte) currentPullupB); }
public void setProgrammableGainAmplifier(ProgrammableGainAmplifierValue pga, GpioPin...pin){ for(GpioPin p : pin){ this.pga[p.getPin().getAddress()] = pga; } }
private void setPullResistanceB(Pin pin, PinPullResistance resistance) throws IOException { // determine pin address int pinAddress = pin.getAddress() - GPIO_B_OFFSET; // determine pull up value for pin bit if (resistance == PinPullResistance.PULL_UP) { currentPullupB |= pinAddress; } else { currentPullupB &= ~pinAddress; } // next update pull up resistor value device.write(REGISTER_GPPU_B, (byte) currentPullupB); }
private void setPullResistanceA(Pin pin, PinPullResistance resistance) throws IOException { // determine pin address int pinAddress = pin.getAddress() - GPIO_A_OFFSET; // determine pull up value for pin bit if (resistance == PinPullResistance.PULL_UP) { currentPullupA |= pinAddress; } else { currentPullupA &= ~pinAddress; } // next update pull up resistor value write(REGISTER_GPPU_A, (byte) currentPullupA); }
private void setPullResistanceB(Pin pin, PinPullResistance resistance) throws IOException { // determine pin address int pinAddress = pin.getAddress() - GPIO_B_OFFSET; // determine pull up value for pin bit if (resistance == PinPullResistance.PULL_UP) { currentPullupB |= pinAddress; } else { currentPullupB &= ~pinAddress; } // next update pull up resistor value write(REGISTER_GPPU_B, (byte) currentPullupB); }
@Override public void setState(Pin pin, PinState state) { super.setState(pin, state); // turn ON/OFF relay pins if (state == PinState.HIGH) { queue.put("+" + pin.getAddress()); } else { queue.put("-" + pin.getAddress()); } }
@Override protected void doStop() throws Exception { pin.removeListener(this); log.trace("Stop Listening GPIO {}", pin.getPin().getAddress()); }
private void setStateA(Pin pin, PinState state) throws IOException { // determine pin address int pinAddress = pin.getAddress() - GPIO_A_OFFSET; // determine state value for pin bit if (state.isHigh()) { currentStatesA |= pinAddress; } else { currentStatesA &= ~pinAddress; } // update state value device.write(REGISTER_GPIO_A, (byte) currentStatesA); }
private PinState getStateA(Pin pin){ // determine pin address int pinAddress = pin.getAddress() - GPIO_A_OFFSET; // determine pin state PinState state = (currentStatesA & pinAddress) == pinAddress ? PinState.HIGH : PinState.LOW; // cache state getPinCache(pin).setState(state); return state; }
@Override public boolean isExported(Pin pin) { super.isExported(pin); // return the pin exported state return GpioUtil.isExported(pin.getAddress()); }
@Override public void unexport(Pin pin) { super.unexport(pin); // unexport the pins GpioUtil.unexport(pin.getAddress()); }
private PinState getStateA(Pin pin){ // determine pin address int pinAddress = pin.getAddress() - GPIO_A_OFFSET; // determine pin state PinState state = (currentStatesA & pinAddress) == pinAddress ? PinState.HIGH : PinState.LOW; // cache state getPinCache(pin).setState(state); return state; }
private void setStateB(Pin pin, PinState state) throws IOException { // determine pin address int pinAddress = pin.getAddress() - GPIO_B_OFFSET; // determine state value for pin bit if (state.isHigh()) { currentStatesB |= pinAddress; } else { currentStatesB &= ~pinAddress; } // update state value write(REGISTER_GPIO_B, (byte) currentStatesB); }
private PinState getStateB(Pin pin){ // determine pin address int pinAddress = pin.getAddress() - GPIO_B_OFFSET; // determine pin state PinState state = (currentStatesB & pinAddress) == pinAddress ? PinState.HIGH : PinState.LOW; // cache state getPinCache(pin).setState(state); return state; }
@Override public void setState(Pin pin, PinState state) { super.setState(pin, state); try { // set state value for pin bit currentStates.set(pin.getAddress(), state.isHigh()); // update state value device.write(currentStates.isEmpty() ? 0 : currentStates.toByteArray()[0]); } catch (IOException ex) { throw new RuntimeException(ex); } }
@Override public void setPullResistance(Pin pin, PinPullResistance resistance) { super.setPullResistance(pin, resistance); com.pi4j.wiringpi.Gpio.pullUpDnControl(pin.getAddress(), resistance.getValue()); }
@Override public PinState getState(Pin pin) { super.getState(pin); // return pin state PinState state = null; int ret = com.pi4j.wiringpi.Gpio.digitalRead(pin.getAddress()); if (ret >= 0) { state = PinState.getState(ret); } return state; }