Skip to content

Commit 11d4fe0

Browse files
committed
DofCallback - add support to check all configuration
1 parent df4d896 commit 11d4fe0

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,6 @@ docs/_build/
5959
# PyBuilder
6060
target/
6161

62-
Release.md
62+
release.md
63+
release.sh
6364
html

pyspacemouse/pyspacemouse.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import Callable, Union, List
66

77
# current version number
8-
__version__ = "1.0.2"
8+
__version__ = "1.0.3"
99

1010
# clock for timing
1111
high_acc_clock = timeit.default_timer
@@ -753,6 +753,22 @@ def check_button_callback_arr(button_callback_arr: List[ButtonCallback]) -> List
753753
raise Exception(f"'ButtonCallback[{num}]' is not instance of 'ButtonCallback'")
754754
return button_callback_arr
755755

756+
class DofCallback:
757+
"""Register new DoF callback"""
758+
759+
def __init__(
760+
self,
761+
axis: str,
762+
callback: Callable[[int], None],
763+
sleep: float = 0.0,
764+
callback_minus: Callable[[int], None] = None,
765+
filter: float = 0.0
766+
):
767+
self.axis = axis
768+
self.callback = callback
769+
self.sleep = sleep
770+
self.callback_minus = callback_minus
771+
self.filter = filter
756772

757773
def check_dof_callback_arr(dof_callback_arr: List[DofCallback]) -> List[DofCallback]:
758774
"""Check that the dof_callback_arr has the correct components.
@@ -780,6 +796,18 @@ def check_dof_callback_arr(dof_callback_arr: List[DofCallback]) -> List[DofCallb
780796
pass
781797
else:
782798
raise Exception(f"'DofCallback[{num}]:sleep' is not type float")
799+
800+
# is callback_minus callable
801+
if dof_call.callback_minus and callable(dof_call.callback_minus):
802+
pass
803+
else:
804+
raise Exception(f"'DofCallback[{num}]:callback_minus' is not callable")
805+
806+
# is filter type float
807+
if dof_call.filter and type(dof_call.filter) is float:
808+
pass
809+
else:
810+
raise Exception(f"'DofCallback[{num}]:filter' is not type float")
783811
else:
784812
raise Exception(f"'DofCallback[{num}]' is not instance of 'DofCallback'")
785813
return dof_callback_arr

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
setuptools.setup(
1313
name='pyspacemouse',
14-
version='1.0.2',
14+
version='1.0.3',
1515
author='Jakub Andrýsek',
1616
author_email='email@kubaandrysek.cz',
1717
description='Multiplatform Python interface to the 3DConnexion Space Mouse - forked from pyspacenavigator',

0 commit comments

Comments
 (0)