Subversion Repositories FlightCtrl

Rev

Rev 2017 | Rev 2026 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1968 - 1
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2
// + Copyright (c) 04.2007 Holger Buss
3
// + Nur f�r den privaten Gebrauch
4
// + www.MikroKopter.com
5
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6
// + Es gilt f�r das gesamte Projekt (Hardware, Software, Bin�rfiles, Sourcecode und Dokumentation),
7
// + dass eine Nutzung (auch auszugsweise) nur f�r den privaten (nicht-kommerziellen) Gebrauch zul�ssig ist.
8
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt
9
// + bzgl. der Nutzungsbedingungen aufzunehmen.
10
// + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Best�ckung und Verkauf von Platinen oder Baus�tzen,
11
// + Verkauf von Luftbildaufnahmen, usw.
12
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13
// + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder ver�ffentlicht,
14
// + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright m�ssen dann beiliegen
15
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
16
// + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts
17
// + auf anderen Webseiten oder sonstigen Medien ver�ffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de"
18
// + eindeutig als Ursprung verlinkt werden
19
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20
// + Keine Gew�hr auf Fehlerfreiheit, Vollst�ndigkeit oder Funktion
21
// + Benutzung auf eigene Gefahr
22
// + Wir �bernehmen keinerlei Haftung f�r direkte oder indirekte Personen- oder Sachsch�den
23
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24
// + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur
25
// + mit unserer Zustimmung zul�ssig
26
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
27
// + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen
28
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
29
// + Redistributions of source code (with or without modifications) must retain the above copyright notice,
30
// + this list of conditions and the following disclaimer.
31
// +   * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived
32
// +     from this software without specific prior written permission.
33
// +   * The use of this project (hardware, software, binary files, sources and documentation) is only permittet
34
// +     for non-commercial use (directly or indirectly)
35
// +     Commercial use (for example: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted
36
// +     with our written permission
37
// +   * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be
38
// +     clearly linked as origin
39
// +   * porting to systems other than hardware from www.mikrokopter.de is not allowed
40
// +  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41
// +  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
// +  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43
// +  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
44
// +  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45
// +  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
46
// +  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
47
// +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48
// +  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49
// +  POSSIBILITY OF SUCH DAMAGE.
50
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
51
#include <stdlib.h>
52
#include <avr/io.h>
53
#include <avr/interrupt.h>
1962 - 54
 
1968 - 55
#include "rc.h"
56
#include "uart0.h"
57
#include "controlMixer.h"
58
#include "configuration.h"
59
#include "commands.h"
60
 
61
// The channel array is now 0-based.
62
volatile int16_t PPM_in[MAX_CHANNELS];
63
volatile int16_t PPM_diff[MAX_CHANNELS];
64
volatile uint8_t NewPpmData = 1;
2019 - 65
volatile uint8_t RCQuality = 0;
1968 - 66
int16_t RC_PRTY[4];
67
uint8_t lastRCCommand = COMMAND_NONE;
68
uint8_t commandTimer = 0;
69
 
70
/***************************************************************
71
 *  16bit timer 1 is used to decode the PPM-Signal            
72
 ***************************************************************/
