本文整理汇总了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);