2 * This file is part of Betaflight.
4 * Betaflight is free software. You can redistribute this software
5 * and/or modify this software under the terms of the GNU General
6 * Public License as published by the Free Software Foundation,
7 * either version 3 of the License, or (at your option) any later
10 * Betaflight is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this software.
19 * If not, see <http://www.gnu.org/licenses/>.
26 #define PWL_DECLARE(name, size, xMinV, xMaxV) \
27 STATIC_ASSERT((xMinV) < (xMaxV), "xMinV must be less than xMaxV"); \
28 STATIC_ASSERT((size) > 1, "size must be more than 1"); \
29 STATIC_ASSERT((size) < 33, "size must be less than 33"); \
30 float name##_yValues[(size)]; \
32 .yValues = name##_yValues, \
33 .numPoints = (size), \
36 .dx = ((xMaxV) - (xMinV)) / ((size) - 1) \
39 typedef struct pwl_s
{
47 void pwlInitialize(pwl_t
*pwl
, float *yValues
, int numPoints
, float xMin
, float xMax
);
48 void pwlFill(pwl_t
*pwl
, float (*function
)(float, void*), void *arg
);
49 float pwlInterpolate(const pwl_t
*pwl
, float x
);