Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mode = Gpio.ALT0;
this._pwmPort = PWM0;
break;
case 1: // GPIO18 PWM0 ALT5
gpioPin = 18;
mode = Gpio.ALT5;
this._pwmPort = PWM0;
break;
case 23: // GPIO13 PWM1 ALT0
gpioPin = 13;
mode = Gpio.ALT0;
this._pwmPort = PWM1;
break;
case 24: // GPIO19 PWM1 ALT5
gpioPin = 19;
mode = Gpio.ALT5;
this._pwmPort = PWM1;
break;
default:
throw new Error(`Pin ${pin} does not support hardware PWM`);
}
if (pwmPeripheralsInUse[this._pwmPort]) {
throw new Error(`${this._pwmPort} is already in use and cannot be used again`);
}
pwmPeripheralsInUse[this._pwmPort] = true;
this._frequencyValue = frequency;
this._dutyCycleValue = 0;
this._pwm = new Gpio(gpioPin, { mode });
}