Skip to content

Commit 4eb3c69

Browse files
authored
Merge branch 'future3/develop' into future3/fix-docker-windows
2 parents b1b321c + 07208e6 commit 4eb3c69

File tree

14 files changed

+686
-108
lines changed

14 files changed

+686
-108
lines changed

.github/workflows/bundle_webapp_and_release_v3.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
tar -czvf ${{ steps.vars.outputs.webapp_bundle_name }} build
102102
103103
- name: Artifact Upload
104-
uses: actions/upload-artifact@v3
104+
uses: actions/upload-artifact@v4
105105
with:
106106
name: ${{ steps.vars.outputs.webapp_bundle_name }}
107107
path: ${{ steps.build-webapp.outputs.webapp-root-path }}/${{ steps.vars.outputs.webapp_bundle_name }}
@@ -119,7 +119,7 @@ jobs:
119119

120120
steps:
121121
- name: Artifact Download
122-
uses: actions/download-artifact@v3
122+
uses: actions/download-artifact@v4
123123
with:
124124
name: ${{ needs.build.outputs.webapp_bundle_name }}
125125

.github/workflows/test_docker_debian_codename_sub_v3.yml

+14-14
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134
BASE_TEST_IMAGE=${{ steps.vars.outputs.image_tag_name_local_base }}
135135
136136
- name: Artifact Upload Docker Image
137-
uses: actions/upload-artifact@v3
137+
uses: actions/upload-artifact@v4
138138
with:
139139
name: ${{ steps.vars.outputs.image_file_name }}
140140
path: ${{ steps.vars.outputs.image_file_path }}
@@ -159,7 +159,7 @@ jobs:
159159
uses: docker/[email protected]
160160

161161
- name: Artifact Download Docker Image
162-
uses: actions/download-artifact@v3
162+
uses: actions/download-artifact@v4
163163
with:
164164
name: ${{ needs.build.outputs.image_file_name }}
165165

@@ -177,15 +177,15 @@ jobs:
177177
args: |
178178
./${{ matrix.test_script }}
179179
180-
# cleanup after test execution
181-
cleanup:
182-
# run only if tests didn't fail: keep the artifact to make job reruns possible
183-
if: ${{ !failure() }}
184-
needs: [build, test]
185-
runs-on: ${{ inputs.runs_on }}
186-
187-
steps:
188-
- name: Artifact Delete Docker Image
189-
uses: geekyeggo/delete-artifact@v2
190-
with:
191-
name: ${{ needs.build.outputs.image_file_name }}
180+
## cleanup after test execution
181+
#cleanup:
182+
# # run only if tests didn't fail: keep the artifact to make job reruns possible
183+
# if: ${{ !failure() }}
184+
# needs: [build, test]
185+
# runs-on: ${{ inputs.runs_on }}
186+
#
187+
# steps:
188+
# - name: Artifact Delete Docker Image
189+
# uses: geekyeggo/delete-artifact@v4
190+
# with:
191+
# name: ${{ needs.build.outputs.image_file_name }}

docker/armv7/jukebox.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ WORKDIR ${HOME}
6565
COPY --chown=${USER}:${USER} . ${INSTALLATION_PATH}/
6666

6767
RUN pip install --no-cache-dir -r ${INSTALLATION_PATH}/requirements.txt
68-
RUN pip install --no-cache-dir --pre --no-binary pyzmq pyzmq
68+
RUN pip install --no-cache-dir --no-binary pyzmq pyzmq
6969

7070
EXPOSE 5555 5556
7171

documentation/builders/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* [Soundcards](./components/soundcards/)
2727
* [HiFiBerry Boards](./components/soundcards/hifiberry.md)
2828
* [RFID Readers](./../developers/rfid/README.md)
29+
* [Event devices (USB and other buttons)](./event-devices.md)
2930

3031
## Web Application
3132

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Event devices
2+
3+
## Background
4+
Event devices are generic input devices that are exposed in `/dev/input`.
5+
This includes USB peripherals (Keyboards, Controllers, Joysticks or Mouse) as well as potentially bluetooth devices.
6+
7+
A specific usecase for this could be, if a Zero Delay Arcade USB Encoder is used to wire arcade buttons instead of using GPIO pins.
8+
9+
These device interface support various kinds of input events, such as press, movements and potentially also outputs (eg. rumble, led lights, ...). Currently only the usage of button presses as input is supported.
10+
11+
This functionality was previously implemented under the name of [USB buttons](https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/develop/components/controls/buttons_usb_encoder/README.md).
12+
13+
The devices and their button mappings need to be mapped in the configuration file.
14+
15+
## Configuration
16+
17+
To configure event devices, first add the plugin as an entry to the module list of your main configuration file ``shared/settings/jukebox.yaml``:
18+
19+
``` yaml
20+
modules:
21+
named:
22+
event_devices: controls.event_devices
23+
```
24+
25+
And add the following section with the plugin specific configuration:
26+
``` yaml
27+
evdev:
28+
enabled: true
29+
config_file: ../../shared/settings/evdev.yaml
30+
```
31+
32+
The actual configuration itself is stored in a separate file. In this case in ``../../shared/settings/evdev.yaml``.
33+
34+
The configuration is structured akin to the configuration of the [GPIO devices](./gpio.md).
35+
36+
In contrast to `gpio`, multiple devices (eg arcade controllser, keyboards, joysticks, mice, ...) are supported, each with their own `input_devices` (=buttons). `output_devices` or actions other than `on_press` are currently not yet supported.
37+
38+
``` yaml
39+
devices: # list of devices to listen for
40+
{device nickname}: # config for a specific device
41+
device_name: {device_name} # name of the device
42+
exact: False/True # optional to require exact match. Otherwise it is sufficient that a part of the name matches
43+
input_devices: # list of buttons to listen for for this device
44+
{button nickname}:
45+
type: Button
46+
kwargs:
47+
key_code: {key-code}: # evdev event id
48+
actions:
49+
on_press: # Currently only the on_press action is supported
50+
{rpc_command_definition} # eg `alias: toggle`
51+
```
52+
The `{device nickname}` is only for your own orientation and can be choosen freely.
53+
For each device you need to figure out the `{device_name}` and the `{event_id}` corresponding to key strokes, as indicated in the sections below.
54+
55+
### Identifying the `{device_name}`
56+
57+
The `{device_name}` can be identified using the following Python snippet:
58+
59+
``` Python
60+
import evdev
61+
devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
62+
for device in devices:
63+
print(device.path, device.name, device.phys)
64+
```
65+
66+
The output could be in the style of:
67+
68+
```
69+
/dev/input/event1 Dell Dell USB Keyboard usb-0000:00:12.1-2/input0
70+
/dev/input/event0 Dell USB Optical Mouse usb-0000:00:12.0-2/input0
71+
```
72+
73+
In this example, the `{device_name}` could be `DELL USB Optical Mouse`.
74+
Note that if you use the option `exact: False`, it would be sufficient to add a substring such as `USB Keyboard`.
75+
76+
### Identifying the `{key-code}`
77+
78+
The key code for a button press can be determined using the following code snippet:
79+
80+
``` Python
81+
import evdev
82+
device = evdev.InputDevice('/dev/input/event0')
83+
device.capabilities(verbose=True)[('EV_KEY', evdev.ecodes.EV_KEY)]
84+
```
85+
86+
With the `InputDevice` corresponding to the path from the output of the section `{device_name}` (eg. in the example `/dev/input/event0`
87+
would correspond to `Dell Dell USB Keyboard`).
88+
89+
If the naming is not clear, it is also possible to empirically check for the key code by listening for events:
90+
91+
``` Python
92+
from evdev import InputDevice, categorize, ecodes
93+
dev = InputDevice('/dev/input/event1')
94+
print(dev)
95+
for event in dev.read_loop():
96+
if event.type == ecodes.EV_KEY:
97+
print(categorize(event))
98+
```
99+
The output could be of the form:
100+
```
101+
device /dev/input/event1, name "DragonRise Inc. Generic USB Joystick ", phys "usb-3f980000.usb-1.2/input0"
102+
key event at 1672569673.124168, 297 (BTN_BASE4), down
103+
key event at 1672569673.385170, 297 (BTN_BASE4), up
104+
```
105+
106+
In this example output, the `{key-code}` would be `297`
107+
108+
Alternatively, the device could also be setup without a mapping.
109+
Afterwards, when pressing keys, the key codes can be found in the log files. Press various buttons on your device,
110+
while watching the logs with `tail -f shared/logs/app.log`.
111+
Look for entries like `No callback registered for button ...`.
112+
113+
### Specifying the `{rpc_command_definition}`
114+
115+
The RPC command follows the regular RPC command rules as defined in the [following documentation](./rpc-commands.md).
116+
117+
118+
## Full example config
119+
120+
A complete configuration example for a USB Joystick controller can be found in the [examples](../../resources/default-settings/evdev.example.yaml).

