From ab384b464bcf7504e70f21d02e7cd9c57977174b Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Tue, 29 Dec 2020 12:08:29 +0100 Subject: [PATCH] doc/pupdevices/colordistancesensor: split examples Now that each sensor is on its own page, we no longer need to collapse snippets to reduce page size. Now they can just all be at the bottom of the page. This also gives each a dedicated link which is easier when giving support. --- doc/api/pupdevices/colordistancesensor.rst | 102 ++++++++++----------- 1 file changed, 49 insertions(+), 53 deletions(-) diff --git a/doc/api/pupdevices/colordistancesensor.rst b/doc/api/pupdevices/colordistancesensor.rst index 40ffdee..328b423 100644 --- a/doc/api/pupdevices/colordistancesensor.rst +++ b/doc/api/pupdevices/colordistancesensor.rst @@ -4,26 +4,6 @@ Color and Distance Sensor .. figure:: ../../api/images/sensor_colordistance.png :width: 35 % -.. toggle-header:: - :header: **Show/hide examples** - - - **Example 1: Measuring color** - - .. literalinclude:: - ../../../examples/pup/sensor_color_distance/color_print.py - - - **Example 2: Waiting for a color** - - .. literalinclude:: - ../../../examples/pup/sensor_color_distance/wait_for_color.py - - **Example 3: Measuring distance** - - .. literalinclude:: - ../../../examples/pup/sensor_color_distance/distance_blink.py - .. autoclass:: pybricks.pupdevices.ColorDistanceSensor :no-members: @@ -35,31 +15,6 @@ Color and Distance Sensor .. automethod:: pybricks.pupdevices.ColorDistanceSensor.distance - .. rubric:: Advanced color sensing - - .. toggle-header:: - :header: **Show/hide examples** - - **Example 1: Reading hue, saturation, and value** - - .. literalinclude:: - ../../../examples/pup/sensor_color_distance/hsv.py - - - **Example 2: Changing the detectable colors** - - By default, the sensor is configured to detect red, yellow, green, - blue, white, or ``None``, which suits many applications. - - For better results in your application, you can measure your desired - colors in advance, and tell the sensor to look only for those colors. - Be sure to measure them at the **same distance and light conditions** - as in your final application. Then you'll get very accurate results - even for colors that are otherwise hard to detect. - - .. literalinclude:: - ../../../examples/pup/sensor_color_distance/detectable_colors.py - .. automethod:: pybricks.pupdevices.ColorDistanceSensor.hsv .. automethod:: pybricks.pupdevices.ColorDistanceSensor.detectable_colors @@ -70,14 +25,55 @@ Color and Distance Sensor it off. If you use the sensor to measure something afterwards, the light automatically turns back on at the default color for that sensing method. - .. toggle-header:: - :header: **Show/hide examples** - - **Example: Blinking the built-in light** - - .. literalinclude:: - ../../../examples/pup/sensor_color_distance/distance_blink.py - .. automethod:: pybricks.pupdevices::ColorDistanceSensor.light.on .. automethod:: pybricks.pupdevices::ColorDistanceSensor.light.off + +Examples +------------------- + +Measuring color +*************** + +.. literalinclude:: + ../../../examples/pup/sensor_color_distance/color_print.py + + +Waiting for a color +******************* + +.. literalinclude:: + ../../../examples/pup/sensor_color_distance/wait_for_color.py + +Measuring distance +****************** + +.. literalinclude:: + ../../../examples/pup/sensor_color_distance/distance_blink.py + +Blinking the built-in light +*************************** + +.. literalinclude:: + ../../../examples/pup/sensor_color_distance/distance_blink.py + +Reading hue, saturation, value +********************************** + +.. literalinclude:: + ../../../examples/pup/sensor_color_distance/hsv.py + +Changing the detectable colors +****************************** + +By default, the sensor is configured to detect red, yellow, green, +blue, white, or ``None``, which suits many applications. + +For better results in your application, you can measure your desired +colors in advance, and tell the sensor to look only for those colors. +Be sure to measure them at the **same distance and light conditions** +as in your final application. Then you'll get very accurate results +even for colors that are otherwise hard to detect. + +.. literalinclude:: + ../../../examples/pup/sensor_color_distance/detectable_colors.py