-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathBtnPPMMap.cpp
More file actions
106 lines (88 loc) · 2.36 KB
/
BtnPPMMap.cpp
File metadata and controls
106 lines (88 loc) · 2.36 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "BtnPPMMap.h"
/**
* Button to PPM Mapping - Maps the joystick buttons and actions to different PPM values
* Released under the GNU General Public License
* @Author github.com/lexfp
*/
BtnPPMMap::BtnPPMMap()
{
channel[CH_THROTTLE] = PPM_FAIL_SAFE_VALUE;
channel[CH_AILERON] = PPM_CENTER_VALUE;
channel[CH_ELEVATOR] = PPM_CENTER_VALUE;
channel[CH_RUDDER] = PPM_CENTER_VALUE;
channel[CH_5] = PPM_FAIL_SAFE_VALUE;
channel[CH_6] = PPM_FAIL_SAFE_VALUE;
channel[CH_7] = PPM_FAIL_SAFE_VALUE;
channel[CH_8] = PPM_FAIL_SAFE_VALUE;
}
int BtnPPMMap::getChannelValue(int c) {
return channel[c];
}
void BtnPPMMap::mapChannelValue(int c, long value, int maxValue, boolean invert) {
//Serial.print("X: ");
//Serial.print(value);
if (invert) {
channel[c] = map(value, 0, maxValue, PPM_MAX_VALUE, PPM_MIN_VALUE);
} else {
channel[c] = map(value, 0, maxValue, PPM_MIN_VALUE, PPM_MAX_VALUE);
}
}
void BtnPPMMap::arm() {
//arm ch5 - 1500
channel[CH_5] = 1500;
}
void BtnPPMMap::disArm() {
//disarm ch5 - 950 (default)
channel[CH_5] = 950;
}
void BtnPPMMap::acro() {
channel[CH_6] = 950;
}
void BtnPPMMap::horizon() {
channel[CH_6] = 1500;
}
void BtnPPMMap::turtle() {
channel[CH_6] = 2010;
}
void BtnPPMMap::angle() {
//put your own code here for this functionality
}
void BtnPPMMap::failsafe() {
//put your own code here for this functionality
//be sure to set up your FC software to failsafe on this value as well
}
void BtnPPMMap::beeper() {
//put your own code here for this functionality
}
void BtnPPMMap::rth() {
//put your own code here for this functionality
}
void BtnPPMMap::autotune() {
//put your own code here for this functionality
}
void BtnPPMMap::autotrim() {
//put your own code here for this functionality
}
void BtnPPMMap::hold() {
//put your own code here for this functionality
}
void BtnPPMMap::debug()
{
Serial.print("T:");
Serial.print(channel[CH_THROTTLE]);
Serial.print(" A:");
Serial.print(channel[CH_AILERON]);
Serial.print(" E:");
Serial.print(channel[CH_ELEVATOR]);
Serial.print(" R:");
Serial.print(channel[CH_RUDDER]);
Serial.print(" 5:");
Serial.print(channel[CH_5]);
Serial.print(" 6:");
Serial.print(channel[CH_6]);
Serial.print(" 7:");
Serial.print(channel[CH_7]);
Serial.print(" 8:");
Serial.print(channel[CH_8]);
Serial.println("");
}