[PLUGIN] RotaryEncoder II

Hi Valdemir,
I‘m using it on my system, which runs on 3.703
Cannot confirm your statement.
Can you provide more info?

Hey there,

I switched to RPi5 using NVMe SSD working perfectly except the Rotatory Encoder II Plugin. The Hardware Setup worked with the RPi4 and there are no changes on this site. The Rotatory Part of the Plugin works (next/previous) but there’s no Function for the Button.

There seems to be a Problem with Triggerhappy

volumio : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/dtoverlay rotary-encoder pin_a=18 pin_b=17 relative_axis=true steps-per-period=1
pam_unix(sudo:session): session opened for user root by (uid=0)
rotary-encoder rotary@12: gray
input: rotary@12 as /devices/platform/rotary@12/input/input11
pam_unix(sudo:session): session closed for user root
Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
info: CALLMETHOD: system_hardware rotaryencoder2 updateEncoder [object Object]
info: CoreCommandRouter::executeOnPlugin: rotaryencoder2 , updateEncoder
 volumio : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/dtoverlay -l
pam_unix(sudo:session): session opened for user root by (uid=0)
pam_unix(sudo:session): session closed for user root
 volumio : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/dtoverlay -r 0
pam_unix(sudo:session): session opened for user root by (uid=0)
pam_unix(sudo:session): session closed for user root
 volumio : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/dtoverlay -l
pam_unix(sudo:session): session opened for user root by (uid=0)
pam_unix(sudo:session): session closed for user root
 volumio : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/dtoverlay rotary-encoder pin_a=18 pin_b=17 relative_axis=true steps-per-period=1
pam_unix(sudo:session): session opened for user root by (uid=0)
rotary-encoder rotary@12: gray
input: rotary@12 as /devices/platform/rotary@12/input/input12
pam_unix(sudo:session): session closed for user root
Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
export_store: invalid GPIO 27

running:

'/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev'

seperately gives a “Segmentation fault” so there seems to be the problem.

Does anyone have a Start or Idee what to do ?

Thanks,
Julian

Oh, I found the solution…

Reading the Rotatory Encoder II source code I saw that for the buttons the npm Package “onoff” is used which reads GPIO Labels. RPi5 changed the names of the GPIO Pins. So just translate the desired “old” GPIO pin (for e.x. GPIO 27) into Board PIN (GPIO 27 = PIN 13) and then get the right GPIO label from the table below (GPIO 27 (non RPi5) = PIN 13 = gpio-426 (RPi 5) so in this case only enter “426” as GPIO Value).

sudo cat /sys/kernel/debug/gpio
[sudo] password for volumio:
gpiochip4: GPIOs 399-452, parent: platform/1f000d0000.gpio, pinctrl-rp1:
 gpio-399 (ID_SD               )
 gpio-400 (ID_SC               )
 gpio-401 (PIN3                )
 gpio-402 (PIN5                )
 gpio-403 (PIN7                )
 gpio-404 (PIN29               )
 gpio-405 (PIN31               )
 gpio-406 (PIN26               )
 gpio-407 (PIN24               )
 gpio-408 (PIN21               )
 gpio-409 (PIN19               )
 gpio-410 (PIN23               )
 gpio-411 (PIN32               )
 gpio-412 (PIN33               )
 gpio-413 (PIN8                )
 gpio-414 (PIN10               )
 gpio-415 (PIN36               )
 gpio-416 (PIN11               |rotary@12           ) in  hi
 gpio-417 (PIN12               |rotary@12           ) in  hi
 gpio-418 (PIN35               )
 gpio-419 (PIN38               )
 gpio-420 (PIN40               )
 gpio-421 (PIN15               )
 gpio-422 (PIN16               )
 gpio-423 (PIN18               )
 gpio-424 (PIN22               )
 gpio-425 (PIN37               )
 gpio-426 (PIN13               )
 gpio-427 (PCIE_RP1_WAKE       )
 gpio-428 (FAN_TACH            )
 gpio-429 (HOST_SDA            )
 gpio-430 (HOST_SCL            )
 gpio-431 (ETH_RST_N           |phy-reset           ) out hi ACTIVE LOW
 gpio-432 (-                   )
 gpio-433 (CD0_IO0_MICCLK      |cam0_reg            ) out lo
 gpio-434 (CD0_IO0_MICDAT0     )
 gpio-435 (RP1_PCIE_CLKREQ_N   )
 gpio-436 (-                   )
 gpio-437 (CD0_SDA             )
 gpio-438 (CD0_SCL             )
 gpio-439 (CD1_SDA             )
 gpio-440 (CD1_SCL             )
 gpio-441 (USB_VBUS_EN         )
 gpio-442 (USB_OC_N            )
 gpio-443 (RP1_STAT_LED        |PWR                 ) out hi ACTIVE LOW
 gpio-444 (FAN_PWM             )
 gpio-445 (CD1_IO0_MICCLK      |cam1_reg            ) out lo
 gpio-446 (2712_WAKE           )
 gpio-447 (CD1_IO1_MICDAT1     )
 gpio-448 (EN_MAX_USB_CUR      )
 gpio-449 (-                   )
 gpio-450 (-                   )
 gpio-451 (-                   )
 gpio-452 (-                   )

