How to use the pigpio.Gpio.ALT5 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
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 });
  }

pigpio

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

MIT
Latest version published 4 years ago

Package Health Score

45 / 100
Full package analysis