WiringPi / WiringPi-Node

Node.js bindings to wiringPi
333 stars 94 forks source link

PWM wrapper for hardware or software PWM #92

Open michaeljanich opened 6 years ago

michaeljanich commented 6 years ago

My code is full of

    if (pin == 1 || pin == 23) {
    wpi.pinMode(pin, wpi.PWM_OUTPUT); // hardware PWM
    wpi.digitalWrite(pin, value);
    } else {
    wpi.softPwmCreate(pin, 0, value / 10.23);
    }

these if's to distinguish between software PWM and hardware PWM pins.

Is there a better solution? Like an automatic switch inside the library?

THANKS