Paparazzi UAS
v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
autopilot_rc_helpers.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2017 Gautier Hattenberger <gautier.hattenberger@enac.fr>
3
*
4
* This file is part of paparazzi.
5
*
6
* paparazzi is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
9
* any later version.
10
*
11
* paparazzi is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with paparazzi; see the file COPYING. If not, see
18
* <http://www.gnu.org/licenses/>.
19
*/
20
27
#ifndef AUTOPILOT_RC_HELPERS_H
28
#define AUTOPILOT_RC_HELPERS_H
29
30
#include "generated/airframe.h"
31
#include "
subsystems/radio_control.h
"
32
41
static
inline
bool
rc_mode_switch
(
uint8_t
chan,
uint8_t
pos,
uint8_t
max)
42
{
43
if
(
radio_control
.
status
!=
RC_OK
)
return
false
;
44
if
(pos >= max)
return
false
;
45
int32_t
v = (
int32_t
)
radio_control
.
values
[chan] -
MIN_PPRZ
;
46
// round final value
47
int32_t
p
= (((((
int32_t
)max - 1) * 10 * v) / (
MAX_PPRZ
-
MIN_PPRZ
)) + 5) / 10;
48
Bound(
p
, 0, max - 1);
// just in case
49
return
pos == (
uint8_t
)
p
;
50
}
51
54
#ifdef RADIO_MODE
55
#define RCMode0() rc_mode_switch(RADIO_MODE, 0, 3)
56
#define RCMode1() rc_mode_switch(RADIO_MODE, 1, 3)
57
#define RCMode2() rc_mode_switch(RADIO_MODE, 2, 3)
58
#endif
59
60
61
#endif
/* AUTOPILOT_RC_HELPERS_H */
MIN_PPRZ
#define MIN_PPRZ
Definition:
paparazzi.h:9
RadioControl::status
uint8_t status
Definition:
radio_control.h:53
radio_control.h
RadioControl::values
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
Definition:
radio_control.h:58
radio_control
struct RadioControl radio_control
Definition:
radio_control.c:30
int32_t
signed long int32_t
Definition:
types.h:19
RC_OK
#define RC_OK
Definition:
radio_control.h:48
uint8_t
unsigned char uint8_t
Definition:
types.h:14
p
static float p[2][2]
Definition:
ins_alt_float.c:268
MAX_PPRZ
#define MAX_PPRZ
Definition:
paparazzi.h:8
rc_mode_switch
static bool rc_mode_switch(uint8_t chan, uint8_t pos, uint8_t max)
RC mode switch position helper switch positions threshold are evenly spaced.
Definition:
autopilot_rc_helpers.h:41
sw
airborne
firmwares
fixedwing
autopilot_rc_helpers.h
Generated on Sat Feb 9 2019 06:43:48 for Paparazzi UAS by
1.8.8