1.13.0 • Published 4 months ago

raspberrypi-rotary-encoder v1.13.0

Weekly downloads
5
License
ISC
Repository
github
Last release
4 months ago

js-raspberrypi-rotary-encoder

Reliable monitoring of rotary encoders from a raspberry pi

This module allows you to monitor the rotation and the switch state of a rotary encoder from a raspberry pi. It's use shell to communicate with python awesome gaugette library.

This package has dependencies using wiringpi pins numerotation: Pinout WiringPi

Installation

Then install this module that way:

    npm install raspberrypi-rotary-encoder

Usage

See more examples into the 'examples' folder

    const Rotary = require('raspberrypi-rotary-encoder');

    // WARNING ! This is WIRINGPI pin numerotation !! please see https://fr.pinout.xyz/pinout/wiringpi#*
    const pinClk = 0;
    const pinDt = 1;
    const pinSwitch = 2;  // Optional switch

    const rotary = new Rotary(pinClk, pinDt, pinSwitch);

    rotary.on("rotate", (delta) => {
      console.log("Rotation :"+delta);
    });
    rotary.on("pressed", () => {
      console.log("Rotary switch pressed");
    });
    rotary.on("released", () => {
      console.log("Rotary switch released");
    });

API

  • constructor(pinClk, pinDt, pinSwitch).Tips: Revert the order of the two first parameters to inverse the rotary values (clock-wise/ anti clock-wise)

Events

  • rotate. Fired when you rotate your rotary encoder.
    • delta : int. The number of steps your rotary has just rotate.
  • pressed. Fired when you press the switch of your rotary encoder.
  • released. Fired when you release the switch of your rotary encoder.

Github sources

1.13.0

4 months ago

1.12.0

4 months ago

1.11.0

4 months ago

1.10.0

4 months ago

1.9.0

4 years ago

1.8.0

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago