本文整理匯總了TypeScript中onoff.Gpio類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Gpio類的具體用法?TypeScript Gpio怎麽用?TypeScript Gpio使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Gpio類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: readPin
readPin(): When.Promise<GpioState> {
const state = this.gpio.readSync() ? true : false;
return When.resolve({
timestamp: new Date(),
bcmPinNumber: this.bcmPinNumber,
state: state
})
.tap((state) => console.log(JSON.stringify(state, null, 4)));
}
示例2: writeToPin
writeToPin(newState: boolean): When.Promise<GpioState> {
this.gpio.writeSync(newState ? 1 : 0);
return this.readPin();
}
示例3: getStatus
export function getStatus(pin: number): number {
const target = new Gpio(pin, 'out');
let status = target.readSync();
target.unexport();
return status;
}
示例4: turnOff
export function turnOff(pin: number): void {
const target = new Gpio(pin, 'out');
target.writeSync(OFF);
target.unexport();
}
示例5: toggle
export function toggle(pin: number): void {
const target = new Gpio(pin, 'out');
target.writeSync(target.readSync() === OFF ? ON : OFF);
target.unexport();
}
示例6: function
var toggleLed = function():void {
var lastState:number = led.readSync();
led.writeSync(lastState ^ 1);
};
示例7: clearInterval
setTimeout(function() {
clearInterval(intervalId);
led.writeSync(0);
led.unexport();
}, 2000);