Audio RotaryKnobVolume - AlvinSchiller/RPi-Jukebox-RFID GitHub Wiki

[!CAUTION] This page is outdated and will be removed in the future. Neccessary information have been integrated into https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/master/components/gpio_control/README.md.

Rotary knob for volume control (Drehknopf für Lautstärke)

Taken from the Phoniebox@GitHub issues forum

  • Tested with this rotary know hardware
  • One file in the repo is dedicated to this feature:
    • RPi-Jukebox-RFID/components/gpio_control/GPIODevices/rotary_encoder.py
  • See below in this document for info on how to change the direction of the rotary knob

Circuit diagram

(capacitors are optionally)

Tested version: Used 3.3V Pin on Raspberry Pi. Connected everything without Capacitors.

  .---------------.                      .---------------.
  |               |                      |               |
  |           CLK |------o---------------| GPIO 5        |
  |               |      |               |               |
  |           DT  |------)----o----------| GPIO 6        |
  |               |      |    |          |               |
  |           SW  |      |    |          |               |
  |               |      |    |          |               |
  |           +   |------)----)----------| 3.3V          |
  |               |      |    |          |               |
  |           GND |------)----)----------| GND           |
  |               |      |    |          |               |
  '---------------'      |    |          '---------------'
       KY-040            |    |              Raspberry
                         |    |
                        ---  ---
                  100nF ---  --- 100nF
                         |    |
                         |    |
                         |    |
                        ===  ===
                        GND  GND

Once you've got the hardware done, start the configuration:

You need to edit settings/gpio_buttons.ini.

After editing the config file, restart the service: sudo systemctl restart phoniebox-gpio-control

The scripts now also provide support for a second knob to navigate through the tracks of a folder. Please not that you may use the switch also for other functionality. See the pin out page for details.

Changing the rotary direction

If you want to swap clockwise and counter clockwise, you can edit the code. This is the original:

def rotaryChangeCWVol(steps):
    check_call("./scripts/playout_controls.sh -c=**volumeup** -v="+str(steps), shell=True)
def rotaryChangeCCWVol(steps):
    check_call("./scripts/playout_controls.sh -c=**volumedown** -v="+str(steps), shell=True)

And this is the version with the behaviour in the opposite direction:

def rotaryChangeCWVol(steps):
    check_call("./scripts/playout_controls.sh -c=**volumedown** -v="+str(steps), shell=True)
def rotaryChangeCCWVol(steps):
    check_call("./scripts/playout_controls.sh -c=**volumeup** -v="+str(steps), shell=True)