Skip to content

Commit ec4dad1

Browse files
committed
doc(examples): Add docstrings to the example script functions
Added docstrings to all the remaining example scripts.
1 parent 429feb4 commit ec4dad1

12 files changed

Lines changed: 117 additions & 0 deletions

examples/01_Retrieving_Data/right_index_events_based.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616

1717
def process_right_index():
18+
"""
19+
Retrieve the pressure data for the right index finger from the etee driver. Print the values.
20+
"""
1821
right_index_pull = etee.get_index_pull('right')
1922
right_index_force = etee.get_index_force('right')
2023
current_time = datetime.now().strftime("%H:%M:%S.%f")

examples/01_Retrieving_Data/right_index_getter_function.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616

1717

1818
def process_right_index():
19+
"""
20+
Retrieve the pressure data for the right index finger from the etee driver.
21+
22+
:return: Index finger pull pressure and force pressure, from the right eteeController.
23+
:rtype: int, int
24+
"""
1925
right_index_pull = etee.get_index_pull('right')
2026
right_index_force = etee.get_index_force('right')
2127
return right_index_pull, right_index_force

examples/02_Print_Data/print_etee_euler_angles.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717

1818
def print_title():
19+
"""
20+
Print CLI graphics for the application title.
21+
"""
1922
print("======================================================")
2023
print(r" __ ___ ____ ____")
2124
print(r" ___ / /____ ___ / | / __ \/ _/")

examples/02_Print_Data/print_etee_finger_data.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313

1414

1515
def process_finger(dev, finger):
16+
"""
17+
Retrieve the selected device's finger values from the etee driver.
18+
19+
:param str dev: Selected device hand. Possible values: "left", "right".
20+
:param str finger: Selected finger. Possible values: "thumb", "index", "middle", "ring", "pinky".
21+
:return: Array containing the selected controller's index finger values: pull pressure, force pressure,
22+
touch and click.
23+
:rtype: list[Any]
24+
"""
1625
finger_pull = finger + "_pull"
1726
finger_force = finger + "_force"
1827
finger_touch = finger + "_touched"
@@ -24,6 +33,9 @@ def process_finger(dev, finger):
2433

2534

2635
def print_title():
36+
"""
37+
Print CLI graphics for the application title.
38+
"""
2739
print("======================================================")
2840
print(r" __ ___ ____ ____")
2941
print(r" ___ / /____ ___ / | / __ \/ _/")

examples/02_Print_Data/print_etee_fingers_all_data.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515

1616
def print_title():
17+
"""
18+
Print CLI graphics for the application title.
19+
"""
1720
print("======================================================")
1821
print(r" __ ___ ____ ____")
1922
print(r" ___ / /____ ___ / | / __ \/ _/")

examples/02_Print_Data/print_etee_imu.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414

1515
def print_title():
16+
"""
17+
Print CLI graphics for the application title.
18+
"""
1619
print("======================================================")
1720
print(r" __ ___ ____ ____")
1821
print(r" ___ / /____ ___ / | / __ \/ _/")
@@ -25,6 +28,14 @@ def print_title():
2528

2629

2730
def adjust_imu(original_arr, offsets_arr):
31+
"""
32+
Apply offsets to the original array.
33+
34+
:param list[int] original_arr: Original IMU (i.e. accel, gyro or mag) XYZ array without offsets.
35+
:param list[int] offsets_arr: Array of XYZ offsets to be applied to the original array.
36+
:return: Adjusted IMU array after applying offsets.
37+
:rtype: list[int]
38+
"""
2839
adj_arr = [0, 0, 0]
2940
if original_arr is None or offsets_arr is None:
3041
pass

examples/02_Print_Data/print_etee_quaternions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515

1616
def print_title():
17+
"""
18+
Print CLI graphics for the application title.
19+
"""
1720
print("======================================================")
1821
print(r" __ ___ ____ ____")
1922
print(r" ___ / /____ ___ / | / __ \/ _/")

examples/02_Print_Data/print_etee_slider_data.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,23 @@
1313

