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

remotebuzzer: remove gpio library, switch to onoff library, add additional button support #201

Merged
merged 2 commits into from
Mar 1, 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
8 changes: 7 additions & 1 deletion config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,13 @@
// collagetime controls the time to distinguish picture from collage in seconds
$config['remotebuzzer']['collagetime'] = '2';
$config['remotebuzzer']['port'] = 14711;
$config['remotebuzzer']['pin'] = 40;
$config['remotebuzzer']['picturebutton'] = true;
$config['remotebuzzer']['picturegpio'] = 21;
$config['remotebuzzer']['collagebutton'] = false;
$config['remotebuzzer']['collagegpio'] = 20;
$config['remotebuzzer']['shutdownbutton'] = false;
$config['remotebuzzer']['shutdowngpio'] = 16;
$config['remotebuzzer']['shutdownholdtime'] = '5';


// S Y N C T O U S B S T I C K
Expand Down
50 changes: 38 additions & 12 deletions faq/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,49 @@ sudo crontab -e
<hr>

### Hardware Button for WLAN connected screen (i.e. iPad) - Remote Buzzer Server
This feature enables a GPIO pin connected hardware button / buzzer for a setup where the display / screen is connected via WLAN / network to the photobooth webserver (e.g. iPad). Configuration takes place in the admin settings - Remote Buzzer Server area.
This feature enables multiple GPIO pin connected hardware buttons (buzzer) in a setup where the display / screen is connected via WLAN / network to the photobooth webserver (e.g. iPad). Configuration takes place in the admin settings - Remote Buzzer Server area.

**Important: You must make sure to set the IP address of the Photobooth web server in the admin settings - section "General"**. The loopback IP (127.0.0.1) does not work, it has to be the exact IP address of the Photobooth web server, to which the remote display connects to.
Troubleshooting / Debugging:

Debugging: switch on dev settings for server logs to be written to the "tmp" directory of the photobooth installation (i.e. `data/tmp/io_server.log`). Clients will log server communication information to the browser console.

If you experience crashes or access permission problems to GPIO pins, check [https://www.npmjs.com/package/rpio](https://www.npmjs.com/package/rpio) for additional settings required on the Pi
- **Important: You must make sure to set the IP address of the Photobooth web server in the admin settings - section "General"**. The loopback IP (127.0.0.1) does not work, it has to be the exact IP address of the Photobooth web server, to which the remote display connects to.
- Switch on dev settings for server logs to be written to the "tmp" directory of the photobooth installation (i.e. `data/tmp/remotebuzzer_server.log`). Clients will log server communication information to the browser console.
- If hardware buttons do not trigger, GPIO interrupts might be disabled. Check file `/boot/config.txt` and remove / disable the following overlay `dtoverlay=gpio-no-irq` to enable interrupts for GPIOs.

***************
Hardware Buzzer / Button
Hardware Button (Buzzer)
***************
The hardware buzzer connects to a GPIO pin, the server will watch for a PIN_DOWN event (pull to ground). This will initiate a message to the photobooth screen over network / WLAN, to trigger the action (thrill).
The server supports up to three connected hardware buttons for the following functionalities.

1) **Picture Button**

- Defaults to GPIO21
- Short button press (default <= 2 sec) will trigger a single picture in Photobooth
- Long button press (default > 2 sec) will trigger a collage in Photobooth

Note:
- If collage is configured with interruption, next button presses will trigger the next collage pictures.
- If collage is disabled in the admin settings, long button press also triggers a single picture
- If the collage button is activated (see next), the picture button will never trigger a collage, regardless

2) **Collage Button**

- Defaults to GPIO20
- Button press will trigger a collage in Photobooth.

Note:
- If collage is configured with interruption, next button presses will trigger the next collage pictures.
- If collage is disabled in the admin settings, this button will do nothing even if it is activated in the admin settings

3) **Shutdown Button**

- Defaults to GPIO16
- This button will initate a safe system shutdown and halt (`shutdown -h now`).

Note:
- One needs to hold the button for a defined time to initiate the shut down (defaults to 3 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).

- Short button press (default <= 2 sec) will trigger a single picture
- Long button press (default > 2 sec) will trigger a collage
- If collage is configured with interruption, next button presses will trigger the next collage pictures.
- If collage is disabled in the admin settings, long button press also triggers a single picture
All hardware buttons connect to a GPIO pin and the server will watch for a PIN_DOWN event (pull to ground). This will initiate a message to the photobooth screen over network / WLAN, to trigger the action (thrill).

After triggered, the hardware button remains disabled until an action (picture / collage) has fully completed. Then the hardware button re-arms / is active again.

Expand All @@ -155,7 +181,7 @@ The trigger server controls and coordinates sending commands via socket.io to th
- Commands: `start-picture`, `start-collage`
- Response: `completed` will be emitted to the client, once photobooth finished the task

