Subversion Repositories FlightCtrl

Rev

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

Rev 1634 Rev 1645
Line 61... Line 61...
61
/*
61
/*
62
 * Number of cycles a command must be repeated before commit. Maybe this really belongs in RC.
62
 * Number of cycles a command must be repeated before commit. Maybe this really belongs in RC.
63
 */
63
 */
64
#define COMMAND_TIMER 200
64
#define COMMAND_TIMER 200
Line 65... Line 65...
65
 
65
 
66
uint16_t maxControlPitch = 0, maxControlRoll = 0;
66
uint16_t maxControl[2] = {0,0};
67
int16_t controlPitch = 0, controlRoll = 0, controlYaw = 0, controlThrottle = 0;
67
int16_t control[2] = {0,0}, controlYaw = 0, controlThrottle = 0;
Line 68... Line 68...
68
uint8_t looping = 0;
68
uint8_t looping = 0;
69
 
69
 
70
// Internal variables for reading commands made with an R/C stick.
70
// Internal variables for reading commands made with an R/C stick.
Line 126... Line 126...
126
}
126
}
Line 127... Line 127...
127
 
127
 
128
uint8_t controlMixer_getSignalQuality(void) {
128
uint8_t controlMixer_getSignalQuality(void) {
129
  uint8_t rcQ = RC_getSignalQuality();
129
  uint8_t rcQ = RC_getSignalQuality();
130
  uint8_t ecQ = EC_getSignalQuality();
-
 
131
  DebugOut.Analog[16] = rcQ;
-
 
132
  DebugOut.Analog[17] = ecQ;
130
  uint8_t ecQ = EC_getSignalQuality();
133
  // This needs not be the only correct solution...
131
  // This needs not be the only correct solution...
134
  return rcQ > ecQ ? rcQ : ecQ;
132
  return rcQ > ecQ ? rcQ : ecQ;
Line 135... Line 133...
135
}
133
}
136
 
134
 
137
/*
135
/*
138
 * Update the variables indicating stick position from the sum of R/C, GPS and external control.
136
 * Update the variables indicating stick position from the sum of R/C, GPS and external control.
139
 */
137
 */
140
void controlMixer_update(void) {
138
void controlMixer_update(void) {
-
 
139
  // calculate Stick inputs by rc channels (P) and changing of rc channels (D)
141
  // calculate Stick inputs by rc channels (P) and changing of rc channels (D)
140
  // TODO: If no signal --> zero.
142
  // TODO: If no signal --> zero.
141
  uint8_t axis;
Line 143... Line 142...
143
  RC_update();
142
  RC_update();
144
  EC_update();
143
  EC_update();
Line 145... Line 144...
145
 
144
 
146
  int16_t* RC_PRTY = RC_getPRTY();
145
  int16_t* RC_PRTY = RC_getPRTY();
147
  int16_t* EC_PRTY = EC_getPRTY();
146
  int16_t* EC_PRTY = EC_getPRTY();
148
 
147
 
Line 149... Line -...
149
  controlPitch     = RC_PRTY[CONTROL_PITCH] + EC_PRTY[CONTROL_PITCH];
-
 
150
  controlRoll      = RC_PRTY[CONTROL_ROLL] + EC_PRTY[CONTROL_ROLL];
-
 
151
  controlThrottle  = RC_PRTY[CONTROL_THROTTLE] + EC_PRTY[CONTROL_THROTTLE];
-
 
152
  controlYaw       = RC_PRTY[CONTROL_YAW] + EC_PRTY[CONTROL_YAW];
-
 
153
 
148
  control[PITCH]   = RC_PRTY[CONTROL_PITCH] + EC_PRTY[CONTROL_PITCH];
154
  DebugOut.Analog[6] = controlPitch;
149
  control[ROLL]    = RC_PRTY[CONTROL_ROLL] + EC_PRTY[CONTROL_ROLL];
155
  DebugOut.Analog[7] = controlRoll;
150
  controlThrottle  = RC_PRTY[CONTROL_THROTTLE] + EC_PRTY[CONTROL_THROTTLE];
156
  DebugOut.Analog[8] = controlYaw;
151
  controlYaw       = RC_PRTY[CONTROL_YAW] + EC_PRTY[CONTROL_YAW];
157
   
152
 
Line 176... Line 171...
176
  }
171
  }
Line 177... Line 172...
177
 
172
 
178
  /*
173
  /*
179
   * Record maxima
174
   * Record maxima
-
 
175
   */
180
   */
176
  for (axis=PITCH; axis<=ROLL; axis++) {
181
  if(abs(controlPitch / STICK_GAIN) > maxControlPitch) {
177
    if(abs(control[axis] / CONTROL_SCALING) > maxControl[axis]) {
182
    maxControlPitch = abs(controlPitch) / STICK_GAIN;
178
      maxControl[axis] = abs(control[axis]) / CONTROL_SCALING;
183
    if(maxControlPitch > 100) maxControlPitch = 100;
179
      if(maxControl[axis] > 100) maxControl[axis] = 100;
184
  } else if (maxControlPitch) maxControlPitch--;
-
 
185
  if(abs(controlRoll / STICK_GAIN) > maxControlRoll) {
-
 
186
    maxControlRoll = abs(controlRoll) / STICK_GAIN;
-
 
187
    if(maxControlRoll > 100) maxControlRoll = 100;
180
    } else if (maxControl[axis]) maxControl[axis]--;
188
  }
-
 
Line 189... Line 181...
189
  else if (maxControlRoll) maxControlRoll--;
181
  }
190
 
182
 
Line 191... Line 183...
191
  // Here we could blend in other sources.
183
  // Here we could blend in other sources.