vtx: fix VTX_SETTINGS_POWER_COUNT and add dummy entries to saPowerNames
[inav.git] / src / main / io / headtracker_msp.c
blob8a800b3f46ebe1b92acdd28d21d2d07164e44e01
1 /*
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/>.
18 #include <platform.h>
19 #include <stdio.h>
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 = {
34 .process = NULL,
35 .getDeviceType = heatTrackerMspGetDeviceType,
36 .isReady = NULL,
37 .isValid = NULL,
40 static headTrackerDevice_t headTrackerMspDevice = {
41 .vTable = &headTrackerMspVTable,
42 .pan = 0,
43 .tilt = 0,
44 .roll = 0,
45 .expires = 0,
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));
59 return;
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;
69 UNUSED(status);
72 headTrackerDevType_e heatTrackerMspGetDeviceType(const headTrackerDevice_t *headTrackerDevice) {
73 UNUSED(headTrackerDevice);
74 return HEADTRACKER_MSP;
77 #endif