fix pumps
Took 11 minutes
This commit is contained in:
28
src/MyGPIO.ts
Normal file
28
src/MyGPIO.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import GPIO from "rpi-gpio";
|
||||
|
||||
export class MyGPIO {
|
||||
static setup(pin: number, direction): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
GPIO.setup(pin, direction, (err) => {
|
||||
if (err) {
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
static write(pin: number, state: boolean): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
GPIO.write(pin, state, (err) => {
|
||||
if(err)
|
||||
{
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user