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 void evaluatePinForChangeB(Pin pin, int state) {
      if (getPinCache(pin).isExported()) {
        // determine pin address
        int pinAddress = pin.getAddress() - GPIO_B_OFFSET;

        if ((state & pinAddress) != (currentStatesB & pinAddress)) {
          PinState newState = (state & pinAddress) == pinAddress ? PinState.HIGH : PinState.LOW;

          // cache state
          getPinCache(pin).setState(newState);

          // determine and cache state value for pin bit
          if (newState.isHigh()) {
            currentStatesB |= pinAddress;
          } else {
            currentStatesB &= ~pinAddress;
          }

          // change detected for INPUT PIN
          // System.out.println("<<< CHANGE >>> " + pin.getName() + " : " + state);
          dispatchPinChangeEvent(pin.getAddress(), newState);
        }
      }
    }
Example #3
0
 public GpioTriggerBase() {
   addPinState(PinState.allStates());
 }