Rev 1796 | Rev 1867 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1796 | Rev 1821 | ||
---|---|---|---|
Line 118... | Line 118... | ||
118 | void controlMixer_updateVariables(void) { |
118 | void controlMixer_updateVariables(void) { |
119 | uint8_t i; |
119 | uint8_t i; |
120 | int16_t targetvalue; |
120 | int16_t targetvalue; |
121 | for (i=0; i<8; i++) { |
121 | for (i = 0; i < 8; i++) { |
122 | targetvalue = RC_getVariable(i); |
122 | targetvalue = RC_getVariable(i); |
123 | if (targetvalue < 0) targetvalue = 0; |
123 | if (targetvalue < 0) |
- | 124 | targetvalue = 0; |
|
- | 125 | if (variables[i] < targetvalue && variables[i] < 255) |
|
- | 126 | variables[i]++; |
|
124 | if (variables[i] < targetvalue && variables[i] < 255) variables[i]++; else if(variables[i] > 0 && variables[i] > targetvalue) variables[i]--; |
127 | else if (variables[i] > 0 && variables[i] > targetvalue) |
- | 128 | variables[i]--; |
|
125 | } |
129 | } |
126 | } |
130 | } |
Line 127... | Line 131... | ||
127 | 131 | ||
128 | uint8_t controlMixer_getSignalQuality(void) { |
132 | uint8_t controlMixer_getSignalQuality(void) { |
Line 153... | Line 157... | ||
153 | int16_t* EC_PRTY = EC_getPRTY(); |
157 | int16_t* EC_PRTY = EC_getPRTY(); |
Line 154... | Line 158... | ||
154 | 158 | ||
155 | control[PITCH] = RC_PRTY[CONTROL_PITCH] + EC_PRTY[CONTROL_PITCH]; |
159 | control[PITCH] = RC_PRTY[CONTROL_PITCH] + EC_PRTY[CONTROL_PITCH]; |
156 | control[ROLL] = RC_PRTY[CONTROL_ROLL] + EC_PRTY[CONTROL_ROLL]; |
160 | control[ROLL] = RC_PRTY[CONTROL_ROLL] + EC_PRTY[CONTROL_ROLL]; |
157 | // This can be a CPU time killer if the function implementations are inefficient. |
161 | // This can be a CPU time killer if the function implementations are inefficient. |
- | 162 | controlThrottle = HC_getThrottle(AC_getThrottle(RC_PRTY[CONTROL_THROTTLE] |
|
158 | controlThrottle = HC_getThrottle(AC_getThrottle(RC_PRTY[CONTROL_THROTTLE] + EC_PRTY[CONTROL_THROTTLE])); |
163 | + EC_PRTY[CONTROL_THROTTLE])); |
Line 159... | Line 164... | ||
159 | controlYaw = RC_PRTY[CONTROL_YAW] + EC_PRTY[CONTROL_YAW]; |
164 | controlYaw = RC_PRTY[CONTROL_YAW] + EC_PRTY[CONTROL_YAW]; |
160 | 165 | ||
161 | DebugOut.Analog[12] = control[PITCH]; |
166 | DebugOut.Analog[12] = control[PITCH]; |
Line 186... | Line 191... | ||
186 | * Record maxima |
191 | * Record maxima |
187 | */ |
192 | */ |
188 | for (axis=PITCH; axis<=ROLL; axis++) { |
193 | for (axis = PITCH; axis <= ROLL; axis++) { |
189 | if(abs(control[axis] / CONTROL_SCALING) > maxControl[axis]) { |
194 | if (abs(control[axis] / CONTROL_SCALING) > maxControl[axis]) { |
190 | maxControl[axis] = abs(control[axis]) / CONTROL_SCALING; |
195 | maxControl[axis] = abs(control[axis]) / CONTROL_SCALING; |
191 | if(maxControl[axis] > 100) maxControl[axis] = 100; |
196 | if (maxControl[axis] > 100) |
- | 197 | maxControl[axis] = 100; |
|
192 | } else if (maxControl[axis]) maxControl[axis]--; |
198 | } else if (maxControl[axis]) |
- | 199 | maxControl[axis]--; |
|
193 | } |
200 | } |
Line 194... | Line 201... | ||
194 | 201 | ||
- | 202 | uint8_t rcCommand = (RC_getSignalQuality() >= SIGNAL_OK) ? RC_getCommand() |
|
195 | uint8_t rcCommand = (RC_getSignalQuality() >= SIGNAL_OK) ? RC_getCommand() : COMMAND_NONE; |
203 | : COMMAND_NONE; |
- | 204 | uint8_t ecCommand = (EC_getSignalQuality() >= SIGNAL_OK) ? EC_getCommand() |
|
Line 196... | Line 205... | ||
196 | uint8_t ecCommand = (EC_getSignalQuality() >= SIGNAL_OK) ? EC_getCommand() : COMMAND_NONE; |
205 | : COMMAND_NONE; |
197 | 206 | ||
198 | if (rcCommand != COMMAND_NONE) { |
207 | if (rcCommand != COMMAND_NONE) { |
199 | isCommandRepeated = (lastCommand == rcCommand); |
208 | isCommandRepeated = (lastCommand == rcCommand); |
Line 208... | Line 217... | ||
208 | // Just set to false. There is no reason to check if the none-command was repeated anyway. |
217 | // Just set to false. There is no reason to check if the none-command was repeated anyway. |
209 | isCommandRepeated = 0; |
218 | isCommandRepeated = 0; |
210 | lastCommand = COMMAND_NONE; |
219 | lastCommand = COMMAND_NONE; |
211 | } |
220 | } |
Line -... | Line 221... | ||
- | 221 | ||
- | 222 | if (isCommandRepeated) |
|
- | 223 | DebugOut.Digital[0] |= DEBUG_COMMANDREPEATED; |
|
212 | 224 | else |
|
- | 225 | DebugOut.Digital[0] &= ~DEBUG_COMMANDREPEATED; |
|
- | 226 | if (rcCommand) |
|
- | 227 | DebugOut.Digital[1] |= DEBUG_COMMANDREPEATED; |
|
213 | if (isCommandRepeated) DebugOut.Digital[0] |= DEBUG_COMMANDREPEATED; else DebugOut.Digital[0] &= ~DEBUG_COMMANDREPEATED; |
228 | else |
Line 214... | Line 229... | ||
214 | if (rcCommand) DebugOut.Digital[1] |= DEBUG_COMMANDREPEATED; else DebugOut.Digital[1] &= ~DEBUG_COMMANDREPEATED; |
229 | DebugOut.Digital[1] &= ~DEBUG_COMMANDREPEATED; |
215 | 230 | ||
Line 216... | Line 231... | ||
216 | // part1 end. |
231 | // part1 end. |