longnanax.blogg.se

Jivelite raspberry pi rotary encoder
Jivelite raspberry pi rotary encoder








watch() this is only for demostration purposes. setup_switch ( debounce =, long_press =, sw_short_callback =, sw_long_callback = ) If you have specified the switch pin when creating the encoder object, here you can setup the debounce value, the long press option and the callbacks. setup_rotary ( min =, max =, scale =, debounce =, up_callback = down_callback = ) Here you can setup min and max values for the encoder, the increase/decrease value, a debounce value (default 300ms) and the callback functions. Optional setup for up and down rotation events setup_rotary ( min =, max =, scale =, debounce =, rotary_callback = ) Here you can setup min and max values for the encoder, the increase/decrease value, a debounce value (default 300ms) and the callback function. my_rotary = Rotary ( clk_gpio =, dt_gpio =, sw_gpio = ) If you don't pass the switch parameter the switch won't be activated. Here you setup the gpio id as keyword argument. The "long press" callback is necessary if you want to use that feature. If you intend to use the switch you must create at least the "short press" callback. def down_callback (): # some action if rotated downwardĬreate callbacks functions for the Switch def up_callback (): # some action if rotated upwardĬreate a callback function for Down-Rotation events. def rotary_callback ( counter ): # some action with counter.Ĭreate a callback function for Up-Rotation events. You must pass a positional argument to retrieve the counter value. Import the module from pigpio_encoder.rotary import RotaryĬreate a callback function for the Rotary Encoder counter.

Jivelite raspberry pi rotary encoder install#

  • python3 -mpip install pigpio_encoder (consider add -user option).
  • sudo apt-get install pigpio python-pigpio python3-pigpio.
  • Install the pigpio library (check pigpio documentation for alternative installation method).
  • Both Rotary and Switch have a customizable debounce value (default 300ms).
  • The Switch can have two different functions for short press or long press.
  • The Rotary Encoder increase/decrease value is customizable (default 1).
  • The Rotary Encoder has customizable min and max values (default 0-100).
  • Easy to setup callback functions for the Rotary Encoder and the Switch.
  • It's based on the pigpio library (cause it proved to be faster than rpi.GPIO or gpiozero libraries) so you need to install pigpio library and run pigpio daemon before starting your script. This module has been developed for quickly interface a rotary encoder with Raspberry Pi. Version: 0.2.4 Requires Python 3 Python module for the KY040 rotary encoder.








    Jivelite raspberry pi rotary encoder