This functionality is experimental and largely untested.
This functionality is experimental and largely untested. Not sure if there is a use-case but if you have one, happy to learn about it.

<hr>

Expand Down
26 changes: 20 additions & 6 deletions install-raspbian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,29 @@ EOF

fi

info "### Enable Nodejs GPIO access - please reboot in order to use the Remote Buzzer Feature"
info "### Remote Buzzer Feature"
info "### Configure Raspberry PI GPIOs for Photobooth - please reboot in order use the Remote Buzzer Feature"
# remove old artifacts from node-rpio library, if there was
if [ -f '/etc/udev/rules.d/20-photobooth-gpiomem.rules' ]; then
info "### Remotebuzzer switched from node-rpio to onoff library. We detected an old remotebuzzer installation and will remove artifacts"
rm -f /etc/udev/rules.d/20-photobooth-gpiomem.rules
sed -i '/dtoverlay=gpio-no-irq/d' /boot/config.txt
fi
# add configuration required for onoff library
usermod -a -G gpio www-data
cat > /etc/udev/rules.d/20-photobooth-gpiomem.rules <<EOF
SUBSYSTEM=="bcm2835-gpiomem", KERNEL=="gpiomem", GROUP="gpio", MODE="0660"
EOF
sed -i '/dtoverlay=gpio-no-irq/d' /boot/config.txt
sed -i '/Photobooth/,/Photobooth End/d' /boot/config.txt
cat >> /boot/config.txt << EOF
dtoverlay=gpio-no-irq
# Photobooth
gpio=16,20,21=pu
# Photobooth End
EOF
# add configuration required for www-data to be able to initiate system shutdown
info "### Note: In order for the shutdown button to work we install /etc/sudoers.d/020_www-data-shutdown"
cat >> /etc/sudoers.d/020_www-data-shutdown << EOF
## Photobooth Remotebuzzer shutdown button for www-data to shutdown the system
www-data ALL=NOPASSWD: /sbin/shutdown
EOF
echo -e "\033[0m"