gpiochip3: GPIOs 453-458, parent: platform/107d517c00.gpio, gpio-brcmstb@107d517c20:
 gpio-453 (HDMI0_SCL           )
 gpio-454 (HDMI0_SDA           )
 gpio-455 (HDMI1_SCL           )
 gpio-456 (HDMI1_SDA           )
 gpio-457 (PMIC_SCL            )
 gpio-458 (PMIC_SDA            )

gpiochip2: GPIOs 459-475, parent: platform/107d517c00.gpio, gpio-brcmstb@107d517c00:
 gpio-459 (RP1_SDA             )
 gpio-460 (RP1_SCL             )
 gpio-461 (RP1_RUN             |RP1 RUN pin         ) out hi
 gpio-462 (SD_IOVDD_SEL        |vdd-sd-io           ) out lo
 gpio-463 (SD_PWR_ON           |sd_vcc_reg          ) out lo
 gpio-464 (SD_CDET_N           )
 gpio-465 (SD_FLG_N            )
 gpio-466 (-                   )
 gpio-467 (2712_WAKE           )
 gpio-468 (2712_STAT_LED       |ACT                 ) out hi ACTIVE LOW
 gpio-469 (-                   )
 gpio-470 (-                   )
 gpio-471 (PMIC_INT            )
 gpio-472 (UART_TX_FS          )
 gpio-473 (UART_RX_FS          )
 gpio-474 (-                   )
 gpio-475 (-                   )

gpiochip1: GPIOs 476-479, parent: platform/107d508500.gpio, gpio-brcmstb@107d508520:
 gpio-476 (WIFI_SDIO_D0        )
 gpio-477 (WIFI_SDIO_D1        )
 gpio-478 (WIFI_SDIO_D2        )
 gpio-479 (WIFI_SDIO_D3        )
gpiochip0: GPIOs 480-511, parent: platform/107d508500.gpio, gpio-brcmstb@107d508500:
 gpio-480 (-                   )
 gpio-481 (2712_BOOT_CS_N      |spi10 CS0           ) out hi ACTIVE LOW
 gpio-482 (2712_BOOT_MISO      )
 gpio-483 (2712_BOOT_MOSI      )
 gpio-484 (2712_BOOT_SCLK      )
 gpio-485 (-                   )
 gpio-486 (-                   )
 gpio-487 (-                   )
 gpio-488 (-                   )
 gpio-489 (-                   )
 gpio-490 (-                   )
 gpio-491 (-                   )
 gpio-492 (-                   )
 gpio-493 (-                   )
 gpio-494 (PCIE_SDA            )
 gpio-495 (PCIE_SCL            )
 gpio-496 (-                   )
 gpio-497 (-                   )
 gpio-498 (-                   )
 gpio-499 (-                   )
 gpio-500 (PWR_GPIO            |pwr_button          ) in  hi ACTIVE LOW
 gpio-501 (2712_G21_FS         )
 gpio-502 (-                   )
 gpio-503 (-                   )
 gpio-504 (BT_RTS              )
 gpio-505 (BT_CTS              )
 gpio-506 (BT_TXD              )
 gpio-507 (BT_RXD              )
 gpio-508 (WL_ON               |wl_on_reg           ) out hi
 gpio-509 (BT_ON               |shutdown            ) out hi
 gpio-510 (WIFI_SDIO_CLK       )
 gpio-511 (WIFI_SDIO_CMD       )
