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

Commit 8f7bbaf

Browse files
committed
remote-buzzer: enable buttons and rotary parallel use
1 parent 2c9c8ee commit 8f7bbaf

File tree

10 files changed

+228
-104
lines changed

10 files changed

+228
-104
lines changed

config/config.inc.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,12 @@
229229

230230

231231
// R E M O T E B U Z Z E R
232-
$config['remotebuzzer']['enabled'] = false;
232+
$config['remotebuzzer']['usebuttons'] = false;
233233
$config['remotebuzzer']['userotary'] = false;
234234
$config['remotebuzzer']['enable_standalonegallery'] = false;
235+
$config['remotebuzzer']['rotaryclkgpio'] = 27;
236+
$config['remotebuzzer']['rotarydtgpio'] = 17;
237+
$config['remotebuzzer']['rotarybtngpio'] = 22;
235238
$config['remotebuzzer']['picturebutton'] = true;
236239
// collagetime controls the time to distinguish picture from collage in seconds
237240
$config['remotebuzzer']['collagetime'] = '2';

faq/faq.md

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ Follow the steps mentioned here: [How to Fix NGINX 413 Request Entity Too Large
116116
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.
117117

118118
The Hardware Button functionality supports two separate modes of operation (select via admin panel):
119-
- **Button Mode**: Distinct hardware buttons can be connected to distinct GPIOs. Each button will trigger a separate functionality (i.e. take photo).
120-
- **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.
119+
- **Buttons**: Distinct hardware buttons can be connected to distinct GPIOs. Each button will trigger a separate functionality (i.e. take photo).
120+
- **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.
121121

122-
Modes can not be combined.
122+
Both buttons and rotary encoder controls can be combined.
123123

124-
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.
124+
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.
125125

126126
Troubleshooting / Debugging:
127127

@@ -135,7 +135,7 @@ Troubleshooting / Debugging:
135135
- 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.
136136

137137
```
138-
gpio=16,20,21,26=pu
138+
gpio=16,17,20,21,22,26,27=pu
139139
```
140140

141141
- 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:
149149
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.
150150

151151

152-
***************
153-
**Button Mode**
154-
***************
155-
The server supports up to three connected hardware buttons for the following functionalities:
152+
******************
153+
**Button Support**
154+
******************
155+
The server supports up to four connected hardware buttons for the following functionalities:
156156

157157
1) **Picture Button**
158158

@@ -183,24 +183,43 @@ Note:
183183
- Hold the button for a defined time to initiate the shut down (defaults to 5 seconds). This can be adjusted in the admin settings.
184184
- The shutdown button will only trigger if there is currently no action in progress in Photobooth (picture, collage).
185185

186+
4) **Print Button**
187+
188+
- Defaults to GPIO26
189+
- This button will initiate a print of the current picture either from the results screen or the gallery.
190+
191+
186192
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.
187193

188-
***************
189-
**Rotary Mode**
190-
***************
191-
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.
194+
The wiring layout is
195+
196+
```
197+
Button Raspberry
198+
199+
Picture --- GPIO 21
200+
Collage --- GPIO 20
201+
Shutdown --- GPIO 16
202+
Print --- GPIO 26
203+
All --- GND
204+
```
205+
206+
207+
******************
208+
**Rotary Encoder**
209+
******************
210+
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.
192211

193212
The wiring layout is
194213

195214
```
196-
Button Rotary Encoder
197-
Mode Raspberry Mode
215+
Rotary
216+
Encoder Raspberry
198217
199-
Picture --- GPIO 21 --- DT
200-
Collage --- GPIO 20 --- CLK
201-
Shutdown --- GPIO 16 --- SW
202-
3V3 --- +
203-
GND --- GND
218+
CLK --- GPIO 27
219+
DT --- GPIO 17
220+
BTN --- GPIO 22
221+
+ --- 3V3
222+
GND --- GND
204223
```
205224

206225
Known limitations:
@@ -215,7 +234,7 @@ Other Remote Trigger (experimental)
215234
**************
216235
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.
217236

218-
- Channel: `photobooth-socket`
237+
- Channel: `photobooth-socket`
219238
- Commands: `start-picture`, `start-collage`
220239
- Response: `completed` will be emitted to the client, once photobooth finished the task
221240

install-raspbian.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ fi
347347
sed -i '/Photobooth/,/Photobooth End/d' /boot/config.txt
348348
cat >> /boot/config.txt << EOF
349349
# Photobooth
350-
gpio=16,20,21,26=pu
350+
gpio=16,17,20,21,22,26,27=pu
351351
# Photobooth End
352352
EOF
353353
# add configuration required for www-data to be able to initiate system shutdown

