From 424e87023eb920279239f4eadda84325ab333c31 Mon Sep 17 00:00:00 2001 From: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> Date: Tue, 23 Apr 2024 08:33:58 +0200 Subject: [PATCH] doc: update docs. removed duplicate / obsolete examples Merged wiki page "Audio-RotaryKnobVolume" --- README.md | 2 +- components/gpio_control/README.md | 46 +++++++++++++---- .../gpio_setting_rotary_vol_prevnext.ini | 36 -------------- .../example_configs/gpio_settings.ini | 18 +++++-- .../gpio_settings_rotary_and_led.ini | 49 ------------------- .../gpio_settings_status_led.ini | 7 --- misc/sampleconfigs/gpio_settings.ini.sample | 18 +++++-- 7 files changed, 67 insertions(+), 109 deletions(-) delete mode 100755 components/gpio_control/example_configs/gpio_setting_rotary_vol_prevnext.ini delete mode 100644 components/gpio_control/example_configs/gpio_settings_rotary_and_led.ini delete mode 100644 components/gpio_control/example_configs/gpio_settings_status_led.ini diff --git a/README.md b/README.md index 3b2266d84..ebaada654 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ Check out the following references. * [PN532](components/rfid-reader/PN532/README.md) * PC/SC * also [multiple readers](https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/1012#issue-434052529) simultaneously -* [**GPIO** control](components/gpio_control/README.md) for [buttons](https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/Using-GPIO-hardware-buttons), [knobs / dials](https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/Audio-RotaryKnobVolume) and much more to control your Phoniebox via GPIO. +* [**GPIO** control](components/gpio_control/README.md) for [buttons](https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/Using-GPIO-hardware-buttons) and much more to control your Phoniebox via GPIO. * Control via smooth [**Web App**](https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/MANUAL#webapp) running on ajax from your phone, tablet or PC. You can play, upload, move files, assign new RFID cards, control playout, settings, etc. * Support for files with embedded chapters metadata (like m4a) * Customizable poweroff command diff --git a/components/gpio_control/README.md b/components/gpio_control/README.md index d3761e208..0f1b9d02b 100644 --- a/components/gpio_control/README.md +++ b/components/gpio_control/README.md @@ -24,20 +24,18 @@ Up to now the following input devices are implemented: * **ShutdownButton**: A specialized implementation for a shutdown button with integrated (but optional) LED support. It initializes a shutdown if the button is pressed more than `time_pressed` seconds and a (optional) LED on GPIO `led_pin` is flashing until that time is reached. For additional information, see [extended documentation below](#shutdownbutton). -* **RotaryEncoder**: - Control of a rotary encoder, for example KY040, see also in [Wiki](https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/Audio-RotaryKnobVolume). - It can be configured using `Pin1` and `Pin2` (use GPIO numbers here), `functionCall1`, `functionCall2` see [extended documentation below](#rotaryencoder). - * **TwoButtonControl**: This Device uses two Buttons and implements a third action if both buttons are pressed together. See [extended documentation below](#twobuttoncontrol). +* **RotaryEncoder**: + Control of a rotary encoder, for example KY040. + It can be configured using `Pin1` and `Pin2` (use GPIO numbers here), `functionCall1`, `functionCall2` see [extended documentation below](#rotaryencoder). + * **StatusLED**: A LED which will light up once the Phoniebox has fully booted up and is ready to be used. For additional information, see [extended documentation below](#statusled). Each section needs to be activated by setting `enabled: True`. -Many example files are located in `~/RPi-Jukebox-RFID/components/gpio_control/example_configs/`. - ## Extended documentation This section provides some extended documentation and guideline. Especially some exemplary configurations are introduced showing how these controls can be set up in the configuration file `~/RPi-Jukebox-RFID/settings/gpio_settings.ini`. @@ -175,8 +173,8 @@ A RotaryEncoder can be created using an `ini` entry like this: [RotaryVolumeControl] enabled: True Type: RotaryEncoder -Pin1: 7 -Pin2: 8 +Pin1: 22 +Pin2: 23 timeBase: 0.1 functionCall1: functionCallVolU functionCall2: functionCallVolD @@ -195,6 +193,15 @@ Example: * **functionCall1Args**: Arguments for `functionCall1`, defaults to `None`. If defined takes precedence over rotation value. Arguments are ignored, if `functionCall1` does not take any. * **functionCall2Args**: Arguments for `functionCall2`, defaults to `None`. If defined takes precedence over rotation value. Arguments are ignored, if `functionCall1` does not take any. +To also use the push button of the encoder just a button definition: +```bash +[Mute] +enabled: True +Type: Button +Pin: 27 +functionCall: functionCallVol0 +``` + Note that the old configuration entries PinUp/PinDown and functionCallUp/functionCallDown are deprecated and might stop working in future. @@ -202,8 +209,8 @@ Note that the old configuration entries PinUp/PinDown and functionCallUp/functio [RotatrySeekingControl] enabled: True Type: RotaryEncoder -Pin1: 7 -Pin2: 8 +Pin1: 22 +Pin2: 23 timeBase: 0.1 functionCall1: functionCallPlayerSeekFwd functionCall1Args: 5 @@ -213,6 +220,25 @@ functionCall2Args: 5 In this example, the encoder will be used to seek for- and backwards by 5 seconds on every rotation step. The rotation value will **NOT** be used in this case as the function args are defined! + +#### Circuit diagram +``` + .---------------. .---------------. + | | | | + | CLK |----------------------| GPIO 22 | + | | | | + | DT |----------------------| GPIO 23 | + | | | | + | SW |----------------------| GPIO 27 | + | | | | + | + |----------------------| 3.3V | + | | | | + | GND |----------------------| GND | + | | | | + '---------------' '---------------' + KY-040 Raspberry +``` + ### StatusLED A StatusLED can be created using an `ini` entry like this: diff --git a/components/gpio_control/example_configs/gpio_setting_rotary_vol_prevnext.ini b/components/gpio_control/example_configs/gpio_setting_rotary_vol_prevnext.ini deleted file mode 100755 index 3e829d55e..000000000 --- a/components/gpio_control/example_configs/gpio_setting_rotary_vol_prevnext.ini +++ /dev/null @@ -1,36 +0,0 @@ -[DEFAULT] -enabled: True - -[VolumeControl] -enabled: True -Type: RotaryEncoder -PinUp: 7 -PinDown: 8 -timeBase: 0.02 -functionCallDown: functionCallVolD -functionCallUp: functionCallVolU - -[PrevNextControl] -enabled: True -Type: RotaryEncoder -PinUp: 16 -PinDown: 20 -timeBase: 0.02 -functionCallDown: functionCallPlayerPrev -functionCallUp: functionCallPlayerNext - -[Shutdown] -enabled: True -Type: Button -Pin: 17 -pull_up_down: pull_down -edge: raising -functionCall: functionCallShutdown - -[PlayPause] -enabled: True -Type: Button -Pin: 25 -pull_up_down: pull_up -edge: falling -functionCall: functionCallPlayerPause diff --git a/components/gpio_control/example_configs/gpio_settings.ini b/components/gpio_control/example_configs/gpio_settings.ini index 4f84ba01b..a386d6ec6 100755 --- a/components/gpio_control/example_configs/gpio_settings.ini +++ b/components/gpio_control/example_configs/gpio_settings.ini @@ -4,20 +4,28 @@ antibouncehack: False [VolumeControl] enabled: False -Type: TwoButtonControl ;or RotaryEncoder +Type: TwoButtonControl Pin1: 5 Pin2: 6 pull_up_down: pull_up hold_time: 0.3 hold_mode: Repeat -timeBase: 0.1 ;only for RotaryEncoder functionCall1: functionCallVolU functionCall2: functionCallVolD -functionCallTwoButtons: functionCallVol0 ;only for TwoButtonControl +functionCallTwoButtons: functionCallVol0 ;functionCall1Args: 1 ;functionCall2Args: 1 ;functionCallTwoButtonsArgs: x +[RotaryVolumeControl] +enabled: False +Type: RotaryEncoder +Pin1: 22 +Pin2: 23 +timeBase: 0.1 +functionCall1: functionCallVolU +functionCall2: functionCallVolD + [PrevNextControl] enabled: False Type: TwoButtonControl @@ -143,3 +151,7 @@ pull_up_down: pull_up functionCall: functionCallTriggerPlayFolder functionCallArgs: someRelativeFolderName +[StatusLED] +enabled: False +Type: StatusLED +Pin: 14 diff --git a/components/gpio_control/example_configs/gpio_settings_rotary_and_led.ini b/components/gpio_control/example_configs/gpio_settings_rotary_and_led.ini deleted file mode 100644 index f636adbcf..000000000 --- a/components/gpio_control/example_configs/gpio_settings_rotary_and_led.ini +++ /dev/null @@ -1,49 +0,0 @@ -[DEFAULT] -enabled: True - -[VolumeControl] -enabled: True -Type: RotaryEncoder -PinUp: 17 -PinDown: 22 -pull_up_down: pull_up -timeBase: 0.2 -; only for rotary encoder -functionCallDown: functionCallVolD -functionCallUp: functionCallVolU -functionCallTwoButtons: functionCallStop -; only for TwoButtonControl -functionCallButton: functionCallPlayerPause -; only for RotaryEncoderClickable - -[PrevNextControl] -enabled: True -Type: TwoButtonControl -Pin1: 6 -Pin2: 12 -functionCall1: functionCallPlayerPrev -functionCall2: functionCallPlayerNext -functionCallTwoButtons: functionCallPlayerStop -pull_up_down: pull_up -hold_time: 0.3 -hold_mode: None - - -[Shutdown] -enabled: False -Type: Button -Pin: 3 -functionCall: functionCallShutdown - - -[PlayPause] -enabled: True -Type: Button -Pin: 27 -pull_up_down: pull_up -functionCall: functionCallPlayerPause - -[StatusLED] -enabled: True -Type: MPDStatusLED -Pin: 16 diff --git a/components/gpio_control/example_configs/gpio_settings_status_led.ini b/components/gpio_control/example_configs/gpio_settings_status_led.ini deleted file mode 100644 index 68e6461b2..000000000 --- a/components/gpio_control/example_configs/gpio_settings_status_led.ini +++ /dev/null @@ -1,7 +0,0 @@ -[DEFAULT] -enabled: True - -[StatusLED] -enabled: True -Type: StatusLED -Pin: 14 diff --git a/misc/sampleconfigs/gpio_settings.ini.sample b/misc/sampleconfigs/gpio_settings.ini.sample index 4f84ba01b..a386d6ec6 100644 --- a/misc/sampleconfigs/gpio_settings.ini.sample +++ b/misc/sampleconfigs/gpio_settings.ini.sample @@ -4,20 +4,28 @@ antibouncehack: False [VolumeControl] enabled: False -Type: TwoButtonControl ;or RotaryEncoder +Type: TwoButtonControl Pin1: 5 Pin2: 6 pull_up_down: pull_up hold_time: 0.3 hold_mode: Repeat -timeBase: 0.1 ;only for RotaryEncoder functionCall1: functionCallVolU functionCall2: functionCallVolD -functionCallTwoButtons: functionCallVol0 ;only for TwoButtonControl +functionCallTwoButtons: functionCallVol0 ;functionCall1Args: 1 ;functionCall2Args: 1 ;functionCallTwoButtonsArgs: x +[RotaryVolumeControl] +enabled: False +Type: RotaryEncoder +Pin1: 22 +Pin2: 23 +timeBase: 0.1 +functionCall1: functionCallVolU +functionCall2: functionCallVolD + [PrevNextControl] enabled: False Type: TwoButtonControl @@ -143,3 +151,7 @@ pull_up_down: pull_up functionCall: functionCallTriggerPlayFolder functionCallArgs: someRelativeFolderName +[StatusLED] +enabled: False +Type: StatusLED +Pin: 14