com.google.android.things.pio.Gpio.setDirection()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中com.google.android.things.pio.Gpio.setDirection()方法的一些代码示例,展示了Gpio.setDirection()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Gpio.setDirection()方法的具体详情如下:
包路径:com.google.android.things.pio.Gpio
类名称:Gpio
方法名:setDirection

Gpio.setDirection介绍

暂无

代码示例

代码示例来源:origin: survivingwithandroid/Surviving-with-android

private void initPins() {

    try {
      bluePin = pmService.openGpio("BCM22");
      yellowPin = pmService.openGpio("BCM27");

      bluePin.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
      yellowPin.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
    }
    catch(IOException ioe) {
        ioe.printStackTrace();
    }

  }
}

代码示例来源:origin: survivingwithandroid/Surviving-with-android

private void initPin() {
  try {
    redPin = pms.openGpio("BCM26");
    redPin.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
    greenPin = pms.openGpio("BCM6");
    greenPin.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
    bluePin = pms.openGpio("BCM5");
    bluePin.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
  }
  catch (IOException ioe) {
    Log.e(TAG, "Unable to open pins");
  }
}

代码示例来源:origin: macdidi5/Android-Things-Tutorial

private void configGPIO(PeripheralManagerService service,
            String sc, String sdo, String sdi, String cs)
    throws IOException {
  serialDataOutput = service.openGpio(sdo);
  serialDataOutput.setDirection(Gpio.DIRECTION_IN);
  serialDataInput = service.openGpio(sdi);
  serialDataInput.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
  serialClock = service.openGpio(sc);
  serialClock.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
  chipSelect = service.openGpio(cs);
  chipSelect.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
}

代码示例来源:origin: macdidi5/Android-Things-Tutorial

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  Log.i(TAG, "onCreate");
  // 建立設備管理員服物物件
  PeripheralManagerService service = new PeripheralManagerService();
  try {
    // 建立GPIO物件
    ledGpio = service.openGpio(PIN_NAME);
    // 設定GPIO為輸出模式,預設為低電壓
    ledGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
    // 啟動控制LED閃爍的Handler物件
    ledHandler.post(ledRunnable);
  }
  catch (IOException e) {
    Log.e(TAG, e.toString());
  }
}

代码示例来源:origin: macdidi5/Android-Things-Tutorial

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  Log.i(TAG, "onCreate");
  // 建立設備管理員服物物件
  PeripheralManagerService service = new PeripheralManagerService();
  try {
    // 建立GPIO物件
    for (int i = 0; i < PIN_NAMES.length; i++) {
      gpios[i] = service.openGpio(PIN_NAMES[i]);
      // 設定GPIO為輸出模式,預設為低電壓
      gpios[i].setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
    }
    // 啟動控制數字顯示的Handler物件
    numberHandler.post(numberRunnable);
  }
  catch (IOException e) {
    Log.e(TAG, e.toString());
  }
}

代码示例来源:origin: macdidi5/Android-Things-Tutorial

public Gpio getPin(PiGPIO pin) throws IOException {
  if (portList.indexOf(pin.name()) == -1) {
    return null;
  }
  // 取得保存中的 GPIO 物件
  Gpio result = pins.get(pin);
  // 如果不存在
  if (result == null) {
    result = service.openGpio(pin.name());
    result.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
    pins.put(pin, result);
  }
  return result;
}

代码示例来源:origin: stefanhaustein/flowgrid

@Override
public void setValue(Object data) {
  try {
    System.out.println("SetValue: " + data);
    if (gpio == null) {
      gpio = peripheralManagerService.openGpio(name);
      gpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_HIGH);
      gpio.setActiveType(Gpio.ACTIVE_LOW);
    }
    gpio.setValue((Boolean) data);
  } catch (IOException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: Nilhcem/1602A-androidthings

rsGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
  rwGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
enableGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
  dataGpios[i].setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);

代码示例来源:origin: androidthings/sample-button

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  Log.i(TAG, "Starting ButtonActivity");
  PeripheralManager pioService = PeripheralManager.getInstance();
  try {
    Log.i(TAG, "Configuring GPIO pins");
    mLedGpio = pioService.openGpio(BoardDefaults.getGPIOForLED());
    mLedGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
  } catch (IOException e) {
    Log.e(TAG, "Error configuring GPIO pins", e);
  }
  try {
    Log.i(TAG, "Registering button driver " + BoardDefaults.getGPIOForButton());
    // Initialize and register the InputDriver that will emit SPACE key events
    // on GPIO state changes.
    mButtonInputDriver = new ButtonInputDriver(
        BoardDefaults.getGPIOForButton(),
        Button.LogicState.PRESSED_WHEN_LOW,
        KeyEvent.KEYCODE_SPACE);
    mButtonInputDriver.register();
  } catch (IOException e) {
    Log.e(TAG, "Error configuring GPIO pins", e);
  }
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

Gpio gpio = mManagerService.openGpio(name);
gpio.setEdgeTriggerType(Gpio.EDGE_NONE);
gpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
gpio.setActiveType(Gpio.ACTIVE_HIGH);
gpio.registerGpioCallback(mGpioCallback);

代码示例来源:origin: macdidi5/Android-Things-Tutorial

miniReedGpio.setDirection(Gpio.DIRECTION_IN);

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

@Override
  public void run() {
    try {
      Gpio gpio = mGpioMap.get(pin.getPinNumber());
      if (gpio != null && pin.getMode() != mode) {
        switch (mode) {
          case GPIO_IN:
            gpio.setEdgeTriggerType(Gpio.EDGE_NONE);
            gpio.setDirection(Gpio.DIRECTION_IN);
            gpio.setActiveType(Gpio.ACTIVE_HIGH);
            gpio.setEdgeTriggerType(Gpio.EDGE_BOTH);
            break;
          case GPIO_OUT:
            gpio.setEdgeTriggerType(Gpio.EDGE_NONE);
            gpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
            gpio.setActiveType(Gpio.ACTIVE_HIGH);
            break;
        }
        pin.setMode(mode);
      }
    } catch (IOException e) {
      if (DEBUG) {
        Log.w(TAG, "setPinMode", e);
      }
    }
  }
});

代码示例来源:origin: macdidi5/Android-Things-Tutorial

final String isLow) throws IOException {
Gpio workPin = gpioContainer.getPin(pin);
workPin.setDirection(Gpio.DIRECTION_IN);
workPin.setEdgeTriggerType(Gpio.EDGE_BOTH);

代码示例来源:origin: androidthings/sample-simpleui

ledPin.setEdgeTriggerType(Gpio.EDGE_NONE);
ledPin.setActiveType(Gpio.ACTIVE_HIGH);
ledPin.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);

相关文章