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

remotebuzzer: allow using remotebuzzer server on linux without GPIO #311

Merged
merged 4 commits into from
Sep 25, 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
3 changes: 3 additions & 0 deletions config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@
$config['remotebuzzer']['usebuttons'] = false;
$config['remotebuzzer']['userotary'] = false;
$config['remotebuzzer']['enable_standalonegallery'] = false;
$config['remotebuzzer']['usegpio'] = true;
$config['remotebuzzer']['usehid'] = false;
$config['remotebuzzer']['usesoftbtn'] = false;
$config['remotebuzzer']['rotaryclkgpio'] = 27;
$config['remotebuzzer']['rotarydtgpio'] = 17;
$config['remotebuzzer']['rotarybtngpio'] = 22;
Expand Down
103 changes: 93 additions & 10 deletions faq/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Open `http://localhost/admin` in your Webbrowser and change the configuration fo
### How to change the look of my Photobooth?
Photobooth can be easylie styled for your personal needs via admin panel, open [localhost/admin](http://localhost/admin) in your browser and take a look at the `User Interface` options.
To use a private custom index you need to create the following files:

- `resources/css/custom_style.css`
- Optional: `src/sass/custom_style.scss` (`yarn build` will create the `resources/css/custom_style.css` out of it)
- `resources/css/custom_chromakeying.css`
Expand Down Expand Up @@ -112,10 +113,79 @@ Follow the steps mentioned here: [How to Fix NGINX 413 Request Entity Too Large

<hr>

### Can I use Hardware Button on my Raspberry Pi, to take a Picture?
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.
### Can I use Hardware Button to take a Picture?
Yes, there's different ways!

#### Key code using connected HID devices
An HID device connected to your hardware can trigger different actions on your device. The HID device must be connected to the device you're accessing Photobooth from!
For example use <a href="https://keycode.info" target="_blank">https://keycode.info</a> to find out the key id of the button you like to use.

- Related configuration:
**PICTURE section**:
- Key code which triggers a picture: **define**

**COLLAGE section**:
- Key code which triggers a collage: **define**

**PRINT section**:
- Key code which triggers printing: **define**

#### Remotebuzzer Software Button feature (Linux only)
Software buttons can use the Remotebuzzer feature to make the button action taking effect at the same time on all devices accessing Photobooth!

- Related configuration:
**GENERAL section**:
- IP address of the Photobooth web server: **define**

**HARDWARE BUTTON section**:
- Enable Software Buttons: **on**
- __Optional:__ Use GPIO for remotebuzzer: **off**

Special Notes:

- **Important: For WLAN connected screens 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.
- Can be combined with HID-Device buttons, GPIO connected Hardware Button and Rotary Encoder!
- Having trouble?
- Switch Photobooth to DEV mode. (admin screen -> expert view -> general section)
- Reload the Photobooth homepage
- Check the browser developer console for error logs
- Check the server logs for errors at the Debug panel: [http://localhost/admin/debugpanel.php](http://localhost/admin/debugpanel.php)

#### Remotebuzzer Hardware Button feature using connected HID devices (Linux only)
An HID device connected to your hardware can trigger different actions. The HID device must be connected to one device you're accessing Photobooth from.
Using the Remotebuzzer feature makes the button action taking effect at the same time on all devices accessing Photobooth!
For example use <a href="https://keycode.info" target="_blank">https://keycode.info</a> to find out the key id of the button you like to use.

- Related configuration:
**GENERAL section**:
- IP address of the Photobooth web server: **define**

**PICTURE section**:
- Key code which triggers a picture: **define**

**COLLAGE section**:
- Key code which triggers a collage: **define**

**HARDWARE BUTTON section**:
- Enable HID-Device Buttons: **on**
- __Optional:__ Use GPIO for remotebuzzer: **off**

Special Notes:

- **Important: For WLAN connected screens 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.
- Can be combined with GPIO connected Hardware Button and Rotary Encoder!
- Having trouble?
- Switch Photobooth to DEV mode. (admin screen -> expert view -> general section)
- Reload the Photobooth homepage
- Check the browser developer console for error logs
- Check the server logs for errors at the Debug panel: [http://localhost/admin/debugpanel.php](http://localhost/admin/debugpanel.php)

#### Remotebuzzer Hardware Button feature using GPIO connected hardware (Raspberry Pi only)
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.
Using the Remotebuzzer feature makes the button action taking effect at the same time on all devices accessing Photobooth!

The Hardware Button functionality supports two separate modes of operation (select via admin panel):

- **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.

Expand All @@ -126,19 +196,20 @@ Photobooth will watch GPIOs for a PIN_DOWN event - so the hardware button needs
Troubleshooting / Debugging:

- **Important: For WLAN connected screens 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 Photobooth to DEV mode. (admin screen -> expert view -> general section)
- Reload the Photobooth homepage
- Check the browser developer console for error logs
- Check the server logs for errors (file `data/tmp/remotebuzzer_server.log`).
- If there is no errors logged but hardware buttons still 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.
- 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.
- Having trouble?
- Switch Photobooth to DEV mode. (admin screen -> expert view -> general section)
- Reload the Photobooth homepage
- Check the browser developer console for error logs
- Check the server logs for errors (file `data/tmp/remotebuzzer_server.log`)
- If there is no errors logged but hardware buttons still 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.
- 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,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
- 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

```
cat >> /etc/sudoers.d/020_www-data-shutdown << EOF
Expand All @@ -161,6 +232,7 @@ The server supports up to four connected hardware buttons for the following func
- 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
Expand All @@ -171,6 +243,7 @@ Note:
- 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 (Collage section), this button will do nothing.

Expand All @@ -180,6 +253,7 @@ Note:
- This button will initate a safe system shutdown and halt (`shutdown -h now`).

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).

Expand Down Expand Up @@ -223,9 +297,11 @@ GND --- GND
```

Known limitations:

- Delete Picture: in order to be able to access the Delete button through rotary control, please activate admin setting General -> "Delete images without confirm request"

The following elements are currently not supported and not accessible through rotary control navigation

- Full Screen Mode button: Looks like modern browser only allow to change to full screen mode upon user gesture. It seems not possible to change to full-screen using Javascript.
- Photoswipe download button: Not needed for Rotary Control. (well, if you can come up with a decent use-case, let us know).

Expand Down Expand Up @@ -302,9 +378,11 @@ There's different ways depending on your needs and personal setup:

#### Preview _"from device cam"_
If you access Photobooth on your Raspberry Pi you could use a Raspberry Pi Camera. Raspberry Pi Camera will be detected as "device cam".

- Admin panel config "Preview mode": `from device cam`

**Note:**

- Preview `"from device cam"` will always use the camera of the device where Photobooth get opened in a Browser (e.g. on a tablet it will always show the tablet camera while on a smartphone it will always show the smartphone camera instead)!
- Secure origin or exception required!
- [Prefer Secure Origins For Powerful New Features](https://medium.com/@Carmichaelize/enabling-the-microphone-camera-in-chrome-for-local-unsecure-origins-9c90c3149339)
Expand All @@ -314,16 +392,19 @@ If you access Photobooth on your Raspberry Pi you could use a Raspberry Pi Camer
#### Preview _"from URL"_
If you like to have the same preview independent of the device you access Photobooth from:
Make sure to have a stream available you can use (e.g. from your Webcam, Smartphone Camera or Raspberry Pi Camera)

- Admin panel config *"Preview mode"*: `from URL`
- Admin panel config *"Preview-URL"* example (add needed IP address instead): `url(http://127.0.0.1:8081)`

**Note**

- Do NOT enable *"Device cam takes picture"* in admin panel config!
- Capture pictures via `raspistill` won't work if motion is installed!
- Requires Photobooth v2.2.1 or later!

#### Preview _"from gohoto2"_
A preview can also be done using the video mode of your DSLR (Linux only), but only works if you access Photobooth via [http://localhost](http://localhost) or [http://127.0.0.1](http://localhost):

- Liveview **must** be supported for your camera model, [check here](http://gphoto.org/proj/libgphoto2/support.php)
- install all dependencies `sudo apt install ffmpeg v4l2loopback-dkms -y`
- create a virtual webcam `sudo modprobe v4l2loopback exclusive_caps=1 card_label="GPhoto2 Webcam"`
Expand All @@ -333,6 +414,7 @@ A preview can also be done using the video mode of your DSLR (Linux only), but o
- Admin panel config *"Preview mode"*: `from gphoto2`

**Note**

- Requires Photobooth v2.11.0 or later!
- You need to access Photobooth directly via [http://localhost](http://localhost) or [http://127.0.0.1](http://localhost), you won't be able to see the preview on a different device (e.g. Tablet)
- There's a delay of about 3 seconds until the preview starts, to avoid that disable the `Battery saving mode on gphoto2 live preview` option to generate a preview in background. **This results in a high battery usage and also a general slowdown.**
Expand Down Expand Up @@ -450,6 +532,7 @@ First head over to the hotspot directory to run the installer:
cd /var/www/html/vendor/rpihotspot
```
There are a couple of flags you need to change from the example command below:

- change `password` to your desired password, make it easy enough for guests to remember.
- change `country code` from `CA` to your own localization.
- keep or change the ip address `10.10.10.10`. Remember what you change it to.
Expand Down
18 changes: 18 additions & 0 deletions lib/configsetup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,24 @@
'name' => 'remotebuzzer[userotary]',
'value' => $config['remotebuzzer']['userotary'],
],
'remotebuzzer_usehid' => [
'view' => 'advanced',
'type' => 'checkbox',
'name' => 'remotebuzzer[usehid]',
'value' => $config['remotebuzzer']['usehid'],
],
'remotebuzzer_usesoftbtn' => [
'view' => 'advanced',
'type' => 'checkbox',
'name' => 'remotebuzzer[usesoftbtn]',
'value' => $config['remotebuzzer']['usesoftbtn'],
],
'remotebuzzer_usegpio' => [
'view' => 'advanced',
'type' => 'checkbox',
'name' => 'remotebuzzer[usegpio]',
'value' => $config['remotebuzzer']['usegpio'],
],
'remotebuzzer_picturebutton' => [
'view' => 'advanced',
'type' => 'checkbox',
Expand Down
10 changes: 8 additions & 2 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,11 @@
"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_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: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_usehid": "This feature enables HID Device support - see FAQ for details. Inside the picture section \"Key code which triggers a photo\" and inside collage section \"Key code which triggers a collage\" must be defined! 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:remotebuzzer:remotebuzzer_usesoftbtn": "This feature enables Software Button support - 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 @@ -535,7 +538,10 @@
"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_usehid": "Enable HID-Device Buttons",
"remotebuzzer:remotebuzzer_userotary": "Enable Rotary Encoder",
"remotebuzzer:remotebuzzer_usesoftbtn": "Enable Software Buttons",
"reset": "Reset",
"reset:reset_button": "Execute config reset",
"reset:reset_remove_config": "Delete personal configuration (my.config.inc.php)",
Expand Down
28 changes: 23 additions & 5 deletions src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1059,16 +1059,24 @@ const photoBooth = (function () {
// Take Picture Button
$('.takePic, .newpic').on('click', function (e) {
e.preventDefault();

api.thrill('photo');
if (config.remotebuzzer.usesoftbtn) {
remoteBuzzerClient.startPicture();
} else {
api.thrill('photo');
}
$('.newpic').blur();
});

// Take Collage Button
$('.takeCollage, .newcollage').on('click', function (e) {
e.preventDefault();

api.thrill('collage');
if (config.remotebuzzer.usesoftbtn) {
remoteBuzzerClient.startCollage();
} else {
api.thrill('collage');
}

$('.newcollage').blur();
});

Expand Down Expand Up @@ -1203,14 +1211,24 @@ const photoBooth = (function () {
$('.triggerPic').on('click', function (e) {
e.preventDefault();

api.thrill('photo');
if (config.remotebuzzer.usehid) {
remoteBuzzerClient.startPicture();
} else {
api.thrill('photo');
}

$('.newpic').blur();
});

$('.triggerCollage').on('click', function (e) {
e.preventDefault();

api.thrill('collage');
if (config.remotebuzzer.usehid) {
remoteBuzzerClient.startCollage();
} else {
api.thrill('collage');
}

$('.newcollage').blur();
});

Expand Down
Loading