73
void RC_Init(void) {
74
  uint8_t sreg = SREG;
75
 
76
  // disable all interrupts before reconfiguration
77
  cli();
78
 
79
  // PPM-signal is connected to the Input Capture Pin (PD6) of timer 1
80
  DDRD &= ~(1<<6);
81
  PORTD |= (1<<PORTD6);
82
 
83
  // Channel 5,6,7 is decoded to servo signals at pin PD5 (J3), PD4(J4), PD3(J5)
84
  // set as output
85
  DDRD |= (1<<DDD5) | (1<<DDD4) | (1<<DDD3);
86
  // low level
87
  PORTD &= ~((1<<PORTD5) | (1<<PORTD4) | (1<<PORTD3));
88
 
89
  // PD3 can't be used if 2nd UART is activated
90
  // because TXD1 is at that port
91
  if (CPUType != ATMEGA644P) {
92
    DDRD |= (1<<PORTD3);
93
    PORTD &= ~(1<<PORTD3);
94
  }
95
 
96
  // Timer/Counter1 Control Register A, B, C
97
 
98
  // Normal Mode (bits: WGM13=0, WGM12=0, WGM11=0, WGM10=0)
99
  // Compare output pin A & B is disabled (bits: COM1A1=0, COM1A0=0, COM1B1=0, COM1B0=0)
100
  // Set clock source to SYSCLK/64 (bit: CS12=0, CS11=1, CS10=1)
101
  // Enable input capture noise cancler (bit: ICNC1=1)
102
  // Trigger on positive edge of the input capture pin (bit: ICES1=1),
103
  // Therefore the counter incremets at a clock of 20 MHz/64 = 312.5 kHz or 3.2�s
104
  // The longest period is 0xFFFF / 312.5 kHz = 0.209712 s.
105
  TCCR1A &= ~((1 << COM1A1) | (1 << COM1A0) | (1 << COM1B1) | (1 << COM1B0) | (1 << WGM11) | (1 << WGM10));
106
  TCCR1B &= ~((1 << WGM13) | (1 << WGM12) | (1 << CS12));
107
  TCCR1B |= (1 << CS11) | (1 << CS10) | (1 << ICES1) | (1 << ICNC1);
108
  TCCR1C &= ~((1 << FOC1A) | (1 << FOC1B));
109
 
110
  // Timer/Counter1 Interrupt Mask Register
111
  // Enable Input Capture Interrupt (bit: ICIE1=1)
112
  // Disable Output Compare A & B Match Interrupts (bit: OCIE1B=0, OICIE1A=0)
113
  // Enable Overflow Interrupt (bit: TOIE1=0)
114
  TIMSK1 &= ~((1<<OCIE1B) | (1<<OCIE1A) | (1<<TOIE1));
115
  TIMSK1 |= (1<<ICIE1);
116
 
2019 - 117
  RCQuality = 0;
1968 - 118
 
119
  SREG = sreg;
120
}
121
 
122
/********************************************************************/
123
/*         Every time a positive edge is detected at PD6            */
124
/********************************************************************/
125
/*                               t-Frame
126
    <----------------------------------------------------------------------->
127
     ____   ______   _____   ________                ______    sync gap      ____
128
    |    | |      | |     | |        |              |      |                |
129
    |    | |      | |     | |        |              |      |                |
130
 ___|    |_|      |_|     |_|        |_.............|      |________________|
131
    <-----><-------><------><-----------            <------>                <---
132
 t0       t1      t2       t4                     tn                     t0
133
 
1962 - 134
 The PPM-Frame length is 22.5 ms.
135
 Channel high pulse width range is 0.7 ms to 1.7 ms completed by an 0.3 ms low pulse.
136
 The mininimum time delay of two events coding a channel is ( 0.7 + 0.3) ms = 1 ms.
137
 The maximum time delay of two events coding a channel is ( 1.7 + 0.3) ms = 2 ms.
138
 The minimum duration of all channels at minimum value is  8 * 1 ms = 8 ms.
139
 The maximum duration of all channels at maximum value is  8 * 2 ms = 16 ms.
140
 The remaining time of (22.5 - 8 ms) ms = 14.5 ms  to (22.5 - 16 ms) ms = 6.5 ms is
141
 the syncronization gap.
142
 */
