From de2a845b36afba373ae3c19005befa09e8de5afd Mon Sep 17 00:00:00 2001 From: Andreas Blaesius Date: Thu, 16 Jun 2022 13:11:22 +0200 Subject: [PATCH] remotebuzzer: rework option to use remotebuzzer server without GPIO On https://github.com/andi34/photobooth/pull/400 we've added simple GET endpoints to trigger photos / collages (to support WiFi hardware buttons), this allows to use the remotebuzzer server without the need for GPIO. Change-Id: I4fa1dc088652bf5119f01d787c69094b0f8741d2 --- config/config.inc.php | 2 +- lib/configsetup.inc.php | 8 ++++---- lib/services_start.php | 2 +- resources/lang/de.json | 1 - resources/lang/en.json | 4 ++-- resources/lang/fr.json | 2 -- src/js/remotebuzzer_client.js | 10 ++++------ src/js/remotebuzzer_server.js | 4 ++-- 8 files changed, 14 insertions(+), 19 deletions(-) diff --git a/config/config.inc.php b/config/config.inc.php index 2a5226cdb..064908647 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -257,7 +257,7 @@ $config['remotebuzzer']['usebuttons'] = false; $config['remotebuzzer']['userotary'] = false; $config['remotebuzzer']['enable_standalonegallery'] = false; -$config['remotebuzzer']['usegpio'] = true; +$config['remotebuzzer']['usenogpio'] = false; $config['remotebuzzer']['rotaryclkgpio'] = 27; $config['remotebuzzer']['rotarydtgpio'] = 17; $config['remotebuzzer']['rotarybtngpio'] = 22; diff --git a/lib/configsetup.inc.php b/lib/configsetup.inc.php index d6d64745f..e20bdf75e 100644 --- a/lib/configsetup.inc.php +++ b/lib/configsetup.inc.php @@ -1545,11 +1545,11 @@ 'name' => 'remotebuzzer[userotary]', 'value' => $config['remotebuzzer']['userotary'], ], - 'remotebuzzer_usegpio' => [ + 'remotebuzzer_usenogpio' => [ 'view' => 'advanced', - 'type' => 'hidden', - 'name' => 'remotebuzzer[usegpio]', - 'value' => $config['remotebuzzer']['usegpio'], + 'type' => 'checkbox', + 'name' => 'remotebuzzer[usenogpio]', + 'value' => $config['remotebuzzer']['usenogpio'], ], 'remotebuzzer_picturebutton' => [ 'view' => 'advanced', diff --git a/lib/services_start.php b/lib/services_start.php index bc170faf1..3521b8fb9 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']['usebuttons'] || $config['remotebuzzer']['userotary']) { +if ($config['remotebuzzer']['usebuttons'] || $config['remotebuzzer']['userotary'] || $config['remotebuzzer']['usenogpio']) { $connection = @fsockopen('127.0.0.1', $config['remotebuzzer']['port']); if (!is_resource($connection)) { diff --git a/resources/lang/de.json b/resources/lang/de.json index 47cd8f795..4fc60f427 100644 --- a/resources/lang/de.json +++ b/resources/lang/de.json @@ -564,7 +564,6 @@ "remotebuzzer:remotebuzzer_shutdownbutton": "Abschalt-Taste", "remotebuzzer:remotebuzzer_shutdownholdtime": "Sekunden um das Herunterfahren einzuleiten", "remotebuzzer:remotebuzzer_usebuttons": "Hardware-Tasten aktivieren", - "remotebuzzer:remotebuzzer_usegpio": "GPIO für Remotebuzzer verwenden", "reset": "Zurücksetzen", "reset:reset_button": "Konfiguration zurücksetzen", "reset:reset_remove_config": "Persönliche Konfiguration löschen (my.config.inc.php)", diff --git a/resources/lang/en.json b/resources/lang/en.json index f250e97e7..ac090982f 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -443,7 +443,7 @@ "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_usebuttons": "This feature enables hardware button support - see FAQ for details. Please activate GPIO support for remotebuzzer. 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_usegpio": "This feature enables hardware 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_usenogpio": "This feature enables the remotebuzzer server without GPIO support. This allows to use a simple GET endpoint to trigger photos / collage (e.g. to support WiFi hardware buttons). 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. Please activate GPIO support for remotebuzzer. 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.", @@ -582,7 +582,7 @@ "remotebuzzer:remotebuzzer_shutdownbutton": "Shutdown Button", "remotebuzzer:remotebuzzer_shutdownholdtime": "Seconds to initiate shutdown", "remotebuzzer:remotebuzzer_usebuttons": "Enable Hardware Buttons", - "remotebuzzer:remotebuzzer_usegpio": "Use GPIO for remotebuzzer", + "remotebuzzer:remotebuzzer_usenogpio": "Use remotebuzzer without GPIO support", "remotebuzzer:remotebuzzer_userotary": "Enable Rotary Encoder", "reset": "Reset", "reset:reset_button": "Execute config reset", diff --git a/resources/lang/fr.json b/resources/lang/fr.json index 3de5798d0..676d248f4 100644 --- a/resources/lang/fr.json +++ b/resources/lang/fr.json @@ -431,7 +431,6 @@ "manual:remotebuzzer:remotebuzzer_shutdownbutton": "Pour ARRETER connectez le bouton matériel au GPIO16. Mettez le GPIO à la masse pour déclencher. Maintenez 5 secondes (par défaut) pour le déclencher.", "manual:remotebuzzer:remotebuzzer_shutdownholdtime": "Lee temps de maintien enfoncé du bouton, en secondes, jusqu'à ce que l'arrêt du système soit initié. La valeur de zéro (0) signifie l'arrêt immédiat sans temps d'attente.", "manual:remotebuzzer:remotebuzzer_usebuttons": "Cette fonction active le support des boutons matériels - voir FAQ pour plus de détails. Veuillez activer le support GPIO pour remotebuzzer. IMPORTANT: Pour les écrans connectés au Wi-Fi, vous devez vous assurer de configurer l'adresse IP du serveur web de Photobooth dans la section \"Général\", pour que cette fonctionnalité fonctionne correctement.", - "manual:remotebuzzer:remotebuzzer_usegpio": "Cette fonctionnalité active le support matériel via les broches Raspberry GPIO - voir la FAQ pour plus de détails. IMPORTANT: Pour les écrans connectés au Wi-Fi, vous devez vous assurer de configurer l'adresse IP du serveur web Photobooth dans la section \"Général\", pour que cette fonction fonctionne correctement.", "manual:remotebuzzer:remotebuzzer_userotary": "Activez le support de l’encodeur rotatif pour naviguer sur l’écran. Nécessite un encodeur rotatif connecté aux GPIOs - voir FAQ pour plus de détails. Veuillez activer le support GPIO pour remotebuzzer. IMPORTANT: Pour les écrans connectés au Wi-Fi, vous devez vous assurer de configurer l'adresse IP du serveur web de Photobooth dans la section \"Général\", pour que cette fonctionnalité fonctionne correctement.", "manual:reset:reset_button": "Exécute la réinitialisation de la configuration. Si vous souhaitez également réinitialiser les photos et / ou la base de données d'adresse e-mail, assurez-vous d'abord d'activer ces paramètres et de sauvegarder la config (!), puis effectuez la réinitialisation de la configuration.", "manual:reset:reset_remove_config": "Si activé, la configuration personnelle sera supprimée lors de la réinitialisation.", @@ -568,7 +567,6 @@ "remotebuzzer:remotebuzzer_shutdownbutton": "Bouton d'arrêt", "remotebuzzer:remotebuzzer_shutdownholdtime": "Nombre de secondes pour lancer l'arrêt", "remotebuzzer:remotebuzzer_usebuttons": "Activer les boutons physiques", - "remotebuzzer:remotebuzzer_usegpio": "Utilisez les GPIO pour le buzzer", "remotebuzzer:remotebuzzer_userotary": "Activer l'encodeur rotatif", "reset": "Réinitialiser", "reset:reset_button": "Exécuter la réinitialisation de la configuration", diff --git a/src/js/remotebuzzer_client.js b/src/js/remotebuzzer_client.js index ca24938de..cc404f98e 100644 --- a/src/js/remotebuzzer_client.js +++ b/src/js/remotebuzzer_client.js @@ -9,8 +9,7 @@ let buttonController; function initRemoteBuzzerFromDOM() { photoboothTools.console.logDev( 'Remote Buzzer client:', - config.remotebuzzer.usebuttons || - config.remotebuzzer.userotary + config.remotebuzzer.usebuttons || config.remotebuzzer.userotary || config.remotebuzzer.usenogpio ? 'enabled' : 'disabled' ); @@ -24,10 +23,7 @@ function initRemoteBuzzerFromDOM() { const api = {}; api.enabled = function () { - return ( - config.remotebuzzer.usebuttons || - config.remotebuzzer.userotary - ); + return config.remotebuzzer.usebuttons || config.remotebuzzer.userotary || config.remotebuzzer.usenogpio; }; api.init = function () { @@ -181,6 +177,7 @@ function initRemoteBuzzerFromDOM() { api.enabled = function () { return ( config.remotebuzzer.usebuttons && + !config.remotebuzzer.usenogpio && typeof onStandaloneGalleryView === 'undefined' && typeof onLiveChromaKeyingView === 'undefined' ); @@ -236,6 +233,7 @@ function initRemoteBuzzerFromDOM() { api.enabled = function () { return ( config.remotebuzzer.userotary && + !config.remotebuzzer.usenogpio && (typeof onStandaloneGalleryView === 'undefined' ? true : config.remotebuzzer.enable_standalonegallery) ); }; diff --git a/src/js/remotebuzzer_server.js b/src/js/remotebuzzer_server.js index e1d40bcc4..be19f9b59 100644 --- a/src/js/remotebuzzer_server.js +++ b/src/js/remotebuzzer_server.js @@ -235,7 +235,7 @@ function gpioSanity(gpioconfig) { } } -if (config.remotebuzzer.usegpio) { +if (!config.remotebuzzer.usenogpio) { gpioSanity(config.remotebuzzer.picturegpio); gpioSanity(config.remotebuzzer.collagegpio); gpioSanity(config.remotebuzzer.shutdowngpio); @@ -588,7 +588,7 @@ const watchRotaryBtn = function watchRotaryBtn(err, gpioValue) { /* INIT ONOFF LIBRARY AND LINK CALLBACK FUNCTIONS */ const Gpio = require('onoff').Gpio; -if (config.remotebuzzer.usegpio) { +if (!config.remotebuzzer.usenogpio) { /* ROTARY ENCODER MODE */ if (config.remotebuzzer.userotary) { /* ROTARY ENCODER MODE */