Subversion Repositories FlightCtrl

Rev

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

Rev 2119 Rev 2122
Line 117... Line 117...
117
    if (index < MAX_CHANNELS) { // PPM24 supports 12 channels
117
    if (index < MAX_CHANNELS) { // PPM24 supports 12 channels
118
      // check for valid signal length (0.8 ms < signal < 2.2 ms)
118
      // check for valid signal length (0.8 ms < signal < 2.2 ms)
119
      if ((signal >= TIME(0.8)) && (signal < TIME(2.2))) {
119
      if ((signal >= TIME(0.8)) && (signal < TIME(2.2))) {
120
        // shift signal to zero symmetric range  -154 to 159
120
        // shift signal to zero symmetric range  -154 to 159
121
        //signal -= 3750; // theoretical value
121
        //signal -= 3750; // theoretical value
122
        signal -= (TIME(1.5) - 128 + channelMap.trim); // best value with my Futaba in zero trim.
122
        signal -= (TIME(1.5) - 128 + channelMap.HWTrim);
123
        // check for stable signal
123
        // check for stable signal
124
        if (abs(signal - PPM_in[index]) < TIME(0.05)) {
124
        if (abs(signal - PPM_in[index]) < TIME(0.05)) {
125
          if (RCQuality < 200)
125
          if (RCQuality < 200)
126
            RCQuality += 10;
126
            RCQuality += 10;
127
          else
127
          else
Line 196... Line 196...
196
 */
196
 */
197
void RC_periodicTaskAndPRYT(int16_t* PRYT) {
197
void RC_periodicTaskAndPRYT(int16_t* PRYT) {
198
  if (RCQuality) {
198
  if (RCQuality) {
199
    RCQuality--;
199
    RCQuality--;
Line 200... Line 200...
200
 
200
 
201
    debugOut.analog[20] = RCChannel(CH_ELEVATOR);
201
    PRYT[CONTROL_ELEVATOR]   = RCChannel(CH_ELEVATOR)   - rcTrim.trim[CH_ELEVATOR];
202
    debugOut.analog[21] = RCChannel(CH_AILERONS);
202
    PRYT[CONTROL_AILERONS]   = RCChannel(CH_AILERONS)   - rcTrim.trim[CH_AILERONS];
203
    debugOut.analog[22] = RCChannel(CH_RUDDER);
203
    PRYT[CONTROL_RUDDER]     = RCChannel(CH_RUDDER)     - rcTrim.trim[CH_RUDDER];
204
    debugOut.analog[23] = RCChannel(CH_THROTTLE);
204
    PRYT[CONTROL_THROTTLE]   = RCChannel(CH_THROTTLE);  // no trim on throttle!
205
 
205
 
206
    PRYT[CONTROL_ELEVATOR]   = RCChannel(CH_ELEVATOR);
206
    debugOut.analog[20] = PRYT[CONTROL_ELEVATOR];
207
    PRYT[CONTROL_AILERONS]   = RCChannel(CH_AILERONS);
207
    debugOut.analog[21] = PRYT[CONTROL_AILERONS];
208
    PRYT[CONTROL_RUDDER]     = RCChannel(CH_RUDDER);
208
    debugOut.analog[22] = PRYT[CONTROL_RUDDER];
209
    PRYT[CONTROL_THROTTLE]   = RCChannel(CH_THROTTLE);
209
    debugOut.analog[23] = PRYT[CONTROL_THROTTLE];
210
  } // if RCQuality is no good, we just do nothing.
210
} // if RCQuality is no good, we just do nothing.
Line 211... Line 211...
211
}
211
}
212
 
212
 
213
/*
213
/*
Line 233... Line 233...
233
    return SIGNAL_BAD;
233
    return SIGNAL_BAD;
234
  return SIGNAL_LOST;
234
  return SIGNAL_LOST;
235
}
235
}
Line 236... Line 236...
236
 
236
 
-
 
237
void RC_calibrate(void) {
-
 
238
  rcTrim.trim[CH_ELEVATOR] = RCChannel(CH_ELEVATOR);
-
 
239
  rcTrim.trim[CH_AILERONS] = RCChannel(CH_AILERONS);
237
void RC_calibrate(void) {
240
  rcTrim.trim[CH_RUDDER]   = RCChannel(CH_RUDDER);
238
  // Do nothing.
241
  rcTrim.trim[CH_THROTTLE] = 0;
Line 239... Line 242...
239
}
242
}
240
 
243
 
241
int16_t RC_getZeroThrottle(void) {
244
int16_t RC_getZeroThrottle(void) {
-
 
245
        return TIME (-0.5);
-
 
246
}
-
 
247
 
-
 
248
void RC_setZeroTrim(void) {
-
 
249
  for (uint8_t i=0; i<MAX_CHANNELS; i++) {
-
 
250
    rcTrim.trim[i] = 0;