コード例 #1
0
  @Before
  public void setup() {
    // create a mock gpio provider and controller
    provider = MockGpioFactory.getMockProvider();
    gpio = MockGpioFactory.getInstance();

    // provision pins for testing
    inputPin = gpio.provisionDigitalInputPin(MockPin.DIGITAL_INPUT_PIN, "digitalInputPin");
    outputPin = gpio.provisionDigitalOutputPin(MockPin.DIGITAL_OUTPUT_PIN, "digitalOutputPin");

    // create triggers
    triggerHigh = new GpioSetStateTrigger(PinState.HIGH, outputPin, PinState.HIGH);
    triggerLow = new GpioSetStateTrigger(PinState.LOW, outputPin, PinState.LOW);

    // add triggers to input pin
    inputPin.addTrigger(triggerHigh);
    inputPin.addTrigger(triggerLow);
  }
コード例 #2
0
  @BeforeClass
  public static void setup() {
    // create a mock gpio provider and controller
    provider = MockGpioFactory.getMockProvider();
    gpio = MockGpioFactory.getInstance();

    // provision pins for testing
    inputPin = gpio.provisionDigitalInputPin(MockPin.DIGITAL_INPUT_PIN, "digitalInputPin");

    // create trigger
    trigger =
        new GpioCallbackTrigger(
            new Callable<Void>() {
              @Override
              public Void call() throws Exception {
                callbackCounter++;
                return null;
              }
            });

    // add trigger to input pin
    inputPin.addTrigger(trigger);
  }