From c2d042ff66dad8e6d21b8101a5b4d30465a559d8 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Fri, 27 May 2011 23:56:38 -0400 Subject: Docs: Improve analogwrite.rst. Make the note warning against its usage more direct. Add a blurb introducing its purpose and links in See Also to related board-specific values. --- source/lang/api/analogwrite.rst | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'source/lang/api') diff --git a/source/lang/api/analogwrite.rst b/source/lang/api/analogwrite.rst index b553d8b..0169976 100644 --- a/source/lang/api/analogwrite.rst +++ b/source/lang/api/analogwrite.rst @@ -8,21 +8,23 @@ analogWrite() ============= +analogWrite() is used to create a :ref:`PWM ` wave on a pin. + .. note:: On the Maple, calling analogWrite() is the same as calling - :ref:`lang-pwmwrite`\ ; we recommend using that function directly - instead. + :ref:`lang-pwmwrite`. We recommend writing pwmWrite() instead of + analogWrite(). - This is because PWM is not true analog output (i.e., is not the - output of a `DAC + This is because PWM is not true analog output (it's not the output + of a `DAC `_\ ), so - the function is badly named. For instance, analogWrite() **has - absolutely nothing to do with** :ref:`lang-analogread`\ , which is - potentially confusing. + the function is very badly named. For instance, **analogWrite() + has nothing to do with** :ref:`lang-analogread`\ , which can be + confusing. - The alias of analogWrite() to pwmWrite() is provided for the sake - of compatibility with Arduino only. + We provide analogWrite() for the sake of compatibility with Arduino + only. .. contents:: Contents :local: @@ -67,7 +69,7 @@ for more information. Another fix is to consult your board's :ref:`pin maps ` to find the timer which controls PWM on the pin you're using, then set -that Timer's overflow to 255. Subsequent calls to analogWrite() +that timer's overflow to 255. Subsequent calls to analogWrite() should work as on the Arduino (with the same loss of precision). Note, however, that that affects the overflow for the **entire timer**, so other code relying on that timer (such as any @@ -162,6 +164,9 @@ See Also -------- - :ref:`pwm` +- :ref:`lang-pwmwrite` +- :ref:`BOARD_NR_PWM_PINS ` +- :ref:`boardPWMPins ` .. rubric:: Footnotes -- cgit v1.2.3