From 53b6c79e035f302897357bde1177846d432c5834 Mon Sep 17 00:00:00 2001 From: jacques42 Date: Sat, 26 Jun 2021 00:05:44 +0200 Subject: [PATCH] remote-buzzer: enable buttons and rotary parallel use --- config/config.inc.php | 5 +- faq/faq.md | 61 +++++++++------ install-raspbian.sh | 2 +- lib/configsetup.inc.php | 40 +++++++--- lib/services_start.php | 2 +- livechroma.php | 5 ++ resources/lang/en.json | 8 +- src/js/core.js | 32 +++++--- src/js/remotebuzzer_client.js | 135 ++++++++++++++++++++++++---------- src/js/remotebuzzer_server.js | 42 ++++++----- 10 files changed, 228 insertions(+), 104 deletions(-) diff --git a/config/config.inc.php b/config/config.inc.php index 2de027a03..19d540927 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -228,9 +228,12 @@ // R E M O T E B U Z Z E R -$config['remotebuzzer']['enabled'] = false; +$config['remotebuzzer']['usebuttons'] = false; $config['remotebuzzer']['userotary'] = false; $config['remotebuzzer']['enable_standalonegallery'] = false; +$config['remotebuzzer']['rotaryclkgpio'] = 27; +$config['remotebuzzer']['rotarydtgpio'] = 17; +$config['remotebuzzer']['rotarybtngpio'] = 22; $config['remotebuzzer']['picturebutton'] = true; // collagetime controls the time to distinguish picture from collage in seconds $config['remotebuzzer']['collagetime'] = '2'; diff --git a/faq/faq.md b/faq/faq.md index c7edadc5b..ba0cafacd 100644 --- a/faq/faq.md +++ b/faq/faq.md @@ -116,12 +116,12 @@ Follow the steps mentioned here: [How to Fix NGINX 413 Request Entity Too Large Yes, the **Hardware Button** feature enables to control Photobooth through hardware buttons connected to Raspberry GPIO pins . This works for directly connected screens and as well for WLAN connected screen (i.e. iPad). Configuration takes place in the admin settings - Hardware Button section. The Hardware Button functionality supports two separate modes of operation (select via admin panel): -- **Button Mode**: Distinct hardware buttons can be connected to distinct GPIOs. Each button will trigger a separate functionality (i.e. take photo). -- **Rotary Mode**: A rotary encoder connected to GPIOs will drive the input on the screen. This enables to use the rotary to scroll through the Photobooth UI buttons, and click to select actions. +- **Buttons**: Distinct hardware buttons can be connected to distinct GPIOs. Each button will trigger a separate functionality (i.e. take photo). +- **Rotary Encoder**: A rotary encoder connected to GPIOs will drive the input on the screen. This enables to use the rotary to scroll through the Photobooth UI buttons, and click to select actions. -Modes can not be combined. +Both buttons and rotary encoder controls can be combined. -In any mode, Photobooth will watch GPIOs for a PIN_DOWN event - so the hardware button needs to pull the GPIO to ground, for to trigger. This requires the GPIOs to be configured in PULLUP mode - always. +Photobooth will watch GPIOs for a PIN_DOWN event - so the hardware button needs to pull the GPIO to ground, for to trigger. This requires the GPIOs to be configured in PULLUP mode - always. Troubleshooting / Debugging: @@ -135,7 +135,7 @@ Troubleshooting / Debugging: - GPIOs may not be configured as PULLUP. The configuration for this is done in fie `/boot/config.txt` by adding the GPIO numbers in use as follows - you **must reboot** the Raspberry Pi in order to activate changes in this setting. ``` - gpio=16,20,21,26=pu + gpio=16,17,20,21,22,26,27=pu ``` - For the Shutdown button to work, `www-data` needs to have the necessary sudo permissions. This is done by the `install-raspian.sh` script or can be manually added as @@ -149,10 +149,10 @@ Troubleshooting / Debugging: As of Photobooth v3, hardware button support is fully integrated into Photobooth. Therefore the `button.py` script has been removed from the distribution. In case you are using this script and for continued backward compatibility please do not activate the Remote Buzzer Hardware Button feature in the admin GUI. Please note that continued backward compatibility is not guaranteed and in case of issues please switch to the integrated functionality. -*************** -**Button Mode** -*************** -The server supports up to three connected hardware buttons for the following functionalities: +****************** +**Button Support** +****************** +The server supports up to four connected hardware buttons for the following functionalities: 1) **Picture Button** @@ -183,24 +183,43 @@ Note: - Hold the button for a defined time to initiate the shut down (defaults to 5 seconds). This can be adjusted in the admin settings. - The shutdown button will only trigger if there is currently no action in progress in Photobooth (picture, collage). +4) **Print Button** + +- Defaults to GPIO26 +- This button will initiate a print of the current picture either from the results screen or the gallery. + + After any button is triggered, all hardware button remain disabled until the action (picture / collage) completed. Once completed, the hardware buttons re-arms / are active again. -*************** -**Rotary Mode** -*************** -In rotary mode a rotary encoder (i.e. [KY-040](https://sensorkit.en.joy-it.net/index.php?title=KY-040_Rotary_encoder)) is connected to the GPIOs. Turning the rotary left / right will navigate through the currently visible set of buttons on the screen. Button press on the rotary will activate the currently highlighted button in Photobooth. +The wiring layout is + +``` +Button Raspberry + +Picture --- GPIO 21 +Collage --- GPIO 20 +Shutdown --- GPIO 16 +Print --- GPIO 26 +All --- GND +``` + + +****************** +**Rotary Encoder** +****************** +A rotary encoder (i.e. [KY-040](https://sensorkit.en.joy-it.net/index.php?title=KY-040_Rotary_encoder)) is connected to the GPIOs. Turning the rotary left / right will navigate through the currently visible set of buttons on the screen. Button press on the rotary will activate the currently highlighted button in Photobooth. The wiring layout is ``` -Button Rotary Encoder -Mode Raspberry Mode +Rotary +Encoder Raspberry -Picture --- GPIO 21 --- DT -Collage --- GPIO 20 --- CLK -Shutdown --- GPIO 16 --- SW - 3V3 --- + - GND --- GND +CLK --- GPIO 27 +DT --- GPIO 17 +BTN --- GPIO 22 ++ --- 3V3 +GND --- GND ``` Known limitations: @@ -215,7 +234,7 @@ Other Remote Trigger (experimental) ************** The trigger server controls and coordinates sending commands via socket.io to the photobooth client. Next to a hardware button, any socket.io client can connect to the trigger server over the network, and send a trigger command. This gives full flexibility to integrate other backend systems for trigger signals. -- Channel: `photobooth-socket` +- Channel: `photobooth-socket` - Commands: `start-picture`, `start-collage` - Response: `completed` will be emitted to the client, once photobooth finished the task diff --git a/install-raspbian.sh b/install-raspbian.sh index c63b13d37..7912d5441 100755 --- a/install-raspbian.sh +++ b/install-raspbian.sh @@ -347,7 +347,7 @@ fi sed -i '/Photobooth/,/Photobooth End/d' /boot/config.txt cat >> /boot/config.txt << EOF # Photobooth -gpio=16,20,21,26=pu +gpio=16,17,20,21,22,26,27=pu # Photobooth End EOF # add configuration required for www-data to be able to initiate system shutdown diff --git a/lib/configsetup.inc.php b/lib/configsetup.inc.php index 01252a6aa..39b15360f 100644 --- a/lib/configsetup.inc.php +++ b/lib/configsetup.inc.php @@ -1311,11 +1311,11 @@ 'remotebuzzer' => [ 'view' => 'advanced', 'platform' => 'linux', - 'remotebuzzer_enabled' => [ + 'remotebuzzer_usebuttons' => [ 'view' => 'advanced', 'type' => 'checkbox', - 'name' => 'remotebuzzer[enabled]', - 'value' => $config['remotebuzzer']['enabled'], + 'name' => 'remotebuzzer[usebuttons]', + 'value' => $config['remotebuzzer']['usebuttons'], ], 'remotebuzzer_userotary' => [ 'view' => 'advanced', @@ -1323,13 +1323,6 @@ 'name' => 'remotebuzzer[userotary]', 'value' => $config['remotebuzzer']['userotary'], ], - 'remotebuzzer_enable_standalonegallery' => [ - 'view' => 'expert', - 'type' => 'checkbox', - 'name' => 'remotebuzzer[enable_standalonegallery]', - 'value' => $config['remotebuzzer']['enable_standalonegallery'], - ], - 'remotebuzzer_picturebutton' => [ 'view' => 'advanced', 'type' => 'checkbox', @@ -1404,6 +1397,33 @@ 'range_step' => 1, 'unit' => 'seconds', ], + 'remotebuzzer_rotaryclkgpio' => [ + 'view' => 'expert', + 'type' => 'hidden', + 'placeholder' => $defaultConfig['remotebuzzer']['rotaryclkgpio'], + 'name' => 'remotebuzzer[rotaryclkgpio]', + 'value' => $config['remotebuzzer']['rotaryclkgpio'], + ], + 'remotebuzzer_rotarydtgpio' => [ + 'view' => 'expert', + 'type' => 'hidden', + 'placeholder' => $defaultConfig['remotebuzzer']['rotarydtgpio'], + 'name' => 'remotebuzzer[rotarydtgpio]', + 'value' => $config['remotebuzzer']['rotarydtgpio'], + ], + 'remotebuzzer_rotarybtngpio' => [ + 'view' => 'expert', + 'type' => 'hidden', + 'placeholder' => $defaultConfig['remotebuzzer']['rotarybtngpio'], + 'name' => 'remotebuzzer[rotarybtngpio]', + 'value' => $config['remotebuzzer']['rotarybtngpio'], + ], + 'remotebuzzer_enable_standalonegallery' => [ + 'view' => 'expert', + 'type' => 'checkbox', + 'name' => 'remotebuzzer[enable_standalonegallery]', + 'value' => $config['remotebuzzer']['enable_standalonegallery'], + ], 'remotebuzzer_logfile' => [ 'view' => 'expert', 'type' => 'hidden', diff --git a/lib/services_start.php b/lib/services_start.php index 4c497f508..f2a7a3498 100644 --- a/lib/services_start.php +++ b/lib/services_start.php @@ -15,7 +15,7 @@ function processIsRunning($pName, $pidFile) { return count($output) - 1 ? true : false; // true if process is active } -if ($config['remotebuzzer']['enabled']) { +if ($config['remotebuzzer']['usebuttons'] || $config['remotebuzzer']['userotary']) { $connection = @fsockopen('127.0.0.1', $config['remotebuzzer']['port']); if (!is_resource($connection)) { diff --git a/livechroma.php b/livechroma.php index 13e95e8c0..e8b3b13b1 100644 --- a/livechroma.php +++ b/livechroma.php @@ -173,5 +173,10 @@ + + + diff --git a/resources/lang/en.json b/resources/lang/en.json index f5e9d68ee..8563b604e 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -363,14 +363,14 @@ "manual:remotebuzzer:remotebuzzer_collagebutton": "For COLLAGE connect the hardware button to GPIO20. Pull GPIO to ground for to trigger. If enabled, long-press on PICTURE button will not trigger collage.", "manual:remotebuzzer:remotebuzzer_collagetime": "If PICTURE button pressed less than seconds here, a picture is triggered. If pressed more seconds than here, a collage is triggered. Only works if collage is enabled in the admin settings and the collage button is disbaled.", "manual:remotebuzzer:remotebuzzer_enable_standalonegallery": "Controls whether the rotary encoder is active on the standalone gallery view.", - "manual:remotebuzzer:remotebuzzer_enabled": "This feature enables hardware button support through Raspberry GPIO pins. IMPORTANT: For WLAN connected screens you must make sure to configure the IP address of the Photobooth web server in the section \"General\", for this feature to work properly.", "manual:remotebuzzer:remotebuzzer_logfile": "In Dev-Mode server debugging information will be written to the logfile, located in the tmp folder and defaults to io_server.log.", "manual:remotebuzzer:remotebuzzer_picturebutton": "For PICTURE connect the hardware button to GPIO21. Pull GPIO to ground for to trigger. Long-press will trigger COLLAGE, if enabled and Collage hardware button is disabled.", "manual:remotebuzzer:remotebuzzer_port": "Server TCP Port - example 14711.", "manual:remotebuzzer:remotebuzzer_printbutton": "For PRINT connect the hardware button to GPIO26. Pull GPIO to ground for to trigger.", "manual:remotebuzzer:remotebuzzer_shutdownbutton": "For SHUTDOWN connect the hardware button to GPIO16. Pull GPIO to ground for to trigger. Hold 5 sec (default) to trigger.", "manual:remotebuzzer:remotebuzzer_shutdownholdtime": "Seconds to hold button until system shutdown will be initiated. Setting to Zero (0) means immediate shutdown without waiting time.", - "manual:remotebuzzer:remotebuzzer_userotary": "Switch to Rotary Encoder mode for to navigate the screen. Needs a rotary encoder switch connected to the GPIOs - see FAQ for details", + "manual:remotebuzzer:remotebuzzer_usebuttons": "This feature enables hardware button support through Raspberry GPIO pins - see FAQ for details. IMPORTANT: For WLAN connected screens you must make sure to configure the IP address of the Photobooth web server in the section \"General\", for this feature to work properly.", + "manual:remotebuzzer:remotebuzzer_userotary": "Enable Rotary Encoder support for to navigate the screen. Needs a rotary encoder switch connected to the GPIOs - see FAQ for details. IMPORTANT: For WLAN connected screens you must make sure to configure the IP address of the Photobooth web server in the section \"General\", for this feature to work properly.", "manual:reset:reset_button": "Will execute config reset. If you like to also reset images and / or the mail address database make sure you first activate those settings and save (!) the config, then perform the config reset itself.", "manual:reset:reset_remove_config": "If enabled, personal config gets removed on reset.", "manual:reset:reset_remove_images": "If enabled, all images gets removed on reset.", @@ -476,14 +476,14 @@ "remotebuzzer:remotebuzzer_collagebutton": "Collage Button", "remotebuzzer:remotebuzzer_collagetime": "Seconds to trigger collage", "remotebuzzer:remotebuzzer_enable_standalonegallery": "Rotary for standalone gallery", - "remotebuzzer:remotebuzzer_enabled": "Enable Hardware Button Support", "remotebuzzer:remotebuzzer_logfile": "Logfile", "remotebuzzer:remotebuzzer_picturebutton": "Picture Button", "remotebuzzer:remotebuzzer_port": "Server Port", "remotebuzzer:remotebuzzer_printbutton": "Print Button", "remotebuzzer:remotebuzzer_shutdownbutton": "Shutdown Button", "remotebuzzer:remotebuzzer_shutdownholdtime": "Seconds to initiate shutdown", - "remotebuzzer:remotebuzzer_userotary": "Rotary Encoder Mode", + "remotebuzzer:remotebuzzer_usebuttons": "Enable Hardware Buttons", + "remotebuzzer:remotebuzzer_userotary": "Enable Rotary Encoder", "reset": "Reset", "reset:reset_button": "Execute config reset", "reset:reset_remove_config": "Delete personal configuration (my.config.inc.php)", diff --git a/src/js/core.js b/src/js/core.js index cda61cdb0..572e0384f 100644 --- a/src/js/core.js +++ b/src/js/core.js @@ -1,4 +1,4 @@ -/* globals initPhotoSwipeFromDOM initRemoteBuzzerFromDOM i18n setMainImage remoteBuzzerClient rotaryController */ +/* globals initPhotoSwipeFromDOM initRemoteBuzzerFromDOM i18n setMainImage remoteBuzzerClient rotaryController globalGalleryHandle */ const photoBooth = (function () { // vars @@ -324,6 +324,7 @@ const photoBooth = (function () { api.closeNav(); api.reset(); api.showResultInner(false); + api.closeGallery(); remoteBuzzerClient.inProgress(true); @@ -859,6 +860,24 @@ const photoBooth = (function () { }, 300); }; + // close Gallery Overview and Slideshow if visible + api.closeGallery = function () { + if (typeof globalGalleryHandle !== 'undefined') { + globalGalleryHandle.close(); + } + + gallery.find('.gallery__inner').hide(); + gallery.removeClass('gallery--open'); + + api.showResultInner(true); + + if ($('#result').is(':visible')) { + rotaryController.focusSet('#result'); + } else if ($('#start').is(':visible')) { + rotaryController.focusSet('#start'); + } + }; + api.resetMailForm = function () { $('#send-mail-form').trigger('reset'); $('#mail-form-message').html(''); @@ -1066,16 +1085,7 @@ const photoBooth = (function () { $('.gallery__close').on('click', function (e) { e.preventDefault(); - gallery.find('.gallery__inner').hide(); - gallery.removeClass('gallery--open'); - - api.showResultInner(true); - - if ($('#result').is(':visible')) { - rotaryController.focusSet('#result'); - } else if ($('#start').is(':visible')) { - rotaryController.focusSet('#start'); - } + api.closeGallery(); }); $('.mailbtn').on('click touchstart', function (e) { diff --git a/src/js/remotebuzzer_client.js b/src/js/remotebuzzer_client.js index 409e4f1f8..50e8fd251 100644 --- a/src/js/remotebuzzer_client.js +++ b/src/js/remotebuzzer_client.js @@ -3,15 +3,19 @@ let remoteBuzzerClient; let rotaryController; +let buttonController; + // eslint-disable-next-line no-unused-vars function initRemoteBuzzerFromDOM() { if (config.dev.enabled) { - console.log('Remote Buzzer client is', config.remotebuzzer.enabled ? 'enabled' : 'disabled'); + console.log( + 'Remote Buzzer client is', + config.remotebuzzer.usebuttons || config.remotebuzzer.userotary ? 'enabled' : 'disabled' + ); } /* ** Communication with Remote Buzzer Server - ** Controls PB when in BUTTON mode */ remoteBuzzerClient = (function () { @@ -19,7 +23,7 @@ function initRemoteBuzzerFromDOM() { const api = {}; api.enabled = function () { - return config.remotebuzzer.enabled; + return config.remotebuzzer.usebuttons || config.remotebuzzer.userotary; }; api.init = function () { @@ -39,26 +43,15 @@ function initRemoteBuzzerFromDOM() { ioClient.on('photobooth-socket', function (data) { switch (data) { case 'start-picture': - $('.resultInner').removeClass('show'); - photoBooth.thrill('photo'); + buttonController.takePicture(); break; case 'start-collage': - if (config.collage.enabled) { - $('.resultInner').removeClass('show'); - photoBooth.thrill('collage'); - } + buttonController.takeCollage(); break; case 'print': - if ($('#result').is(':visible')) { - $('.printbtn').trigger('click'); - $('.printbtn').blur(); - } else if ($('.pswp__button--print').is(':visible')) { - $('.pswp__button--print').trigger('click'); - } else { - ioClient.emit('photobooth-socket', 'completed'); - } + buttonController.print(); break; case 'rotary-cw': @@ -90,29 +83,93 @@ function initRemoteBuzzerFromDOM() { } }); + buttonController.init(); + rotaryController.init(); + rotaryController.focusSet('#start'); } else { console.log( 'ERROR: remotebuzzer_client unable to connect - webserver.ip not defined in photobooth config' ); } - - rotaryController.init(); }; api.inProgress = function (flag) { if (this.enabled()) { if (flag) { - ioClient.emit('photobooth-socket', 'in-progress'); + this.emitToServer('in-progress'); } else { - ioClient.emit('photobooth-socket', 'completed'); + this.emitToServer('completed'); } } }; api.collageWaitForNext = function () { if (this.enabled()) { - ioClient.emit('photobooth-socket', 'collage-wait-for-next'); + this.emitToServer('collage-wait-for-next'); + } + }; + + api.emitToServer = function (cmd) { + switch (cmd) { + case 'in-progress': + ioClient.emit('photobooth-socket', 'in-progress'); + break; + case 'completed': + ioClient.emit('photobooth-socket', 'completed'); + break; + case 'collage-wait-for-next': + ioClient.emit('photobooth-socket', 'collage-wait-for-next'); + break; + default: + break; + } + }; + + return api; + })(); + + /* + ** Controls PB with hardware BUTTONS + */ + buttonController = (function () { + // vars + const api = {}; + + api.init = function () { + // nothing to init + }; + + api.enabled = function () { + return ( + config.remotebuzzer.usebuttons && + typeof onStandaloneGalleryView === 'undefined' && + typeof onLiveChromaKeyingView === 'undefined' + ); + }; + + api.takePicture = function () { + if (this.enabled()) { + $('.resultInner').removeClass('show'); + photoBooth.thrill('photo'); + } + }; + + api.takeCollage = function () { + if (this.enabled() && config.collage.enabled) { + $('.resultInner').removeClass('show'); + photoBooth.thrill('collage'); + } + }; + + api.print = function () { + if ($('#result').is(':visible')) { + $('.printbtn').trigger('click'); + $('.printbtn').blur(); + } else if ($('.pswp__button--print').is(':visible')) { + $('.pswp__button--print').trigger('click'); + } else { + remoteBuzzerClient.emitToServer('completed'); } }; @@ -120,31 +177,33 @@ function initRemoteBuzzerFromDOM() { })(); /* - ** Controls PB when in ROTARY mode + ** Controls PB with ROTARY encoder */ rotaryController = (function () { // vars - let enabled = false; const api = {}; // API functions + api.enabled = function () { + return ( + config.remotebuzzer.userotary && + (typeof onStandaloneGalleryView === 'undefined' ? true : config.remotebuzzer.enable_standalonegallery) + ); + }; + api.init = function () { - enabled = config.remotebuzzer.userotary; - if (typeof onStandaloneGalleryView !== 'undefined') { - enabled = enabled && config.remotebuzzer.enable_standalonegallery; - if (config.dev.enabled) { - console.log( - 'Rotary Controller is ', - config.remotebuzzer.enable_standalonegallery ? 'enabled' : 'disabled', - ' for standalone gallery view' - ); - } + if (config.dev.enabled && typeof onStandaloneGalleryView !== 'undefined') { + console.log( + 'Rotary Controller is ', + config.remotebuzzer.enable_standalonegallery ? 'enabled' : 'disabled', + ' for standalone gallery view' + ); } }; api.focusSet = function (id) { - if (enabled) { + if (this.enabled()) { this.focusRemove(); $(id).find('.rotaryfocus').first().addClass('focused'); } @@ -155,7 +214,7 @@ function initRemoteBuzzerFromDOM() { }; api.focusNext = function () { - if (this.rotationInactive() || !enabled) { + if (this.rotationInactive() || !this.enabled()) { return; } @@ -202,7 +261,7 @@ function initRemoteBuzzerFromDOM() { }; api.focusPrev = function () { - if (this.rotationInactive() || !enabled) { + if (this.rotationInactive() || !this.enabled()) { return; } @@ -248,7 +307,7 @@ function initRemoteBuzzerFromDOM() { }; api.click = function () { - if (enabled) { + if (this.enabled()) { // click modal if open if ($('#qrCode.modal.modal--show').exists()) { $('#qrCode').click(); diff --git a/src/js/remotebuzzer_server.js b/src/js/remotebuzzer_server.js index e3e83d98f..9f97b599b 100644 --- a/src/js/remotebuzzer_server.js +++ b/src/js/remotebuzzer_server.js @@ -162,8 +162,8 @@ function gpioSanity(gpioconfig) { throw new Error(gpioconfig + ' is not a valid number'); } - if (gpioconfig < 1 || gpioconfig > 26) { - throw new Error('GPIO' + gpioconfig + ' number is out of range (1-26)'); + if (gpioconfig < 1 || gpioconfig > 27) { + throw new Error('GPIO' + gpioconfig + ' number is out of range (1-27)'); } cmd = 'sed -n "s/^gpio=\\(.*\\)=pu/\\1/p" /boot/config.txt'; @@ -178,6 +178,9 @@ gpioSanity(config.remotebuzzer.picturegpio); gpioSanity(config.remotebuzzer.collagegpio); gpioSanity(config.remotebuzzer.shutdowngpio); gpioSanity(config.remotebuzzer.printgpio); +gpioSanity(config.remotebuzzer.rotaryclkgpio); +gpioSanity(config.remotebuzzer.rotarydtgpio); +gpioSanity(config.remotebuzzer.rotarybtngpio); /* BUTTON SEMAPHORE HELPER FUNCTION */ function buttonActiveCheck(gpio, value) { @@ -503,10 +506,10 @@ const Gpio = require('onoff').Gpio; /* ROTARY ENCODER MODE */ if (config.remotebuzzer.userotary) { /* ROTARY ENCODER MODE */ - log('Operating in ROTARY mode'); - const rotaryClk = new Gpio(config.remotebuzzer.picturegpio, 'in', 'both'); - const rotaryDt = new Gpio(config.remotebuzzer.collagegpio, 'in', 'both'); - const rotaryBtn = new Gpio(config.remotebuzzer.shutdowngpio, 'in', 'both', {debounceTimeout: 20}); + log('ROTARY support active'); + const rotaryClk = new Gpio(config.remotebuzzer.rotaryclkgpio, 'in', 'both'); + const rotaryDt = new Gpio(config.remotebuzzer.rotarydtgpio, 'in', 'both'); + const rotaryBtn = new Gpio(config.remotebuzzer.rotarybtngpio, 'in', 'both', {debounceTimeout: 20}); rotaryClkPin = 0; rotaryDtPin = 0; @@ -516,14 +519,19 @@ if (config.remotebuzzer.userotary) { rotaryBtn.watch(watchRotaryBtn); log( - 'Ready for Rotary Encoder on GPIOs', - config.remotebuzzer.picturegpio, - config.remotebuzzer.collagegpio, - config.remotebuzzer.shutdowngpio + 'Looking for Rotary Encoder connected to GPIOs ', + config.remotebuzzer.rotaryclkgpio, + '(CLK) ', + config.remotebuzzer.rotarydtgpio, + '(DT) ', + config.remotebuzzer.rotarybtngpio, + '(BTN)' ); -} else { - /* NORMAL BUTTON BUTTON */ - log('Operating in BUTTON mode'); +} + +/* NORMAL BUTTON SUPPORT */ +if (config.remotebuzzer.usebuttons) { + log('BUTTON support active'); if (config.remotebuzzer.picturebutton) { const pictureButton = new Gpio(config.remotebuzzer.picturegpio, 'in', 'both', {debounceTimeout: 20}); @@ -534,28 +542,28 @@ if (config.remotebuzzer.userotary) { pictureButton.watch(watchPictureGPIO); } - log('Connecting Picture Button to Raspberry GPIO', config.remotebuzzer.picturegpio); + log('Looking for Picture Button on Raspberry GPIO', config.remotebuzzer.picturegpio); } /* COLLAGE BUTTON */ if (config.remotebuzzer.collagebutton && config.collage.enabled) { const collageButton = new Gpio(config.remotebuzzer.collagegpio, 'in', 'both', {debounceTimeout: 20}); collageButton.watch(watchCollageGPIO); - log('Connecting Collage Button to Raspberry GPIO', config.remotebuzzer.collagegpio); + log('Looking for Collage Button on Raspberry GPIO', config.remotebuzzer.collagegpio); } /* SHUTDOWN BUTTON */ if (config.remotebuzzer.shutdownbutton) { const shutdownButton = new Gpio(config.remotebuzzer.shutdowngpio, 'in', 'both', {debounceTimeout: 20}); shutdownButton.watch(watchShutdownGPIO); - log('Connecting Shutdown Button to Raspberry GPIO', config.remotebuzzer.shutdowngpio); + log('Looking for Shutdown Button on Raspberry GPIO', config.remotebuzzer.shutdowngpio); } /* PRINT BUTTON */ if (config.remotebuzzer.printbutton) { const printButton = new Gpio(config.remotebuzzer.printgpio, 'in', 'both', {debounceTimeout: 20}); printButton.watch(watchPrintGPIO); - log('Connecting Print Button to Raspberry GPIO', config.remotebuzzer.printgpio); + log('Looking for Print Button on Raspberry GPIO', config.remotebuzzer.printgpio); } } log('Initialization completed');