本文整理了Java中com.google.android.things.pio.Gpio
类的一些代码示例,展示了Gpio
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Gpio
类的具体详情如下:
包路径:com.google.android.things.pio.Gpio
类名称:Gpio
暂无
代码示例来源: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 updatePin(Gpio pin, int value) {
try {
pin.setValue( value > 0 ? false : true);
} catch (IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: macdidi5/Android-Things-Tutorial
miniReedGpio.setDirection(Gpio.DIRECTION_IN);
miniReedGpio.setEdgeTriggerType(Gpio.EDGE_BOTH);
miniReedGpio.setActiveType(Gpio.ACTIVE_HIGH);
miniReedGpio.registerGpioCallback(new GpioCallback() {
@Override
public boolean onGpioEdge(Gpio gpio) {
代码示例来源: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: 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
public void close() throws IOException {
serialDataOutput.close();
serialDataInput.close();
serialClock.close();
chipSelect.close();
}
代码示例来源: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);
workPin.registerGpioCallback(new GpioCallback() {
@Override
public boolean onGpioEdge(Gpio gpio) {
代码示例来源:origin: macdidi5/Android-Things-Tutorial
@Override
public void run() {
if (ledGpio == null) {
return;
}
try {
// 設定GPIO狀態
ledGpio.setValue(!ledGpio.getValue());
Log.i(TAG, "LED: " + (ledGpio.getValue() ? "ON" : "OFF"));
// 1秒以後重複執行
ledHandler.postDelayed(ledRunnable, 1000);
}
catch (IOException e) {
Log.e(TAG, e.toString());
}
}
};
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
@Override
public boolean onGpioEdge(final Gpio gpio) {
if (DEBUG) {
try {
Log.e(TAG, "GPIO: " + gpio.getValue());
} catch (IOException e) {
e.printStackTrace();
}
}
notifyDigital();
return true;
}
@Override
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
if (pin != null) {
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);
gpio.setValue(false);
代码示例来源:origin: androidthings/sample-simpleui
ledPin.setEdgeTriggerType(Gpio.EDGE_NONE);
ledPin.setActiveType(Gpio.ACTIVE_HIGH);
ledPin.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
代码示例来源:origin: stefanhaustein/flowgrid
@Override
public void detach() {
try {
if (gpio != null) {
gpio.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: macdidi5/Android-Things-Tutorial
chipSelect.setValue(true);
serialClock.setValue(false);
chipSelect.setValue(false);
serialDataInput.setValue(true);
serialDataInput.setValue(false);
adcOut <<= 1;
if (serialDataOutput.getValue()) {
adcOut |= 0x1;
chipSelect.setValue(true);
代码示例来源:origin: macdidi5/Android-Things-Tutorial
@Override
public boolean onGpioEdge(Gpio gpio) {
try {
// 顯示GPIO狀態
Log.i(TAG, "Mini Reed: " + gpio.getValue());
}
catch (IOException e) {
Log.e(TAG, e.toString());
}
return true;
}
});
代码示例来源:origin: survivingwithandroid/Surviving-with-android
private void setPin(Gpio pin, String state) {
try {
pin.setValue(Boolean.parseBoolean(state));
}
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: Nilhcem/1602A-androidthings
if (rsGpio != null) {
try {
rsGpio.close();
} finally {
rsGpio = null;
rwGpio.close();
} finally {
rwGpio = null;
enableGpio.close();
} finally {
enableGpio = null;
if (dataGpios[i] != null) {
try {
dataGpios[i].close();
} finally {
dataGpios[i] = null;
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
@Override
public FaBoShield.Level getDigital(final FaBoShield.Pin pin) {
try {
Gpio gpio = mGpioMap.get(pin.getPinNumber());
if (gpio != null) {
return gpio.getValue() ? FaBoShield.Level.HIGH : FaBoShield.Level.LOW;
}
return null;
} catch (Exception e) {
return null;
}
}
代码示例来源:origin: macdidi5/Android-Things-Tutorial
private void displayNumber(int number) throws IOException {
if (number < 0 || number > 9) {
return;
}
for (int i = 0; i < gpios.length; i++) {
// 根據共陰極對照表設定針腳的狀態輸出電壓
boolean status = DisplayMap.COMMON_CATHODE[number][i] == 1;
gpios[i].setValue(status);
}
}
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!