143
ISR(TIMER1_CAPT_vect)
144
{ // typical rate of 1 ms to 2 ms
145
  int16_t signal = 0, tmp;
146
  static int16_t index;
147
  static uint16_t oldICR1 = 0;
148
 
149
  // 16bit Input Capture Register ICR1 contains the timer value TCNT1
150
  // at the time the edge was detected
151
 
152
  // calculate the time delay to the previous event time which is stored in oldICR1
153
  // calculatiing the difference of the two uint16_t and converting the result to an int16_t
154
  // implicit handles a timer overflow 65535 -> 0 the right way.
155
  signal = (uint16_t) ICR1 - oldICR1;
156
  oldICR1 = ICR1;
157
 
158
  //sync gap? (3.52 ms < signal < 25.6 ms)
159
  if ((signal > 1100) && (signal < 8000)) {
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.
1968 - 162
    if (index >= 3) {
1962 - 163
      NewPpmData = 0; // Null means NewData for the first 4 channels
164
    }
165
    // synchronize channel index
1968 - 166
    index = 0;
1962 - 167
  } else { // within the PPM frame
1968 - 168
    if (index < MAX_CHANNELS) { // PPM24 supports 12 channels
1962 - 169
      // check for valid signal length (0.8 ms < signal < 2.1984 ms)
170
      // signal range is from 1.0ms/3.2us = 312 to 2.0ms/3.2us = 625
171
      if ((signal > 250) && (signal < 687)) {
172
        // shift signal to zero symmetric range  -154 to 159
2017 - 173
        signal -= 470; // offset of 1.4912 ms ??? (469 * 3.2us = 1.5008 ms)
1962 - 174
        // check for stable signal
175
        if (abs(signal - PPM_in[index]) < 6) {
2019 - 176
          if (RCQuality < 200)
177
            RCQuality += 10;
1962 - 178
          else
2019 - 179
            RCQuality = 200;
1962 - 180
        }
181
        // If signal is the same as before +/- 1, just keep it there.
182
        if (signal >= PPM_in[index] - 1 && signal <= PPM_in[index] + 1) {
183
          // In addition, if the signal is very close to 0, just set it to 0.
184
          if (signal >= -1 && signal <= 1) {
185
            tmp = 0;
186
          } else {
187
            tmp = PPM_in[index];
188
          }
189
        } else
190
          tmp = signal;
191
        // calculate signal difference on good signal level
2019 - 192
        if (RCQuality >= 195)
1962 - 193
          PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; // cut off lower 3 bit for nois reduction
194
        else
195
          PPM_diff[index] = 0;
196
        PPM_in[index] = tmp; // update channel value
197
      }
198
      index++; // next channel
199
      // demux sum signal for channels 5 to 7 to J3, J4, J5
200
      // TODO: General configurability of this R/C channel forwarding. Or remove it completely - the
201
      // channels are usually available at the receiver anyway.
202
      // if(index == 5) J3HIGH; else J3LOW;
203
      // if(index == 6) J4HIGH; else J4LOW;
204
      // if(CPUType != ATMEGA644P) // not used as TXD1
205
      //  {
206
      //    if(index == 7) J5HIGH; else J5LOW;
207
      //  }
208
    }
209
  }
210
}
211
 
212
#define RCChannel(dimension) PPM_in[channelMap.channels[dimension]]
213
#define RCDiff(dimension) PPM_diff[channelMap.channels[dimension]]
214
#define COMMAND_THRESHOLD 85
215
#define COMMAND_CHANNEL_VERTICAL CH_THROTTLE
216
#define COMMAND_CHANNEL_HORIZONTAL CH_YAW
217
 
218
// Internal.
219
uint8_t RC_getStickCommand(void) {
220
  if (RCChannel(COMMAND_CHANNEL_VERTICAL) > COMMAND_THRESHOLD) {
221
    // vertical is up
222
    if (RCChannel(COMMAND_CHANNEL_HORIZONTAL) > COMMAND_THRESHOLD)
223
      return COMMAND_GYROCAL;
224
    if (RCChannel(COMMAND_CHANNEL_HORIZONTAL) < -COMMAND_THRESHOLD)
225
      return COMMAND_ACCCAL;
226
    return COMMAND_NONE;
227
  } else if (RCChannel(COMMAND_CHANNEL_VERTICAL) < -COMMAND_THRESHOLD) {
228
    // vertical is down
229
    if (RCChannel(COMMAND_CHANNEL_HORIZONTAL) > COMMAND_THRESHOLD)
230
      return COMMAND_STOP;
231
    if (RCChannel(COMMAND_CHANNEL_HORIZONTAL) < -COMMAND_THRESHOLD)
232
      return COMMAND_START;
233
    return COMMAND_NONE;
234
  }
235
  // vertical is around center
236
  return COMMAND_NONE;
237
}
238
 
239
/*
240
 * This must be called (as the only thing) for each control loop cycle (488 Hz).
241
 */
