Subversion Repositories FlightCtrl

Rev

Rev 1645 | Rev 1821 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1645 Rev 1775
Line 1... Line 1...
1
#include <inttypes.h>
1
#include <inttypes.h>
2
/*
2
/*
3
 * The throttle range is normalized to [0, THROTTLE_RANGE[
-
 
4
 * This is the normal range. Exceeding it a little is allowed.
-
 
5
 */
-
 
6
#define THROTTLE_RANGE 256
-
 
7
 
-
 
8
/*
-
 
9
 * The stick (pitch, roll, yaw) ranges are normalized to [-STICK_RANGE, STICK_RANGE]
-
 
10
 * This is the normal range. Exceeding it a little is allowed.
-
 
11
 */
-
 
12
#define STICK_RANGE 256
-
 
13
 
-
 
14
/*
-
 
15
 * An attempt to define a generic control. That could be an R/C receiver, an external control
3
 * An attempt to define a generic control. That could be an R/C receiver, an external control
16
 * (serial over Bluetooth, Wi232, XBee, whatever) or the NaviCtrl.
4
 * (serial over Bluetooth, Wi232, XBee, whatever) or the NaviCtrl.
17
 * This resembles somewhat an object-oriented class definition (except that there are no virtuals).
5
 * This resembles somewhat an object-oriented class definition (except that there are no virtuals).
18
 * The idea is that the combination of different control inputs, of the way they superimpose upon
6
 * The idea is that the combination of different control inputs, of the way they superimpose upon
19
 * each other, the proirities between them and the behavior in case that one fails is simplified,
7
 * each other, the priorities between them and the behavior in case that one fails is simplified,
20
 * and all in one place.
8
 * and all in one place.
21
 */
9
 */
Line 22... Line 10...
22
 
10
 
23
/*
11
/*
Line 33... Line 21...
33
#define SIGNAL_BAD  2
21
#define SIGNAL_BAD  2
34
#define SIGNAL_OK   3
22
#define SIGNAL_OK   3
35
#define SIGNAL_GOOD 4
23
#define SIGNAL_GOOD 4
Line 36... Line 24...
36
 
24
 
37
/*
-
 
38
 * An enumeration over the  start motors, stop motors, calibrate gyros
-
 
39
 * and calibreate acc. meters commands.
-
 
40
 */
-
 
41
#define COMMAND_NONE    0
-
 
42
#define COMMAND_START   6
-
 
43
#define COMMAND_STOP    8
-
 
44
#define COMMAND_GYROCAL 2
-
 
45
#define COMMAND_ACCCAL  4
-
 
46
 
-
 
47
/*
25
/*
48
 * The PRTY arrays
26
 * The PRTY arrays
49
 */
27
 */
50
#define CONTROL_PITCH 0
28
#define CONTROL_PITCH    0
51
#define CONTROL_ROLL 1
29
#define CONTROL_ROLL     1
52
#define CONTROL_THROTTLE 2
30
#define CONTROL_THROTTLE 2
Line 53... Line 31...
53
#define CONTROL_YAW 3
31
#define CONTROL_YAW      3
54
 
32
 
55
/*
33
/*
56
 * Looping flags.
34
 * Looping flags.
Line 91... Line 69...
91
} t_control;
69
} t_control;
Line 92... Line 70...
92
 
70
 
93
/*
71
/*
94
 * Our output.
72
 * Our output.
95
 */
73
 */
96
extern int16_t control[2], controlYaw, controlThrottle;
74
extern int16_t control[2];
97
// extern int16_t stickOffsetNick, stickOffsetRoll;
75
extern int16_t controlYaw, controlThrottle;
98
extern uint16_t maxControl[2];
76
extern uint16_t maxControl[2];
Line -... Line 77...
-
 
77
extern uint8_t looping;
-
 
78
 
-
 
79
extern volatile uint8_t MKFlags;
99
extern uint8_t looping;
80
extern uint16_t isFlying;
100
 
81
 
Line 101... Line 82...
101
void controlMixer_initVariables(void);
82
void controlMixer_initVariables(void);
Line 102... Line 83...
102
void controlMixer_updateVariables(void);
83
void controlMixer_updateVariables(void);
103
 
84
 
104
void controlMixer_setNeutral(uint8_t calibrate);
85
void controlMixer_setNeutral(void);
105
 
86
 
Line 116... Line 97...
116
void controlMixer_performCalibrationCommands(uint8_t command);
97
void controlMixer_performCalibrationCommands(uint8_t command);
Line 117... Line 98...
117
 
98
 
Line 118... Line 99...
118
uint8_t controlMixer_getSignalQuality(void);
99
uint8_t controlMixer_getSignalQuality(void);
119
 
100
 
120
/*
101
/*
121
 * The motor throttles can be set in an [0..256[ interval.
102
 * The controls operate in a [-150 * CONTROL_SCALING, 150 * CONTROL_SCALING] interval
122
 * The calculation of motor throttle values from sensor and control information (basically
103
 * Throttle is [0..300 * CONTROL_SCALING].
123
 * flight.c) take place in an [0..256*CONTROL_SCALING[ interval for better precision.
104
 * (just about. No precision needed).
Line 124... Line 105...
124
 */
105
 */
125
#define CONTROL_SCALING 4
106
#define CONTROL_SCALING (1024/256)
126
 
107
 
127
/*
108
/*
Line 137... Line 118...
137
 * + <--
118
 * + <--
138
 *    0
119
 *    0
139
 *
120
 *
140
 * Not in any of these positions: 0
121
 * Not in any of these positions: 0
141
 */
122
 */
-
 
123
// void controlMixer_handleCommands(void);
142
uint8_t controlMixer_getArgument(void);
124
uint8_t controlMixer_getArgument(void);
143
uint8_t controlMixer_isCommandRepeated(void);
125
uint8_t controlMixer_isCommandRepeated(void);
144
// TODO: Abstract away if possible.
126
// TODO: Abstract away if possible.
145
// void controlMixer_setCompassCalState(void);
127
uint8_t controlMixer_testCompassCalState(void);
146
// void controlMixer_updateCompass(void);
-