From 5a424de913f40b9d275af95c46cd7693ed3ff161 Mon Sep 17 00:00:00 2001 From: jasondaming Date: Thu, 7 Dec 2023 19:08:35 -0600 Subject: [PATCH] changed line numbers with example update --- .../basic-programming/robot-preferences.rst | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source/docs/software/basic-programming/robot-preferences.rst b/source/docs/software/basic-programming/robot-preferences.rst index 60009d04a8..b60267fbac 100644 --- a/source/docs/software/basic-programming/robot-preferences.rst +++ b/source/docs/software/basic-programming/robot-preferences.rst @@ -36,13 +36,13 @@ Initializing Preferences .. tab-item:: Python :sync: Python - .. rli:: https://raw.githubusercontent.com/robotpy/examples/7a03f44e977af11c842a898afbab886d3e23d8ba/arm-simulation/robot.py + .. rli:: https://raw.githubusercontent.com/robotpy/examples/7a03f44e977af11c842a898afbab886d3e23d8ba/arm-simulation/constants.py :language: python - :lines: 18-20,26-29 + :lines: 16-21 - .. rli:: https://raw.githubusercontent.com/robotpy/examples/7a03f44e977af11c842a898afbab886d3e23d8ba/arm-simulation/robot.py + .. rli:: https://raw.githubusercontent.com/robotpy/examples/7a03f44e977af11c842a898afbab886d3e23d8ba/arm-simulation/subsytems/arm.py :language: python - :lines: 39-44 + :lines: 18-21,35-39 Preferences are stored using a name, the key. It's helpful to store the key in a constant, like ``kArmPositionKey`` and ``kArmPKey`` in the code above to avoid typing it multiple times and avoid typos. We also declare variables, ``kArmKp`` and ``armPositionDeg`` to hold the data retrieved from preferences. @@ -72,9 +72,9 @@ Reading Preferences .. tab-item:: Python :sync: Python - .. rli:: https://raw.githubusercontent.com/robotpy/examples/7a03f44e977af11c842a898afbab886d3e23d8ba/arm-simulation/robot.py + .. rli:: https://raw.githubusercontent.com/robotpy/examples/7a03f44e977af11c842a898afbab886d3e23d8ba/arm-simulation/subsytems/arm.py :language: python - :lines: 46-53 + :lines: 41-48 Reading a preference is easy. The ``getDouble`` method takes two parameters, the key to read, and a default value to use in case the preference doesn't exist. There are similar methods for other data types like booleans, ints, and strings. @@ -107,7 +107,10 @@ Depending on the data that is stored in preferences, you can use it when you rea .. rli:: https://raw.githubusercontent.com/robotpy/examples/7a03f44e977af11c842a898afbab886d3e23d8ba/arm-simulation/robot.py :language: python - :lines: 55-65 + :lines: 21-27 + .. rli:: https://raw.githubusercontent.com/robotpy/examples/7a03f44e977af11c842a898afbab886d3e23d8ba/arm-simulation/subsytems/arm.py + :language: python + :lines: 50-55 Using Preferences in SmartDashboard -----------------------------------