1 Like

Hi wheatens! Mind me to ask if the switch on rotary encoder can use for power on the pi? Or still use for off and reboot?

On a rpi5 it will work as this has 2 pins to connect a physical switch. Lower version don’t have this. You can code to shutdown or use the Rotary encoder option, but it won’t give you a startup as there is no HW for it. (you would also need to wire the reset or buy a power module for it)

On a rPi5, as used on my test device:
image

I see, can you show me what start up module looks like?

If I only knew what your asking :grinning:

Guess you mean something like this:

dear @T0MR0

with the beta image for Raspberry Pi (where the kernel has been updated to 6.6.x) your plugin does not work anymore. On kernel 6.6.x, the GPIO numbering has changed, so the plugin should be adapted to have it working again

an attempt was made for trying to fix the issue, but unfortunately it does not work

the rotary part works, but the button press doesn’t

any chance you can have a look and fix this?
until we don’t have all the plugin working on kernel 6.6.x, we cannot promote the beta to stable

Hi,
already was actively triggered and worked on it the last days - I just created two pull-requests for an updated version of both my plugins.
The RotaryEncoder2 PR however is suffering from an issue with volumio plugin submit, where I get an error, which I cannot find the reason for:

Compressing the plugin 
Plugin succesfully compressed 
Error adding plugin: Error: got 401 response

This would mean unauthorized but I am not doing it different for this plugin compared to the other - so no idea how to fix.

In the update I completely removed the references to onoff and use the buttons now in the same way I use the rotaries by just loading the kernel drivers for buttons with device tree overlays.
Tested on RPi5 with Volumio 0.012 and also on RPi4 with Volumio 3.733 - both working.

(This should also fix some of the problems reported in this thread earlier (apologies, I had a tough year and not much time for hobbies)).

Dear @T0MR0

many thanks for your quick response

Could you please send another PR for the buster plugin repo, increasing the version number to something higher than 1.1.22 (that is the version of the experiment mentioned before)?
On the buster plugin, the required node and volumio version should be as the latest stable:

node: >=14.15.4 <15.0.0
volumio: >=3.179.0 <4.0.0

@balbuze this is similar to what other plugin developer had, how was it solved?

Awesome, this should be good for both buster on kernel 6.6 and bookworm. Only one question: did you test with 3.733 or with the latest beta 3.771?

We have to change the owner of the plugin in firebase.
I can’t do it now. This evening. Or @volumio ?

Please retry now, it should be ok

works - thanks!
I just submitted with plugin submit and commited a new PR to fix a small bug that sneaked in during debugging
PR #15 on Bookworm

I just created a PR on Buster repo as well under #367
I updated to last stable version for testing now 3.757 - Since my most complex test system is in heavy use, I try to avoid beta versions, but if necessary, I can also test 3.771 if absolutely necessary - just let me know.

@T0MR0 just updated to your latest beta, rotary encoder ll plugin v1.1.23 on system v3.772 beta.

push button now okay.
only small error when switching on and off. I don’t know if that has to do with your plugin.
raspberry pi 3 and 5, rotary encoder type: KY-040.

@T0MR0 no problem, I can also test it, many thanks for taking care!

it works like a charm, well done!

@balbuze could you please promote the version 1.1.23 as stable?

1 Like

done!

If you can make a log like described here I can have a look

sorry for the late response.
will try to explain what is happening.

After a reboot, I turn off the rotary plugin and turn it back on after a few seconds, everything is okay, the rotary works.
now I switch the infrared plugin off and on again (also error- see screenshot) at that moment the rorary encoder no longer works.
turn the rotary encoder off and on again and it works as it should again, it does give an error but it goes away too quickly to take a screenshot.
The problem now is that the infrared no longer works.
so turn one off and on then the other no longer works and reboot is the only solution to get this right again.
I have enabled logging in your rotary encoder plugin settings and hope the error is visible in the attached log.

http://logs.volumio.org/volumio/wd8Qmcm.html

raspberry pi 5, 4gb model.
rotary encoder KY-040, plug-in version 1.1.23.
volumio systeem version, 3.779.

same problem on a raspberry pi3, same type of rotary encoder.

Fault turn off infrared plugin.