lib/configsetup.inc.php

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,25 +1329,18 @@
13291329
'remotebuzzer' => [
13301330
'view' => 'advanced',
13311331
'platform' => 'linux',
1332-
'remotebuzzer_enabled' => [
1332+
'remotebuzzer_usebuttons' => [
13331333
'view' => 'advanced',
13341334
'type' => 'checkbox',
1335-
'name' => 'remotebuzzer[enabled]',
1336-
'value' => $config['remotebuzzer']['enabled'],
1335+
'name' => 'remotebuzzer[usebuttons]',
1336+
'value' => $config['remotebuzzer']['usebuttons'],
13371337
],
13381338
'remotebuzzer_userotary' => [
13391339
'view' => 'advanced',
13401340
'type' => 'checkbox',
13411341
'name' => 'remotebuzzer[userotary]',
13421342
'value' => $config['remotebuzzer']['userotary'],
13431343
],
1344-
'remotebuzzer_enable_standalonegallery' => [
1345-
'view' => 'expert',
1346-
'type' => 'checkbox',
1347-
'name' => 'remotebuzzer[enable_standalonegallery]',
1348-
'value' => $config['remotebuzzer']['enable_standalonegallery'],
1349-
],
1350-
13511344
'remotebuzzer_picturebutton' => [
13521345
'view' => 'advanced',
13531346
'type' => 'checkbox',
@@ -1422,6 +1415,33 @@
14221415
'range_step' => 1,
14231416
'unit' => 'seconds',
14241417
],
1418+
'remotebuzzer_rotaryclkgpio' => [
1419+
'view' => 'expert',
1420+
'type' => 'hidden',
1421+
'placeholder' => $defaultConfig['remotebuzzer']['rotaryclkgpio'],
1422+
'name' => 'remotebuzzer[rotaryclkgpio]',
1423+
'value' => $config['remotebuzzer']['rotaryclkgpio'],
1424+
],
1425+
'remotebuzzer_rotarydtgpio' => [
1426+
'view' => 'expert',
1427+
'type' => 'hidden',
1428+
'placeholder' => $defaultConfig['remotebuzzer']['rotarydtgpio'],
1429+
'name' => 'remotebuzzer[rotarydtgpio]',
1430+
'value' => $config['remotebuzzer']['rotarydtgpio'],
1431+
],
1432+
'remotebuzzer_rotarybtngpio' => [
1433+
'view' => 'expert',
1434+
'type' => 'hidden',
1435+
'placeholder' => $defaultConfig['remotebuzzer']['rotarybtngpio'],
1436+
'name' => 'remotebuzzer[rotarybtngpio]',
1437+
'value' => $config['remotebuzzer']['rotarybtngpio'],
1438+
],
1439+
'remotebuzzer_enable_standalonegallery' => [
1440+
'view' => 'expert',
1441+
'type' => 'checkbox',
1442+
'name' => 'remotebuzzer[enable_standalonegallery]',
1443+
'value' => $config['remotebuzzer']['enable_standalonegallery'],
1444+
],
14251445
'remotebuzzer_logfile' => [
14261446
'view' => 'expert',
14271447
'type' => 'hidden',

lib/services_start.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function processIsRunning($pName, $pidFile) {
1515
return count($output) - 1 ? true : false; // true if process is active
1616
}
1717

18-
if ($config['remotebuzzer']['enabled']) {
18+
if ($config['remotebuzzer']['usebuttons'] || $config['remotebuzzer']['userotary']) {
1919
$connection = @fsockopen('127.0.0.1', $config['remotebuzzer']['port']);
2020

2121
if (!is_resource($connection)) {

livechroma.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,10 @@
173173
<script type="text/javascript" src="resources/js/i18n.js"></script>
174174

175175
<?php require_once('lib/services_start.php'); ?>
176+
177+
<script type="text/javascript">
178+
onLiveChromaKeyingView = true;
179+
</script>
180+
176181
</body>
177182
</html>

resources/lang/en.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,14 @@
372372
"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.",
373373
"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.",
374374
"manual:remotebuzzer:remotebuzzer_enable_standalonegallery": "Controls whether the rotary encoder is active on the standalone gallery view.",
375-
"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.",
376375
"manual:remotebuzzer:remotebuzzer_logfile": "In Dev-Mode server debugging information will be written to the logfile, located in the <code>tmp</code> folder and defaults to <code>io_server.log</code>.",
377376
"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.",
378377
"manual:remotebuzzer:remotebuzzer_port": "Server TCP Port - example 14711.",
379378
"manual:remotebuzzer:remotebuzzer_printbutton": "For PRINT connect the hardware button to GPIO26. Pull GPIO to ground for to trigger.",
380379
"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.",
381380
"manual:remotebuzzer:remotebuzzer_shutdownholdtime": "Seconds to hold button until system shutdown will be initiated. Setting to Zero (0) means immediate shutdown without waiting time.",
382-
"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",
381+
"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.",
382+
"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.",
383383
"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.",
384384
"manual:reset:reset_remove_config": "If enabled, personal config gets removed on reset.",
385385
"manual:reset:reset_remove_images": "If enabled, all images gets removed on reset.",
@@ -486,14 +486,14 @@
486486
"remotebuzzer:remotebuzzer_collagebutton": "Collage Button",
487487
"remotebuzzer:remotebuzzer_collagetime": "Seconds to trigger collage",
488488
"remotebuzzer:remotebuzzer_enable_standalonegallery": "Rotary for standalone gallery",
489-
"remotebuzzer:remotebuzzer_enabled": "Enable Hardware Button Support",
490489
"remotebuzzer:remotebuzzer_logfile": "Logfile",
491490
"remotebuzzer:remotebuzzer_picturebutton": "Picture Button",
492491
"remotebuzzer:remotebuzzer_port": "Server Port",
493492
"remotebuzzer:remotebuzzer_printbutton": "Print Button",
494493
"remotebuzzer:remotebuzzer_shutdownbutton": "Shutdown Button",
495494
"remotebuzzer:remotebuzzer_shutdownholdtime": "Seconds to initiate shutdown",
496-
"remotebuzzer:remotebuzzer_userotary": "Rotary Encoder Mode",
495+
"remotebuzzer:remotebuzzer_usebuttons": "Enable Hardware Buttons",
496+
"remotebuzzer:remotebuzzer_userotary": "Enable Rotary Encoder",
497497
"reset": "Reset",
498498
"reset:reset_button": "Execute config reset",
499499
"reset:reset_remove_config": "Delete personal configuration (my.config.inc.php)",

src/js/core.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* globals initPhotoSwipeFromDOM initRemoteBuzzerFromDOM i18n setMainImage remoteBuzzerClient rotaryController */
1+
/* globals initPhotoSwipeFromDOM initRemoteBuzzerFromDOM i18n setMainImage remoteBuzzerClient rotaryController globalGalleryHandle */
22

33
const photoBooth = (function () {
44
// vars
@@ -323,6 +323,7 @@ const photoBooth = (function () {
323323
api.closeNav();
324324
api.reset();
325325
api.showResultInner(false);
326+
api.closeGallery();
326327

327328
remoteBuzzerClient.inProgress(true);
328329

@@ -861,6 +862,24 @@ const photoBooth = (function () {
861862
}, 300);
862863
};
863864

865+
// close Gallery Overview and Slideshow if visible
866+
api.closeGallery = function () {
867+
if (typeof globalGalleryHandle !== 'undefined') {
868+
globalGalleryHandle.close();
869+
}
870+
871+
gallery.find('.gallery__inner').hide();
872+
gallery.removeClass('gallery--open');
873+
874+
api.showResultInner(true);
875+
876+
if ($('#result').is(':visible')) {
877+
rotaryController.focusSet('#result');
878+
} else if ($('#start').is(':visible')) {
879+
rotaryController.focusSet('#start');
880+
}
881+
};
882+
864883
api.resetMailForm = function () {
865884
$('#send-mail-form').trigger('reset');
866885
$('#mail-form-message').html('');
@@ -1068,16 +1087,7 @@ const photoBooth = (function () {
10681087
$('.gallery__close').on('click', function (e) {
10691088
e.preventDefault();
10701089

1071-
gallery.find('.gallery__inner').hide();
1072-
gallery.removeClass('gallery--open');
1073-
1074-
api.showResultInner(true);
1075-
1076-
if ($('#result').is(':visible')) {
1077-
rotaryController.focusSet('#result');
1078-
} else if ($('#start').is(':visible')) {
1079-
rotaryController.focusSet('#start');
1080-
}
1090+
api.closeGallery();
10811091
});
10821092

10831093
$('.mailbtn').on('click touchstart', function (e) {

0 commit comments

Comments
 (0)