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.