How to use the pigpio.Gpio.ALT0 function in pigpio

To help you get started, we’ve selected a few pigpio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nebrius / raspi-pwm / src / index.ts View on Github external
let gpioPin: number;
    let mode: number;
    switch (this.pins[0]) {
      case 26: // GPIO12 PWM0 ALT0
        gpioPin = 12;
        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;

pigpio

Fast GPIO, PWM, servo control, state change notification, and interrupt handling on the Raspberry Pi

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis