Skip to content

Commit 2a9c4a3

Browse files
committed
docs: document utility helpers
1 parent 28932af commit 2a9c4a3

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Start with one of the tutorials below or explore the API reference.
2727
tutorials/build_stimulus
2828
tutorials/send_trigger
2929
tutorials/cli_usage
30+
tutorials/utilities
3031

3132

3233
.. toctree::

docs/tutorials/utilities.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Utility Helpers
2+
3+
These small helper functions streamline common setup tasks.
4+
5+
## `initialize_exp`
6+
7+
Initialize the PsychoPy window and keyboard while setting up logging.
8+
9+
```python
10+
from psyflow import initialize_exp, TaskSettings
11+
12+
settings = TaskSettings.from_dict({"fullscreen": False})
13+
win, kb = initialize_exp(settings)
14+
```
15+
16+
## `count_down`
17+
18+
Display a simple countdown before the experiment starts.
19+
20+
```python
21+
from psyflow import count_down
22+
23+
count_down(win, seconds=3, color="white")
24+
```
25+
26+
## `list_serial_ports`
27+
28+
Quickly list available serial ports (alias of `show_ports`).
29+
30+
```python
31+
from psyflow import list_serial_ports
32+
33+
list_serial_ports() # prints numbered ports to the console
34+
```
35+
36+
## `list_supported_voices`
37+
38+
Retrieve available voices for speech synthesis via `edge-tts`.
39+
40+
```python
41+
from psyflow import list_supported_voices
42+
43+
voices = list_supported_voices(filter_lang="en")
44+
print(voices[0]["ShortName"]) # Inspect voice attributes
45+
```
46+
47+
Use `list_supported_voices(human_readable=True)` to print a formatted table.

psyflow/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ def show_ports():
2121
print(f"[{i}] {p.device} - {p.description}")
2222

2323

24+
def list_serial_ports():
25+
"""Alias for :func:`show_ports`.
26+
27+
Returns
28+
-------
29+
None
30+
This function simply calls :func:`show_ports` and prints the ports.
31+
"""
32+
return show_ports()
33+
34+
2435

2536

2637
from cookiecutter.main import cookiecutter

0 commit comments

Comments
 (0)