1414

1515
def process_slider(dev):
16+
"""
17+
Retrieve the selected device's slider values from the etee driver.
18+
19+
:param str dev: Selected device hand. Possible values: "left", "right".
20+
:return: Array containing the selected controller's slider values: Y-axis position, touch, up and down button values.
21+
:rtype: list[Any]
22+
"""
1623
slider = [etee.get_slider_value(dev),
1724
etee.get_slider_touched(dev),
1825
etee.get_slider_up_button(dev), etee.get_slider_down_button(dev)]
1926
return slider
2027

2128

2229
def print_title():
30+
"""
31+
Print CLI graphics for the application title.
32+
"""
2333
print("======================================================")
2434
print(r" __ ___ ____ ____")
2535
print(r" ___ / /____ ___ / | / __ \/ _/")

examples/02_Print_Data/print_etee_sliders_buttons.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,31 @@
1313

1414

1515
def process_left_slider_buttons():
16+
"""
17+
Retrieve the left slider button values from the etee driver.
18+
19+
:return: Array containing the left controller's slider button values: up and down button states.
20+
:rtype: list[bool]
21+
"""
1622
left_slider = [etee.get_slider_up_button('left'), etee.get_slider_down_button('left')]
1723
return left_slider
1824

1925

2026
def process_right_slider_buttons():
27+
"""
28+
Retrieve the right slider button values from the etee driver.
29+
30+
:return: Array containing the right controller's slider button values: up and down button states.
31+
:rtype: list[bool]
32+
"""
2133
right_slider = [etee.get_slider_up_button('right'), etee.get_slider_down_button('right')]
2234
return right_slider
2335

2436

2537
def print_title():
38+
"""
39+
Print CLI graphics for the application title.
40+
"""
2641
print("======================================================")
2742
print(r" __ ___ ____ ____")
2843
print(r" ___ / /____ ___ / | / __ \/ _/")
@@ -35,6 +50,14 @@ def print_title():
3550

3651

3752
def check_controller_connection(left_data, right_data):
53+
"""
54+
Check that both controllers are connected. If not, attempt re-connection.
55+
56+
:param str left_data: Left controller button values from the etee driver. If a controller disconnects, the values in the buffer will reset to None.
57+
:param str right_data: Right controller button values from the etee driver. If a controller disconnects, the values in the buffer will reset to None.
58+
:return: True if both controllers are still connected; False if otherwise
59+
:rtype: bool
60+
"""
3861
connection = True
3962
if left_data[0] == None and right_data[0] == None:
4063
print("---")
@@ -56,6 +79,7 @@ def check_controller_connection(left_data, right_data):
5679
connection = False
5780
return connection
5881

82+
5983
if __name__ == "__main__":
6084
# Initialise the etee driver and find dongle
6185
etee = EteeController()

examples/02_Print_Data/print_etee_trackpad_data.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,24 @@
1313

1414

1515
def process_trackpad(dev):
16+
"""
17+
Retrieve the selected device's trackpad values from the etee driver.
18+
19+
:param str dev: Selected device hand. Possible values: "left", "right".
20+
:return: Two arrays containing the selected controller's trackpad values. One containing the location
21+
(X-axis position, Y-axis position), and another the pressure (pull pressure, force pressure, touch and click).
22+
:rtype: list[int], list[Any]
23+
"""
1624
loc = [etee.get_data(dev, "trackpad_x"), etee.get_data(dev, "trackpad_y")]
1725
pressure = [etee.get_data(dev, "trackpad_pull"), etee.get_data(dev, "trackpad_force"),
1826
etee.get_data(dev, "trackpad_touched"), etee.get_data(dev, "trackpad_clicked")]
1927
return loc, pressure
2028

2129

2230
def print_title():
31+
"""
32+
Print CLI graphics for the application title.
33+
"""
2334
print("======================================================")
2435
print(r" __ ___ ____ ____")
2536
print(r" ___ / /____ ___ / | / __ \/ _/")

0 commit comments

Comments
 (0)