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

remote-buzzer: enable buttons and rotary parallel use #262

Merged
merged 3 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,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';
Expand Down
61 changes: 40 additions & 21 deletions faq/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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
Expand All @@ -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**

Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down
5 changes: 4 additions & 1 deletion install-raspbian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -356,6 +356,9 @@ cat >> /etc/sudoers.d/020_www-data-shutdown << EOF
# Photobooth Remotebuzzer shutdown button for www-data to shutdown the system
www-data ALL=(ALL) NOPASSWD: /sbin/shutdown
EOF

# update artifacts in user configuration from old remotebuzzer implementation
sed -i '/remotebuzzer/{n;n;s/enabled/usebuttons/}' $INSTALLFOLDERPATH/config/my.config.inc.php
fi
# remotebuzzer config depending on version end

Expand Down
40 changes: 30 additions & 10 deletions lib/configsetup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1329,25 +1329,18 @@
'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',
'type' => 'checkbox',
'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',
Expand Down Expand Up @@ -1422,6 +1415,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',
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']['enabled']) {
if ($config['remotebuzzer']['usebuttons'] || $config['remotebuzzer']['userotary']) {
$connection = @fsockopen('127.0.0.1', $config['remotebuzzer']['port']);

if (!is_resource($connection)) {
Expand Down
5 changes: 5 additions & 0 deletions livechroma.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,10 @@
<script type="text/javascript" src="resources/js/i18n.js"></script>

<?php require_once('lib/services_start.php'); ?>

<script type="text/javascript">
onLiveChromaKeyingView = true;
</script>

</body>
</html>
8 changes: 4 additions & 4 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,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 <code>tmp</code> folder and defaults to <code>io_server.log</code>.",
"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.",
Expand Down Expand Up @@ -486,14 +486,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)",
Expand Down
32 changes: 21 additions & 11 deletions src/js/core.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals initPhotoSwipeFromDOM initRemoteBuzzerFromDOM i18n setMainImage remoteBuzzerClient rotaryController */
/* globals initPhotoSwipeFromDOM initRemoteBuzzerFromDOM i18n setMainImage remoteBuzzerClient rotaryController globalGalleryHandle */

const photoBooth = (function () {
// vars
Expand Down Expand Up @@ -323,6 +323,7 @@ const photoBooth = (function () {
api.closeNav();
api.reset();
api.showResultInner(false);
api.closeGallery();

remoteBuzzerClient.inProgress(true);

Expand Down Expand Up @@ -861,6 +862,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('');
Expand Down Expand Up @@ -1068,16 +1087,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) {
Expand Down
Loading