Skip to content

Commit 097a6b2

Browse files
committed
Make DutyCycleEncoder a component.
1 parent 72ced67 commit 097a6b2

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

python_tools/json_util.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,21 @@ def _processComponent(self, class_data, constructor_data, declaring_class_name,
520520
class_data[_KEY_IS_COMPONENT] = True
521521
return
522522

523+
if declaring_class_name == 'wpilib.DutyCycleEncoder':
524+
if (len(arg_names) == 4 and
525+
arg_names[0] == 'self' and
526+
arg_names[1] == 'channel' and
527+
arg_names[2] == 'fullRange' and
528+
arg_names[3] == 'expectedZero'):
529+
args = []
530+
args.append(self._createArgData('smart_io_port', 'SYSTEMCORE_SMART_IO_PORT'))
531+
args.append(self._createArgData('full_range', self._getClassName(arg_types[2]), '1'))
532+
args.append(self._createArgData('expected_zero', self._getClassName(arg_types[3]), '0'))
533+
constructor_data[_KEY_COMPONENT_ARGS] = args
534+
constructor_data[_KEY_IS_COMPONENT] = True
535+
class_data[_KEY_IS_COMPONENT] = True
536+
return
537+
523538
if declaring_class_name == 'wpilib.OnboardIMU':
524539
if (len(arg_names) == 2 and
525540
arg_names[0] == 'self' and

src/blocks/utils/generated/robotpy_data.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5463,8 +5463,26 @@
54635463
"type": "float"
54645464
}
54655465
],
5466+
"componentArgs": [
5467+
{
5468+
"defaultValue": "",
5469+
"name": "smart_io_port",
5470+
"type": "SYSTEMCORE_SMART_IO_PORT"
5471+
},
5472+
{
5473+
"defaultValue": "1",
5474+
"name": "full_range",
5475+
"type": "float"
5476+
},
5477+
{
5478+
"defaultValue": "0",
5479+
"name": "expected_zero",
5480+
"type": "float"
5481+
}
5482+
],
54665483
"declaringClassName": "wpilib.DutyCycleEncoder",
54675484
"functionName": "__init__",
5485+
"isComponent": true,
54685486
"returnType": "wpilib.DutyCycleEncoder",
54695487
"tooltip": "Construct a new DutyCycleEncoder on a specific channel.\n\n:param channel: the channel to attach to\n:param fullRange: the value to report at maximum travel\n:param expectedZero: the reading where you would expect a 0 from get()"
54705488
},
@@ -5643,7 +5661,7 @@
56435661
}
56445662
],
56455663
"instanceVariables": [],
5646-
"isComponent": false,
5664+
"isComponent": true,
56475665
"moduleName": "wpilib",
56485666
"staticMethods": []
56495667
},

0 commit comments

Comments
 (0)