Skip to content

Commit

Permalink
DofCallback - add support to check all configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubAndrysek committed Mar 25, 2021
1 parent df4d896 commit 11d4fe0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ docs/_build/
# PyBuilder
target/

Release.md
release.md
release.sh
html
30 changes: 29 additions & 1 deletion pyspacemouse/pyspacemouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Callable, Union, List

# current version number
__version__ = "1.0.2"
__version__ = "1.0.3"

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

class DofCallback:
"""Register new DoF callback"""

def __init__(
self,
axis: str,
callback: Callable[[int], None],
sleep: float = 0.0,
callback_minus: Callable[[int], None] = None,
filter: float = 0.0
):
self.axis = axis
self.callback = callback
self.sleep = sleep
self.callback_minus = callback_minus
self.filter = filter

def check_dof_callback_arr(dof_callback_arr: List[DofCallback]) -> List[DofCallback]:
"""Check that the dof_callback_arr has the correct components.
Expand Down Expand Up @@ -780,6 +796,18 @@ def check_dof_callback_arr(dof_callback_arr: List[DofCallback]) -> List[DofCallb
pass
else:
raise Exception(f"'DofCallback[{num}]:sleep' is not type float")

# is callback_minus callable
if dof_call.callback_minus and callable(dof_call.callback_minus):
pass
else:
raise Exception(f"'DofCallback[{num}]:callback_minus' is not callable")

# is filter type float
if dof_call.filter and type(dof_call.filter) is float:
pass
else:
raise Exception(f"'DofCallback[{num}]:filter' is not type float")
else:
raise Exception(f"'DofCallback[{num}]' is not instance of 'DofCallback'")
return dof_callback_arr
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setuptools.setup(
name='pyspacemouse',
version='1.0.2',
version='1.0.3',
author='Jakub Andrýsek',
author_email='[email protected]',
description='Multiplatform Python interface to the 3DConnexion Space Mouse - forked from pyspacenavigator',
Expand Down

0 comments on commit 11d4fe0

Please sign in to comment.