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();
            });
        });
    }
}