本文整理了Java中com.google.android.things.pio.Gpio.setValue()
方法的一些代码示例,展示了Gpio.setValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Gpio.setValue()
方法的具体详情如下:
包路径:com.google.android.things.pio.Gpio
类名称:Gpio
方法名:setValue
暂无
代码示例来源: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: survivingwithandroid/Surviving-with-android
private void setPin(Gpio pin, String state) {
try {
pin.setValue(Boolean.parseBoolean(state));
}
catch (IOException ioe) {
ioe.printStackTrace();
}
}
代码示例来源: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 tickPin(Gpio pin) throws IOException {
pin.setValue(true);
pin.setValue(false);
}
代码示例来源:origin: androidthings/sample-button
/**
* Update the value of the LED output.
*/
private void setLedValue(boolean value) {
try {
mLedGpio.setValue(value);
} catch (IOException e) {
Log.e(TAG, "Error updating GPIO value", e);
}
}
代码示例来源:origin: Nilhcem/1602A-androidthings
private void pulseEnable() throws IOException {
enableGpio.setValue(false);
delayMicroseconds(1);
enableGpio.setValue(true);
delayMicroseconds(1); // enable pulse must be >450ns
enableGpio.setValue(false);
delayMicroseconds(100); // commands need > 37us to settle
}
代码示例来源:origin: Nilhcem/1602A-androidthings
private void write8bits(int value) throws IOException {
for (int i = 0; i < 8; i++) {
dataGpios[i].setValue(((value >> i) & 0x01) != 0);
}
pulseEnable();
}
代码示例来源:origin: Nilhcem/1602A-androidthings
private void write4bits(int value) throws IOException {
for (int i = 0; i < 4; i++) {
dataGpios[i].setValue(((value >> i) & 0x01) != 0);
}
pulseEnable();
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
@Override
public void writeDigital(final FaBoShield.Pin pin, final FaBoShield.Level hl) {
try {
Gpio gpio = mGpioMap.get(pin.getPinNumber());
if (gpio != null) {
gpio.setValue(hl == FaBoShield.Level.HIGH);
}
} catch (Exception e) {
if (DEBUG) {
Log.w(TAG, "", e);
}
}
}
代码示例来源:origin: macdidi5/Android-Things-Tutorial
chipSelect.setValue(true);
serialClock.setValue(false);
chipSelect.setValue(false);
serialDataInput.setValue(true);
serialDataInput.setValue(false);
chipSelect.setValue(true);
代码示例来源: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: Nilhcem/1602A-androidthings
/************
* low level data pushing commands
**********/
// write either command or data, with automatic 4/8-bit selection
private void send(int value, boolean rsValue) throws IOException {
rsGpio.setValue(rsValue);
// if there is a RW pin indicated, set it low to Write
if (rwGpio != null) {
rwGpio.setValue(false);
}
if ((displayfunction & LCD_8BITMODE) == 0) {
write4bits(value >> 4);
write4bits(value);
} else {
write8bits(value);
}
}
代码示例来源: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: androidthings/sample-simpleui
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
try {
ledPin.setValue(isChecked);
} catch (IOException e) {
Log.e(TAG, "error toggling gpio:", e);
buttonView.setOnCheckedChangeListener(null);
// reset button to previous state.
buttonView.setChecked(!isChecked);
buttonView.setOnCheckedChangeListener(this);
}
}
});
代码示例来源:origin: macdidi5/Android-Things-Tutorial
@Override
public void onDataChange(DataSnapshot ds) {
PiGPIO pin = PiGPIO.getPiGPIO(ds.getKey());
if (pin == null) {
return;
}
Log.d(TAG, pin.name() + ":" + ds.getValue());
try {
// 取得 GPIO 物件
Gpio workPin = gpioContainer.getPin(pin);
// 讀取雲端資料
boolean status = (Boolean) ds.getValue();
// 設定 GPIO
workPin.setValue(status);
}
catch (IOException e) {
Log.e(TAG, e.toString());
}
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
gpio.setActiveType(Gpio.ACTIVE_HIGH);
gpio.registerGpioCallback(mGpioCallback);
gpio.setValue(false);
代码示例来源:origin: Nilhcem/1602A-androidthings
rsGpio.setValue(false);
enableGpio.setValue(false);
if (rwGpio != null) {
rwGpio.setValue(false);
内容来源于网络,如有侵权,请联系作者删除!