Automatically map an input value to an output range without knowing the precise range of inputs beforehand.
More...
#include <AutoMap.h>
|
| AutoMap (int min_expected, int max_expected, int map_to_min, int map_to_max) |
| Constructor. More...
|
|
int | next (int n) |
| Process the next value and return it mapped to the range which was set in the constructor. More...
|
|
int | operator() (int n) |
| Process the next value and return it mapped to the range which was set in the constructor. More...
|
|
int | getMin () |
| Returns the current minimum. More...
|
|
int | getMax () |
| Returns the current maximum. More...
|
|
int | getRange () |
| Returns the current range. More...
|
|
Automatically map an input value to an output range without knowing the precise range of inputs beforehand.
- Examples:
- 03.Sensors/Knob_LDR_x2_WavePacket/Knob_LDR_x2_WavePacket.ino.
Definition at line 28 of file AutoMap.h.
AutoMap::AutoMap |
( |
int |
min_expected, |
|
|
int |
max_expected, |
|
|
int |
map_to_min, |
|
|
int |
map_to_max |
|
) |
| |
|
inline |
Constructor.
- Parameters
-
min_expected | the minimum possible input value. |
max_expected | the maximum possible input value. |
Definition at line 35 of file AutoMap.h.
Returns the current maximum.
- Returns
- maximum
Definition at line 57 of file AutoRange.h.
Returns the current minimum.
- Returns
- minimum
Definition at line 49 of file AutoRange.h.
Returns the current range.
- Returns
- range
Definition at line 65 of file AutoRange.h.
int AutoMap::next |
( |
int |
n | ) |
|
|
inline |
Process the next value and return it mapped to the range which was set in the constructor.
Can use the operator instead if you prefer, eg. myMap(n) instead of myMap.next(n).
- Parameters
-
n | the next value to process. |
- Returns
- the input value mapped to the range which was set in the constructor.
Definition at line 47 of file AutoMap.h.
int AutoMap::operator() |
( |
int |
n | ) |
|
|
inline |
Process the next value and return it mapped to the range which was set in the constructor.
This is an alternative to next() if you prefer, eg. myMap(n) instead of myMap.next(n).
- Parameters
-
n | the next value to process. |
- Returns
- the input value mapped to the range which was set in the constructor.
Definition at line 58 of file AutoMap.h.