Subversion Repositories FlightCtrl

Rev

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

Rev 2019 Rev 2026
Line 59... Line 59...
59
#include "commands.h"
59
#include "commands.h"
Line 60... Line 60...
60
 
60
 
61
// The channel array is now 0-based.
61
// The channel array is now 0-based.
62
volatile int16_t PPM_in[MAX_CHANNELS];
62
volatile int16_t PPM_in[MAX_CHANNELS];
63
volatile int16_t PPM_diff[MAX_CHANNELS];
63
volatile int16_t PPM_diff[MAX_CHANNELS];
64
volatile uint8_t NewPpmData = 1;
64
volatile uint8_t newPPMData = 1;
65
volatile uint8_t RCQuality = 0;
65
volatile uint8_t RCQuality;
66
int16_t RC_PRTY[4];
66
int16_t RC_PRTY[4];
67
uint8_t lastRCCommand = COMMAND_NONE;
67
uint8_t lastRCCommand = COMMAND_NONE;
Line 68... Line 68...
68
uint8_t commandTimer = 0;
68
uint8_t commandTimer = 0;
Line 158... Line 158...
158
  //sync gap? (3.52 ms < signal < 25.6 ms)
158
  //sync gap? (3.52 ms < signal < 25.6 ms)
159
  if ((signal > 1100) && (signal < 8000)) {
159
  if ((signal > 1100) && (signal < 8000)) {
160
    // if a sync gap happens and there where at least 4 channels decoded before
160
    // if a sync gap happens and there where at least 4 channels decoded before
161
    // then the NewPpmData flag is reset indicating valid data in the PPM_in[] array.
161
    // then the NewPpmData flag is reset indicating valid data in the PPM_in[] array.
162
    if (index >= 3) {
162
    if (index >= 3) {
163
      NewPpmData = 0; // Null means NewData for the first 4 channels
163
      newPPMData = 0; // Null means NewData for the first 4 channels
164
    }
164
    }
165
    // synchronize channel index
165
    // synchronize channel index
166
    index = 0;
166
    index = 0;
167
  } else { // within the PPM frame
167
  } else { // within the PPM frame
168
    if (index < MAX_CHANNELS) { // PPM24 supports 12 channels
168
    if (index < MAX_CHANNELS) { // PPM24 supports 12 channels
Line 241... Line 241...
241
 */
241
 */
242
void RC_update() {
242
void RC_update() {
243
  int16_t tmp1, tmp2;
243
  int16_t tmp1, tmp2;
244
  if (RCQuality) {
244
  if (RCQuality) {
245
    RCQuality--;
245
    RCQuality--;
246
    if (NewPpmData-- == 0) {
246
    if (newPPMData-- == 0) {
247
      RC_PRTY[CONTROL_PITCH] = RCChannel(CH_PITCH) * staticParams.stickP
247
      RC_PRTY[CONTROL_PITCH] = RCChannel(CH_PITCH) * staticParams.stickP
248
          + RCDiff(CH_PITCH) * staticParams.stickD;
248
          + RCDiff(CH_PITCH) * staticParams.stickD;
249
      RC_PRTY[CONTROL_ROLL] = RCChannel(CH_ROLL) * staticParams.stickP
249
      RC_PRTY[CONTROL_ROLL] = RCChannel(CH_ROLL) * staticParams.stickP
250
          + RCDiff(CH_ROLL) * staticParams.stickD;
250
          + RCDiff(CH_ROLL) * staticParams.stickD;
251
      RC_PRTY[CONTROL_THROTTLE] = RCChannel(CH_THROTTLE) + RCDiff(CH_THROTTLE)
251
      RC_PRTY[CONTROL_THROTTLE] = RCChannel(CH_THROTTLE) + RCDiff(CH_THROTTLE)
Line 272... Line 272...
272
    }
272
    }
273
  } else { // Bad signal
273
  } else { // Bad signal
274
    RC_PRTY[CONTROL_PITCH] = RC_PRTY[CONTROL_ROLL] = RC_PRTY[CONTROL_THROTTLE]
274
    RC_PRTY[CONTROL_PITCH] = RC_PRTY[CONTROL_ROLL] = RC_PRTY[CONTROL_THROTTLE]
275
        = RC_PRTY[CONTROL_YAW] = 0;
275
        = RC_PRTY[CONTROL_YAW] = 0;
276
  }
276
  }
277
 
-
 
278
  debugOut.analog[21] = RCQuality;
-
 
279
}
277
}
Line 280... Line 278...
280
 
278
 
281
/*
279
/*
282
 * Get Pitch, Roll, Throttle, Yaw values
280
 * Get Pitch, Roll, Throttle, Yaw values