242
void RC_update() {
243
  int16_t tmp1, tmp2;
2019 - 244
  if (RCQuality) {
245
    RCQuality--;
1962 - 246
    if (NewPpmData-- == 0) {
247
      RC_PRTY[CONTROL_PITCH] = RCChannel(CH_PITCH) * staticParams.stickP
248
          + RCDiff(CH_PITCH) * staticParams.stickD;
249
      RC_PRTY[CONTROL_ROLL] = RCChannel(CH_ROLL) * staticParams.stickP
250
          + RCDiff(CH_ROLL) * staticParams.stickD;
251
      RC_PRTY[CONTROL_THROTTLE] = RCChannel(CH_THROTTLE) + RCDiff(CH_THROTTLE)
252
          * staticParams.stickThrottleD + 120;
253
      if (RC_PRTY[CONTROL_THROTTLE] < 0)
254
        RC_PRTY[CONTROL_THROTTLE] = 0; // Throttle is non negative.
255
      tmp1 = -RCChannel(CH_YAW) - RCDiff(CH_YAW);
256
      // exponential stick sensitivity in yawing rate
257
      tmp2 = (int32_t) staticParams.stickYawP * ((int32_t) tmp1 * abs(tmp1))
258
          / 512L; // expo  y = ax + bx^2
259
      tmp2 += (staticParams.stickYawP * tmp1) >> 2;
260
      RC_PRTY[CONTROL_YAW] = tmp2;
261
    }
262
    uint8_t command = RC_getStickCommand();
263
 
264
    if (lastRCCommand == command) {
265
      // Keep timer from overrunning.
266
      if (commandTimer < COMMAND_TIMER)
267
        commandTimer++;
268
    } else {
269
      // There was a change.
270
      lastRCCommand = command;
271
      commandTimer = 0;
272
    }
273
  } else { // Bad signal
274
    RC_PRTY[CONTROL_PITCH] = RC_PRTY[CONTROL_ROLL] = RC_PRTY[CONTROL_THROTTLE]
275
        = RC_PRTY[CONTROL_YAW] = 0;
276
  }
2019 - 277
 
278
  debugOut.analog[21] = RCQuality;
1962 - 279
}
280
 
281
/*
282
 * Get Pitch, Roll, Throttle, Yaw values
283
 */
284
int16_t* RC_getPRTY(void) {
285
  return RC_PRTY;
286
}
287
 
288
/*
289
 * Get other channel value
290
 */
291
int16_t RC_getVariable(uint8_t varNum) {
292
  if (varNum < 4)
293
    // 0th variable is 5th channel (1-based) etc.
1986 - 294
    return RCChannel(varNum + CH_POTS) + POT_OFFSET;
1962 - 295
  /*
296
   * Let's just say:
1986 - 297
   * The RC variable i is hardwired to channel i, i>=4
1962 - 298
   */
1986 - 299
  return PPM_in[varNum] + POT_OFFSET;
1962 - 300
}
301
 
302
uint8_t RC_getSignalQuality(void) {
2019 - 303
  if (RCQuality >= 160)
1962 - 304
    return SIGNAL_GOOD;
2019 - 305
  if (RCQuality >= 140)
1962 - 306
    return SIGNAL_OK;
2019 - 307
  if (RCQuality >= 120)
1962 - 308
    return SIGNAL_BAD;
309
  return SIGNAL_LOST;
310
}
311
 
312
/*
313
 * To should fired only when the right stick is in the center position.
314
 * This will cause the value of pitch and roll stick to be adjusted
315
 * to zero (not just to near zero, as per the assumption in rc.c
316
 * about the rc signal. I had values about 50..70 with a Futaba
317
 * R617 receiver.) This calibration is not strictly necessary, but
318
 * for control logic that depends on the exact (non)center position
319
 * of a stick, it may be useful.
320
 */
321
void RC_calibrate(void) {
322
  // Do nothing.
323
}
324
 
325
/*
326
 if (staticParams.GlobalConfig & CFG_HEADING_HOLD) {
327
 // In HH, it s OK to trim the R/C. The effect should not be conteracted here.
328
 stickOffsetPitch = stickOffsetRoll = 0;
329
 } else {
330
 stickOffsetPitch = RCChannel(CH_PITCH) * staticParams.StickP;
331
 stickOffsetRoll = RCChannel(CH_ROLL)   * staticParams.StickP;
332
 }
333
 }
334
 */
335
 
336
uint8_t RC_getCommand(void) {
337
  if (commandTimer == COMMAND_TIMER) {
338
    // Stick has been held long enough; command committed.
339
    return lastRCCommand;
340
  }
341
  // Not yet sure what the command is.
342
  return COMMAND_NONE;
343
}
344
 
345
/*
346
 * Command arguments on R/C:
347
 * 2--3--4
348
 * |     |  +
349
 * 1  0  5  ^ 0
350
 * |     |  |  
351
 * 8--7--6
352
 *    
353
 * + <--
354
 *    0
355
 *
356
 * Not in any of these positions: 0
357
 */
358
 
359
#define ARGUMENT_THRESHOLD 70
360
#define ARGUMENT_CHANNEL_VERTICAL CH_PITCH
361
#define ARGUMENT_CHANNEL_HORIZONTAL CH_ROLL
362
 
