-
Notifications
You must be signed in to change notification settings - Fork 229
/
Copy pathmotion.c
73 lines (59 loc) · 2.21 KB
/
motion.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* /\ /\
* / \_____/ \
* /_____________\
* W H I T E C A T
*
* Copyright (C) 2015 - 2020, IBEROXARXA SERVICIOS INTEGRALES, S.L.
* Copyright (C) 2015 - 2020, Jaume Olivé Petrus (jolive@whitecatboard.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "motion.h"
#include "esp_attr.h"
#include <string.h>
void motion_prepare(motion_constraints_t *pconstraints, motion_t *pmotion) {
if (pconstraints->accleration_profile == MotionSCurve) {
pmotion->accleration_profile = MotionSCurve;
memset(pmotion, 0, sizeof(motion_t));
pmotion->s_curve.v0 = pconstraints->s_curve.v0;
pmotion->s_curve.v = pconstraints->s_curve.v;
pmotion->s_curve.a = pconstraints->s_curve.a;
pmotion->s_curve.j = pconstraints->s_curve.j;
pmotion->s_curve.s = pconstraints->s_curve.s;
pmotion->s_curve.t = pconstraints->s_curve.t;
pmotion->s_curve.units_per_step = pconstraints->s_curve.units_per_step;
pmotion->s_curve.steps_per_unit = pconstraints->s_curve.steps_per_unit;
pmotion->_prepare = s_curve_prepare;
pmotion->_next = s_curve_next;
#if MOTION_DEBUG
pmotion->_dump = s_curve_dump;
#endif
}
pmotion->_prepare(pmotion);
}
void motion_constraint_t(motion_t *pmotion, float t) {
if (pmotion->accleration_profile == MotionSCurve) {
pmotion->s_curve.t = t;
}
pmotion->_prepare(pmotion);
}
void motion_dumnp(motion_t *pmotion) {
#if MOTION_DEBUG
pmotion->_dump(pmotion);
#endif
}
float IRAM_ATTR motion_next(motion_t *pmotion) {
return pmotion->_next(pmotion);
}