2 * This file is part of INAV.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with INAV. If not, see <http://www.gnu.org/licenses/>.
21 #if (defined(USE_HEADTRACKER_MSP) && defined(USE_HEADTRACKER))
23 #include "build/debug.h"
25 #include "common/utils.h"
26 #include "common/time.h"
27 #include "common/maths.h"
29 #include "drivers/headtracker_common.h"
31 #include "io/headtracker_msp.h"
33 static headTrackerVTable_t headTrackerMspVTable
= {
35 .getDeviceType
= heatTrackerMspGetDeviceType
,
40 static headTrackerDevice_t headTrackerMspDevice
= {
41 .vTable
= &headTrackerMspVTable
,
48 void mspHeadTrackerInit(void)
50 if(headTrackerConfig()->devType
== HEADTRACKER_MSP
) {
51 headTrackerCommonSetDevice(&headTrackerMspDevice
);
55 void mspHeadTrackerReceiverNewData(uint8_t *data
, int dataSize
)
57 if(dataSize
!= sizeof(headtrackerMspMessage_t
)) {
58 SD(fprintf(stderr
, "[headTracker]: invalid data size %d\n", dataSize
));
62 headtrackerMspMessage_t
*status
= (headtrackerMspMessage_t
*)data
;
64 headTrackerMspDevice
.pan
= constrain(status
->pan
, HEADTRACKER_RANGE_MIN
, HEADTRACKER_RANGE_MAX
);
65 headTrackerMspDevice
.tilt
= constrain(status
->tilt
, HEADTRACKER_RANGE_MIN
, HEADTRACKER_RANGE_MAX
);
66 headTrackerMspDevice
.roll
= constrain(status
->roll
, HEADTRACKER_RANGE_MIN
, HEADTRACKER_RANGE_MAX
);
67 headTrackerMspDevice
.expires
= micros() + MAX_HEADTRACKER_DATA_AGE_US
;
72 headTrackerDevType_e
heatTrackerMspGetDeviceType(const headTrackerDevice_t
*headTrackerDevice
) {
73 UNUSED(headTrackerDevice
);
74 return HEADTRACKER_MSP
;