How to use a rotary encoder for volume

On my Libre Sweet Potato AML-S905X-CC-V2, I am trying to set up a rotary encoder volume control and shown in this github:

After attempting to run the script, I get the following:

" cumulus@CUMULUS:~ $ python ~/bin/monitor-volume

Traceback (most recent call last):

File “/home/cumulus/bin/monitor-volume”, line 22, in

from RPi import GPIO

File “/usr/lib/python3/dist-packages/RPi/GPIO/init.py”, line 23, in

from RPi._GPIO import *

RuntimeError: This module can only be run on a Raspberry Pi!"

Apparently it works only for an actual Raspberry Pi board. Any idea how to make it work for a Libre? Thanks in advance.

Most rotary encoders can work with 2 GPIOs. Depending on which GPIO is triggered first on the rising edge, it provides the direction of change. This is simple to do with libgpiod so you can probably find a project on GitHub or have an AI tool generate the C code for you. Just assign the proper GPIO chip and line via libretech-wiring-tool tool for mappings (lgpio).