Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
remotebuzzer: rework option to use remotebuzzer server without GPIO
Browse files Browse the repository at this point in the history
On #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
  • Loading branch information
andi34 committed Jun 16, 2022
1 parent 2c9b381 commit de2a845
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions lib/configsetup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion lib/services_start.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
1 change: 0 additions & 1 deletion resources/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
4 changes: 2 additions & 2 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions resources/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 4 additions & 6 deletions src/js/remotebuzzer_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
Expand All @@ -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 () {
Expand Down Expand Up @@ -181,6 +177,7 @@ function initRemoteBuzzerFromDOM() {
api.enabled = function () {
return (
config.remotebuzzer.usebuttons &&
!config.remotebuzzer.usenogpio &&
typeof onStandaloneGalleryView === 'undefined' &&
typeof onLiveChromaKeyingView === 'undefined'
);
Expand Down Expand Up @@ -236,6 +233,7 @@ function initRemoteBuzzerFromDOM() {
api.enabled = function () {
return (
config.remotebuzzer.userotary &&
!config.remotebuzzer.usenogpio &&
(typeof onStandaloneGalleryView === 'undefined' ? true : config.remotebuzzer.enable_standalonegallery)
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/js/remotebuzzer_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit de2a845

Please sign in to comment.