Plaquette
 
Loading...
Searching...
No Matches
pq_map.h
1/*
2 * pq_map_float.h
3 *
4 * Equivalent of Arduino map() method but for floats and doubles.
5 *
6 * (c) 2015 Sofian Audry :: info(@)sofianaudry(.)com
7 * (c) 2015 Thomas O Fredericks :: tof(@)t-o-f(.)info
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23#ifndef PQ_MAP_H_
24#define PQ_MAP_H_
25
26#include <stdint.h>
27
28namespace pq {
29
31enum MapMode {
32 UNCONSTRAIN = 0,
33 CONSTRAIN = 1,
34 WRAP = 2
35};
36
47float mapFloat(double value, double fromLow, double fromHigh, double toLow, double toHigh, MapMode mode=UNCONSTRAIN);
48
57float mapFrom01(double value, double toLow, double toHigh, MapMode mode=UNCONSTRAIN);
58
67float mapTo01(double value, double fromLow, double fromHigh, MapMode mode=UNCONSTRAIN);
68
69
70} // namespace pq
71
72#endif