363
uint8_t RC_getArgument(void) {
364
  if (RCChannel(ARGUMENT_CHANNEL_VERTICAL) > ARGUMENT_THRESHOLD) {
365
    // vertical is up
366
    if (RCChannel(ARGUMENT_CHANNEL_HORIZONTAL) > ARGUMENT_THRESHOLD)
367
      return 2;
368
    if (RCChannel(ARGUMENT_CHANNEL_HORIZONTAL) < -ARGUMENT_THRESHOLD)
369
      return 4;
370
    return 3;
371
  } else if (RCChannel(ARGUMENT_CHANNEL_VERTICAL) < -ARGUMENT_THRESHOLD) {
372
    // vertical is down
373
    if (RCChannel(ARGUMENT_CHANNEL_HORIZONTAL) > ARGUMENT_THRESHOLD)
374
      return 8;
375
    if (RCChannel(ARGUMENT_CHANNEL_HORIZONTAL) < -ARGUMENT_THRESHOLD)
376
      return 6;
377
    return 7;
378
  } else {
379
    // vertical is around center
380
    if (RCChannel(ARGUMENT_CHANNEL_HORIZONTAL) > ARGUMENT_THRESHOLD)
381
      return 1;
382
    if (RCChannel(ARGUMENT_CHANNEL_HORIZONTAL) < -ARGUMENT_THRESHOLD)
383
      return 5;
384
    return 0;
385
  }
386
}
387
 
388
/*
389
uint8_t RC_getLooping(uint8_t looping) {
390
  //  static uint8_t looping = 0;
391
 
392
  if (RCChannel(CH_ROLL) > staticParams.LoopThreshold && staticParams.BitConfig
393
      & CFG_LOOP_LEFT) {
394
    looping |= (LOOPING_ROLL_AXIS | LOOPING_LEFT);
395
  } else if ((looping & LOOPING_LEFT) && RCChannel(CH_ROLL)
396
      < staticParams.LoopThreshold - staticParams.LoopHysteresis) {
397
    looping &= (~(LOOPING_ROLL_AXIS | LOOPING_LEFT));
398
  }
399
 
400
  if (RCChannel(CH_ROLL) < -staticParams.LoopThreshold
401
      && staticParams.BitConfig & CFG_LOOP_RIGHT) {
402
    looping |= (LOOPING_ROLL_AXIS | LOOPING_RIGHT);
403
  } else if ((looping & LOOPING_RIGHT) && RCChannel(CH_ROLL)
404
      > -staticParams.LoopThreshold - staticParams.LoopHysteresis) {
405
    looping &= (~(LOOPING_ROLL_AXIS | LOOPING_RIGHT));
406
  }
407
 
408
  if (RCChannel(CH_PITCH) > staticParams.LoopThreshold
409
      && staticParams.BitConfig & CFG_LOOP_UP) {
410
    looping |= (LOOPING_PITCH_AXIS | LOOPING_UP);
411
  } else if ((looping & LOOPING_UP) && RCChannel(CH_PITCH)
412
      < staticParams.LoopThreshold - staticParams.LoopHysteresis) {
413
    looping &= (~(LOOPING_PITCH_AXIS | LOOPING_UP));
414
  }
415
 
416
  if (RCChannel(CH_PITCH) < -staticParams.LoopThreshold
417
      && staticParams.BitConfig & CFG_LOOP_DOWN) {
418
    looping |= (LOOPING_PITCH_AXIS | LOOPING_DOWN);
419
  } else if ((looping & LOOPING_DOWN) && RCChannel(CH_PITCH)
420
      > -staticParams.LoopThreshold - staticParams.LoopHysteresis) {
421
    looping &= (~(LOOPING_PITCH_AXIS | LOOPING_DOWN));
422
  }
423
 
424
  return looping;
425
}
426
*/
427
 
428
uint8_t RC_testCompassCalState(void) {
429
  static uint8_t stick = 1;
430
  // if pitch is centered or top set stick to zero
431
  if (RCChannel(CH_PITCH) > -20)
432
    stick = 0;
433
  // if pitch is down trigger to next cal state
434
  if ((RCChannel(CH_PITCH) < -70) && !stick) {
435
    stick = 1;
436
    return 1;
437
  }
438
  return 0;
439
}
440
/*
441
 * Abstract controls are not used at the moment.
442
 t_control rc_control = {
443
 RC_getPitch,
444
 RC_getRoll,
445
 RC_getYaw,
446
 RC_getThrottle,
447
 RC_getSignalQuality,
448
 RC_calibrate
449
 };
450
 */