documentation/developers/docker.md

+14
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,20 @@ $ docker run -it --rm \
291291
--name jukebox jukebox
292292
```
293293

294+
## Testing EVDEV devices in Linux
295+
To test the [event device capabilities](../builders/event-devices.md) in docker, the device needs to be made available to the container.
296+
297+
### Linux
298+
Mount the device into the container by configuring the appropriate device in a `devices` section of the `jukebox` service in the docker compose file. For example:
299+
300+
```yaml
301+
jukebox:
302+
...
303+
devices:
304+
- /dev/input/event3:/dev/input/event3
305+
```
306+
307+
294308
### Resources
295309

296310
#### Mac

documentation/developers/docstring/README.md

+65-32
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@
104104
* [pbox\_set\_state](#components.rfid.hardware.fake_reader_gui.gpioz_gui_addon.pbox_set_state)
105105
* [que\_set\_pbox](#components.rfid.hardware.fake_reader_gui.gpioz_gui_addon.que_set_pbox)
106106
* [create\_outputs](#components.rfid.hardware.fake_reader_gui.gpioz_gui_addon.create_outputs)
107+
* [components.rfid.hardware.generic\_nfcpy.description](#components.rfid.hardware.generic_nfcpy.description)
108+
* [components.rfid.hardware.generic\_nfcpy.generic\_nfcpy](#components.rfid.hardware.generic_nfcpy.generic_nfcpy)
109+
* [ReaderClass](#components.rfid.hardware.generic_nfcpy.generic_nfcpy.ReaderClass)
110+
* [cleanup](#components.rfid.hardware.generic_nfcpy.generic_nfcpy.ReaderClass.cleanup)
111+
* [stop](#components.rfid.hardware.generic_nfcpy.generic_nfcpy.ReaderClass.stop)
112+
* [read\_card](#components.rfid.hardware.generic_nfcpy.generic_nfcpy.ReaderClass.read_card)
107113
* [components.rfid.hardware.generic\_usb.description](#components.rfid.hardware.generic_usb.description)
108114
* [components.rfid.hardware.generic\_usb.generic\_usb](#components.rfid.hardware.generic_usb.generic_usb)
109115
* [components.rfid.hardware.rc522\_spi.description](#components.rfid.hardware.rc522_spi.description)
@@ -1948,6 +1954,61 @@ Add all output devices to the GUI
19481954

19491955
List of all added GUI objects
19501956

1957+
<a id="components.rfid.hardware.generic_nfcpy.description"></a>
1958+
1959+
# components.rfid.hardware.generic\_nfcpy.description
1960+
1961+
List of supported devices https://nfcpy.readthedocs.io/en/latest/overview.html
1962+
1963+
1964+
<a id="components.rfid.hardware.generic_nfcpy.generic_nfcpy"></a>
1965+
1966+
# components.rfid.hardware.generic\_nfcpy.generic\_nfcpy
1967+
1968+
<a id="components.rfid.hardware.generic_nfcpy.generic_nfcpy.ReaderClass"></a>
1969+
1970+
## ReaderClass Objects
1971+
1972+
```python
1973+
class ReaderClass(ReaderBaseClass)
1974+
```
1975+
1976+
The reader class for nfcpy supported NFC card readers.
1977+
1978+
1979+
<a id="components.rfid.hardware.generic_nfcpy.generic_nfcpy.ReaderClass.cleanup"></a>
1980+
1981+
#### cleanup
1982+
1983+
```python
1984+
def cleanup()
1985+
```
1986+
1987+
The cleanup function: free and release all resources used by this card reader (if any).
1988+
1989+
1990+
<a id="components.rfid.hardware.generic_nfcpy.generic_nfcpy.ReaderClass.stop"></a>
1991+
1992+
#### stop
1993+
1994+
```python
1995+
def stop()
1996+
```
1997+
1998+
This function is called to tell the reader to exit its reading function.
1999+
2000+
2001+
<a id="components.rfid.hardware.generic_nfcpy.generic_nfcpy.ReaderClass.read_card"></a>
2002+
2003+
#### read\_card
2004+
2005+
```python
2006+
def read_card() -> str
2007+
```
2008+
2009+
Blocking or non-blocking function that waits for a new card to appear and return the card's UID as string
2010+
2011+
19512012
<a id="components.rfid.hardware.generic_usb.description"></a>
19522013

19532014
# components.rfid.hardware.generic\_usb.description
@@ -2659,7 +2720,7 @@ def stop_autohotspot()
26592720

26602721
Stop auto hotspot functionality
26612722

2662-
Basically disabling the cronjob and running the script one last time manually
2723+
Stopping and disabling the timer and running the service one last time manually
26632724

26642725

26652726
<a id="components.hostif.linux.start_autohotspot"></a>
@@ -2671,9 +2732,9 @@ Basically disabling the cronjob and running the script one last time manually
26712732
def start_autohotspot()
26722733
```
26732734

2674-
start auto hotspot functionality
2735+
Start auto hotspot functionality
26752736

2676-
Basically enabling the cronjob and running the script one time manually
2737+
Enabling and starting the timer (timer will start the service)
26772738

26782739

26792740
<a id="components.misc"></a>
@@ -2966,35 +3027,7 @@ class battmon_ads1015(BatteryMonitorBase.BattmonBase)
29663027

29673028
Battery Monitor based on a ADS1015
29683029

2969-
> [!CAUTION]
2970-
> Lithium and other batteries are dangerous and must be treated with care.
2971-
> Rechargeable Lithium Ion batteries are potentially hazardous and can
2972-
> present a serious **FIRE HAZARD** if damaged, defective or improperly used.
2973-
> Do not use this circuit to a lithium ion battery without expertise and
2974-
> training in handling and use of batteries of this type.
2975-
> Use appropriate test equipment and safety protocols during development.
2976-
> There is no warranty, this may not work as expected or at all!
2977-
2978-
This script is intended to read out the Voltage of a single Cell LiIon Battery using a CY-ADS1015 Board:
2979-
2980-
3.3V
2981-
+
2982-
|
2983-
.----o----.
2984-
___ | | SDA
2985-
.--------|___|---o----o---------o AIN0 o------
2986-
| 2MΩ | | | | SCL
2987-
| .-. | | ADS1015 o------
2988-
--- | | --- | |
2989-
Battery - 1.5MΩ| | ---100nF '----o----'
2990-
2.9V-4.2V| '-' | |
2991-
| | | |
2992-
=== === === ===
2993-
2994-
Attention:
2995-
* the circuit is constantly draining the battery! (leak current up to: 2.1µA)
2996-
* the time between sample needs to be a minimum 1sec with this high impedance voltage divider
2997-
don't use the continuous conversion method!
3030+
See [Battery Monitor documentation](../../builders/components/power/batterymonitor.md)
29983031

29993032

30003033
<a id="components.gpio.gpioz.plugin"></a>

documentation/developers/rfid/mock_reader.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ machine - probably in a Python virtual environment.
66

77
**place-capable**: yes
88

9-
If you [mock the GPIO pins](../../../src/jukebox/components/gpio/gpioz/README.rst#use-mock-pins), this GUI will show the GPIO devices.
9+
If you [mock the GPIO pins](../../builders/gpio.md#use-mock-pins), this GUI will show the GPIO devices.
1010

1111
![image](mock_reader.png)
1212

installation/routines/setup_jukebox_core.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ _jukebox_core_build_and_install_pyzmq() {
8686
fi
8787

8888
ZMQ_PREFIX="${JUKEBOX_ZMQ_PREFIX}" ZMQ_DRAFT_API=1 \
89-
pip install -v --no-binary pyzmq --pre pyzmq
89+
pip install -v --no-binary pyzmq pyzmq
9090
else
9191
print_lc " Skipping. pyzmq already installed"
9292
fi

0 commit comments

Comments
 (0)