echo -e "\033[0;33m### Sync to USB - this feature will automatically copy (sync) new pictures to a USB stick."
echo -e "### The actual configuration will be done in the admin panel but we need to setup Raspberry Pi OS first"
Expand Down
66 changes: 54 additions & 12 deletions lib/configsetup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@
'value' => $config['remotebuzzer']['enabled'],
],
'remotebuzzer_collagetime' => [
'view' => 'advanced',
'view' => 'expert',
'type' => 'range',
'placeholder' => $defaultConfig['remotebuzzer']['collagetime'],
'name' => 'remotebuzzer[collagetime]',
Expand All @@ -1081,27 +1081,69 @@
'range_step' => 1,
'unit' => 'seconds',
],
'remotebuzzer_port' => [
'view' => 'expert',
'type' => 'input',
'placeholder' => $defaultConfig['remotebuzzer']['port'],
'name' => 'remotebuzzer[port]',
'value' => $config['remotebuzzer']['port'],
'remotebuzzer_picturebutton' => [
'view' => 'advanced',
'type' => 'checkbox',
'name' => 'remotebuzzer[picturebutton]',
'value' => $config['remotebuzzer']['picturebutton'],
],
'remotebuzzer_pin' => [
'remotebuzzer_picturegpio' => [
'view' => 'advanced',
'type' => 'hidden',
'placeholder' => $defaultConfig['remotebuzzer']['picturegpio'],
'name' => 'remotebuzzer[picturegpio]',
'value' => $config['remotebuzzer']['picturegpio'],
],
'remotebuzzer_collagebutton' => [
'view' => 'advanced',
'type' => 'checkbox',
'name' => 'remotebuzzer[collagebutton]',
'value' => $config['remotebuzzer']['collagebutton'],
],
'remotebuzzer_collagegpio' => [
'view' => 'expert',
'type' => 'hidden',
'placeholder' => $defaultConfig['remotebuzzer']['collagegpio'],
'name' => 'remotebuzzer[collagegpio]',
'value' => $config['remotebuzzer']['collagegpio'],
],
'remotebuzzer_shutdownbutton' => [
'view' => 'advanced',
'type' => 'input',
'placeholder' => $defaultConfig['remotebuzzer']['pin'],
'name' => 'remotebuzzer[pin]',
'value' => $config['remotebuzzer']['pin'],
'type' => 'checkbox',
'name' => 'remotebuzzer[shutdownbutton]',
'value' => $config['remotebuzzer']['shutdownbutton'],
],
'remotebuzzer_shutdowngpio' => [
'view' => 'expert',
'type' => 'hidden',
'placeholder' => $defaultConfig['remotebuzzer']['shutdowngpio'],
'name' => 'remotebuzzer[shutdowngpio]',
'value' => $config['remotebuzzer']['shutdowngpio'],
],
'remotebuzzer_shutdownholdtime' => [
'view' => 'expert',
'type' => 'range',
'placeholder' => $defaultConfig['remotebuzzer']['shutdownholdtime'],
'name' => 'remotebuzzer[shutdownholdtime]',
'value' => $config['remotebuzzer']['shutdownholdtime'],
'range_min' => 0,
'range_max' => 9,
'range_step' => 1,
'unit' => 'seconds',
],
'remotebuzzer_logfile' => [
'view' => 'expert',
'type' => 'hidden',
'name' => 'remotebuzzer[logfile]',
'value' => $config['remotebuzzer']['logfile'],
],
'remotebuzzer_port' => [
'view' => 'expert',
'type' => 'input',
'placeholder' => $defaultConfig['remotebuzzer']['port'],
'name' => 'remotebuzzer[port]',
'value' => $config['remotebuzzer']['port'],
],
],
'synctodrive' => [
'platform' => 'linux',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"marvinj": "^1.0.0",
"normalize.css": "^8.0.1",
"npm-run-all": "^4.1.5",
"rpio": "^2.1.1",
"onoff": "^6.0.1",
"selectize": "^0.12.6",
"socket.io": "^3.1.2",
"socket.io-client": "^3.1.2",
Expand Down
9 changes: 8 additions & 1 deletion resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,15 @@
"manual:print:textonprint_locationx": "X-Coordinates of the text while printing text on your picture.",
"manual:print:textonprint_locationy": "Y-Coordinates of the text while printing text on your picture.",
"manual:print:textonprint_rotation": "Enter a value which is used as degrees a picture gets rotated at print.",
"manual:remotebuzzer:remotebuzzer_collagebutton": "Connect the hardware button for COLLAGE to this Raspberry Pi GPIO. Defaults 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 trigger button is pressed (GPIO pulled down) less or equal number of seconds configured here, a picture is triggered. If button is pressed more seconds as what is configured here, a collage is triggered. If collage is disabled in the admin settings, no collage will be triggered at all.",
"manual:remotebuzzer:remotebuzzer_enabled": "This feature enables a GPIO monitoring for a hardware trigger connected to Raspberry GPIO pins in combination with WLAN connected displays and screens (i.e. iPad). IMPORTANT: Please 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": "If Dev-Mode is on, 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": "Connect the hardware button for PICTURE to this Raspberry Pi GPIO. Defaults to GPIO21. Pull GPIO to ground for to trigger. Long-Press will trigger COLLAGE, in case COLLAGE hardware button is disabled.",
"manual:remotebuzzer:remotebuzzer_pin": "Connect the hardware trigger to this Raspberry Pi <b>PIN</b> number (range 1-40). Defaults to PIN 40 == GPIO21. Set to 0 (zero) for to disable the GPIO harware monitoring. Raspberry PIN layout can be found <a href=\"https://www.raspberrypi.org/documentation/usage/gpio/\" target=\"_blank\">here</a>. Please use the actual PIN numbers, not the GPIO numners. Pull PIN to ground for to trigger.",
"manual:remotebuzzer:remotebuzzer_port": "Server TCP Port - example 14711.",
"manual:remotebuzzer:remotebuzzer_shutdownbutton": "Connect the hardware button to SHUTDOWN Raspberry Pi. Pull GPIO to ground for to trigger. Defaults to GPIO16",
"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: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 @@ -392,11 +396,14 @@
"really_delete_image": "will be deleted! This cannot be undone! Really delte picture?",
"reload": "Reload Page",
"remotebuzzer": "Remote Buzzer Server",
"remotebuzzer:remotebuzzer_collagebutton": "Enable GPIO for collage",
"remotebuzzer:remotebuzzer_collagetime": "Seconds to trigger collage",
"remotebuzzer:remotebuzzer_enabled": "Enable Remote Buzzer",
"remotebuzzer:remotebuzzer_logfile": "Logfile",
"remotebuzzer:remotebuzzer_pin": "Raspberry Pi <b>PIN</b> number (0 to disable)",
"remotebuzzer:remotebuzzer_picturebutton": "Enable GPIO for pictures",
"remotebuzzer:remotebuzzer_port": "Server Port",
"remotebuzzer:remotebuzzer_shutdownbutton": "Enable GPIO for shutdown",
"remotebuzzer:remotebuzzer_shutdownholdtime": "Seconds to initiate shutdown",
"reset": "Reset",
"reset:reset_button": "Execute config reset",
"reset:reset_remove_config": "Delete personal configuration (my.config.inc.php)",
Expand Down
2 changes: 1 addition & 1 deletion scripts/pack-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ function createArchive(fileName, archive) {
archive.directory('node_modules/nan');
archive.directory('node_modules/negotiator');
archive.directory('node_modules/object-component');
archive.directory('node_modules/onoff');
archive.directory('node_modules/parseqs');
archive.directory('node_modules/parseuri');
archive.directory('node_modules/rpio');
archive.directory('node_modules/selectize');
archive.directory('node_modules/socket.io');
archive.directory('node_modules/socket.io-adapter');
Expand Down
Loading