diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2011-05-25 01:53:29 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2011-05-26 02:42:07 -0400 |
commit | 0dbb4829963a88a84a4387e8c9dc7ce94482a28b (patch) | |
tree | cdb17c7fa404ea7e5b4bee3674705acaaef44095 /docs/source/lang/api | |
parent | 6bf24f14a33b7e6d4565cd147ad4d2252dba77ff (diff) | |
download | librambutan-0dbb4829963a88a84a4387e8c9dc7ce94482a28b.tar.gz librambutan-0dbb4829963a88a84a4387e8c9dc7ce94482a28b.zip |
Docs: Move toggleLED() and waitForButtonPress() examples.
These two examples from board-values.rst really belong in the
documentation for the functions they reference.
Diffstat (limited to 'docs/source/lang/api')
-rw-r--r-- | docs/source/lang/api/board-values.rst | 42 | ||||
-rw-r--r-- | docs/source/lang/api/toggleled.rst | 22 | ||||
-rw-r--r-- | docs/source/lang/api/waitforbuttonpress.rst | 28 |
3 files changed, 60 insertions, 32 deletions
diff --git a/docs/source/lang/api/board-values.rst b/docs/source/lang/api/board-values.rst index 7198407..11b86a8 100644 --- a/docs/source/lang/api/board-values.rst +++ b/docs/source/lang/api/board-values.rst @@ -1,3 +1,5 @@ +.. highlight:: cpp + .. _lang-board-values: Board-Specific Values @@ -122,8 +124,9 @@ Constants default (i.e., they are in :ref:`boardUsedPins <lang-board-values-used-pins>`). However, they can be used as ordinary GPIOs if you call the :ref:`lang-disabledebugports` - function. (Be careful with this on the Maple, as writing to - ``BOARD_NJTRST_PIN`` may cause your board to reset!). + function. (Be careful with this on the Maple and Maple RET6 + Edition, as writing to ``BOARD_NJTRST_PIN`` :ref:`may cause your + board to reset <maple-nrst-pb4>`\ !). .. _lang-board-values-pwm-pins: @@ -161,33 +164,14 @@ Examples :ref:`BOARD_LED_PIN <lang-board-values-led>` On the Maple, the built-in LED is connected to pin 13. On the Maple Mini, however, it is connected to pin 33. You can write a "blinky" program that works -on all LeafLabs boards using ``BOARD_LED_PIN`` and :ref:`toggleLED() -<lang-toggleled>`:: - - void setup() { - pinMode(BOARD_LED_PIN, OUTPUT); - } - - void loop() { - toggleLED(); - delay(100); - } - -:ref:`BOARD_BUTTON_PIN <lang-board-values-but>`: Similarly, you can -write a single program that prints a message whenever the button is -pressed which will work on all LeafLabs boards using -``BOARD_BUTTON_PIN`` and :ref:`isButtonPressed() -<lang-isbuttonpressed>`:: - - void setup() { - pinMode(BOARD_BUTTON_PIN, INPUT); - } - - void loop() { - if (isButtonPressed()) { - SerialUSB.println("You pressed the button!"); - } - } +on both boards using :ref:`this example <lang-toggleled-example>`. + +:ref:`BOARD_BUTTON_PIN <lang-board-values-but>`: On the Maple, the +built-in button is connected to pin 38. On the Maple Mini, however, +it is connected to pin 32. :ref:`This example +<lang-waitforbuttonpress-example>` shows how you can write a program +that prints a message whenever the button is pressed which will work +on all LeafLabs boards. See Also -------- diff --git a/docs/source/lang/api/toggleled.rst b/docs/source/lang/api/toggleled.rst index 54a7d64..cad347f 100644 --- a/docs/source/lang/api/toggleled.rst +++ b/docs/source/lang/api/toggleled.rst @@ -1,15 +1,35 @@ +.. highlight:: cpp + .. _lang-toggleled: toggleLED() =========== -Switches the LED from off to on, or on to off. +*Toggle* the built-in LED: switch it from off to on, or on to off. Library Documentation --------------------- .. doxygenfunction:: toggleLED +Example +------- + +.. _lang-toggleled-example: + +This example sets up the board's LED pin for output, then toggles the +LED every 100 milliseconds:: + + void setup() { + pinMode(BOARD_LED_PIN, OUTPUT); + } + + void loop() { + toggleLED(); + delay(100); + } + + See Also -------- diff --git a/docs/source/lang/api/waitforbuttonpress.rst b/docs/source/lang/api/waitforbuttonpress.rst index a5bd45c..0e0fbaf 100644 --- a/docs/source/lang/api/waitforbuttonpress.rst +++ b/docs/source/lang/api/waitforbuttonpress.rst @@ -1,16 +1,40 @@ +.. highlight:: cpp + .. _lang-waitforbuttonpress: waitForButtonPress() ==================== -Wait for the board's built-in button (labeled BUT on the silkscreen) -to be pressed, possibly with timeout. +Wait for the board's built-in button to be pressed, possibly with +timeout. The button is labeled "BUT" on the board's silkscreen. Its +pin number is the constant :ref:`BOARD_BUTTON_PIN +<lang-board-values-but>`. Library Documentation --------------------- .. doxygenfunction:: waitForButtonPress + +Example +------- + +.. _lang-waitforbuttonpress-example: + +This example sets up the board's button pin as an input, then prints a +message very time the button is pressed. + +:: + + void setup() { + pinMode(BOARD_BUTTON_PIN, INPUT); + } + + void loop() { + waitForButtonPress(); + SerialUSB.println("You pressed the button!"); + } + See Also -------- |