diff options
author | Marti Bolivar <mbolivar@mit.edu> | 2010-12-03 20:18:00 -0500 |
---|---|---|
committer | Marti Bolivar <mbolivar@mit.edu> | 2010-12-03 20:18:00 -0500 |
commit | 210f3d2b1555bae87c9de27ea145e16d3bddb0f8 (patch) | |
tree | 5e409fff948c9a1847d08e5ec34f905ea2212956 /source/lang/map.rst | |
parent | 11573d0fca18ef2ccd965ab67d419afd48b7cef2 (diff) | |
download | librambutan-210f3d2b1555bae87c9de27ea145e16d3bddb0f8.tar.gz librambutan-210f3d2b1555bae87c9de27ea145e16d3bddb0f8.zip |
cleaning up previous commits.
note that addition of new files under docs/source/lang/api and
docs/source/lang/cpp which were just copies of files in
docs/source/lang/ imply that change history is lost to git.
Diffstat (limited to 'source/lang/map.rst')
-rw-r--r-- | source/lang/map.rst | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/source/lang/map.rst b/source/lang/map.rst deleted file mode 100644 index 79122b3..0000000 --- a/source/lang/map.rst +++ /dev/null @@ -1,68 +0,0 @@ -.. highlight:: cpp - -.. _lang-map: - -map() -===== - -Re-maps a number from one range to another. - -.. contents:: Contents - :local: - -Library Documentation ---------------------- - -.. doxygenfunction:: map - -Discussion ----------- - -``map()`` does not constrain values to within the range, because -out-of-range values are sometimes intended and useful. The -:ref:`constrain() <lang-constrain>` macro may be used either before or -after this function, if limits to the ranges are desired. - -Note that the "lower bounds" of either range may be larger or smaller -than the "upper bounds" so that ``map()`` may be used to reverse a -range of numbers; for example:: - - y = map(x, 1, 50, 50, 1); - -The function also handles negative numbers well, so that this -example :: - - y = map(x, 1, 50, 50, -100); - -is also valid. - -The ``map()`` function uses integer math (its arguments and return -values all have type :ref:`long <lang-long>`), so it will not generate -fractions, when the math might indicate that it should do so. -Fractional remainders are truncated, and are not rounded or averaged. - -Example -------- - -:: - - /* Map an ADC reading (12 bits) to 16-bit PWM (0 to 65,535) */ - - void setup() { - pinMode(0, INPUT_ANALOG); - pinMode(9, PWM); - } - - void loop() { - int val = analogRead(0); - val = map(val, 0, 4095, 0, 65535); - analogWrite(9, val); - } - - -See Also --------- - -- :ref:`constrain() <lang-constrain>` - -.. include:: cc-attribution.txt |