Skip to content

Commit

Permalink
Implemented custom param (#99)
Browse files Browse the repository at this point in the history
Implement motor controller custom params
  • Loading branch information
joelbryla authored and auscompgeek committed Feb 2, 2019
1 parent 58102e9 commit b72d0fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 7 additions & 0 deletions gen/MotController_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ c_MotController_Create1:
'vel_measurement_period': 0,
'vel_measurement_window': 0,
"custom_param_0": 0,
"custom_param_1": 0,
# Quadrature encoder data
'quad_position': 0,
Expand Down Expand Up @@ -1374,6 +1377,8 @@ c_MotController_HasResetOccurred:
doc: |
:returns: Returns true if the device has reset since last call
c_MotController_ConfigSetCustomParam:
code: |
self.hal_data["custom_param_%d" % paramIndex] = newValue
doc: |
Sets the value of a custom parameter. This is for arbitrary use.
Expand All @@ -1391,6 +1396,8 @@ c_MotController_ConfigSetCustomParam:
If zero, no blocking or checking is performed.
:returns: Error Code generated by function. 0 indicates no error.
c_MotController_ConfigGetCustomParam:
code: |
retval = self.hal_data["custom_param_%d" % paramIndex]
doc: |
Gets the value of a custom parameter.
Expand Down
11 changes: 6 additions & 5 deletions tests/test_talonsrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,10 @@ def test_basemotorcontroller_configForwardSoftLimitThreshold(talon, cdata):
assert cdata["soft_limit_for"] == 1


@pytest.mark.xfail(raises=NotImplementedError)
def test_basemotorcontroller_configGetCustomParam(talon):
talon.configGetCustomParam(1, 2)
def test_basemotorcontroller_configGetCustomParam(talon, cdata):
cdata["custom_param_1"] = 10
param = talon.configGetCustomParam(1, 2)
assert param == 10 == cdata["custom_param_1"]


config_data = [
Expand Down Expand Up @@ -296,9 +297,9 @@ def test_basemotorcontroller_configSensorTerm(talon, cdata):
assert cdata["sensor_term"] == (5, 6)


@pytest.mark.xfail(raises=NotImplementedError)
def test_basemotorcontroller_configSetCustomParam(talon):
def test_basemotorcontroller_configSetCustomParam(talon, cdata):
talon.configSetCustomParam(1, 2, 3)
assert cdata["custom_param_2"] == 1


def test_basemotorcontroller_configVelocityMeasurementPeriod(talon, cdata):
Expand Down

0 comments on commit b72d0fe

Please sign in to comment.