Subversion Repositories FlightCtrl

Rev

Rev 2026 | Rev 2045 | 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];
2026 - 64
volatile uint8_t newPPMData = 1;
65
volatile uint8_t RCQuality;
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) {
2026 - 163
      newPPMData = 0; // Null means NewData for the first 4 channels
1962 - 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
 */
2039 - 242
void RC_periodicTask() {
1962 - 243
  int16_t tmp1, tmp2;
2019 - 244
  if (RCQuality) {
245
    RCQuality--;
2026 - 246
    if (newPPMData-- == 0) {
1962 - 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
  }
277
}
278
 
279
/*
280
 * Get Pitch, Roll, Throttle, Yaw values
281
 */
282
int16_t* RC_getPRTY(void) {
283
  return RC_PRTY;
284
}
285
 
286
/*
287
 * Get other channel value
288
 */
289
int16_t RC_getVariable(uint8_t varNum) {
290
  if (varNum < 4)
291
    // 0th variable is 5th channel (1-based) etc.
1986 - 292
    return RCChannel(varNum + CH_POTS) + POT_OFFSET;
1962 - 293
  /*
294
   * Let's just say:
1986 - 295
   * The RC variable i is hardwired to channel i, i>=4
1962 - 296
   */
1986 - 297
  return PPM_in[varNum] + POT_OFFSET;
1962 - 298
}
299
 
300
uint8_t RC_getSignalQuality(void) {
2019 - 301
  if (RCQuality >= 160)
1962 - 302
    return SIGNAL_GOOD;
2019 - 303
  if (RCQuality >= 140)
1962 - 304
    return SIGNAL_OK;
2019 - 305
  if (RCQuality >= 120)
1962 - 306
    return SIGNAL_BAD;
307
  return SIGNAL_LOST;
308
}
309
 
310
/*
311
 * To should fired only when the right stick is in the center position.
312
 * This will cause the value of pitch and roll stick to be adjusted
313
 * to zero (not just to near zero, as per the assumption in rc.c
314
 * about the rc signal. I had values about 50..70 with a Futaba
315
 * R617 receiver.) This calibration is not strictly necessary, but
316
 * for control logic that depends on the exact (non)center position
317
 * of a stick, it may be useful.
318
 */
319
void RC_calibrate(void) {
320
  // Do nothing.
321
}
322
 
323
/*
324
 if (staticParams.GlobalConfig & CFG_HEADING_HOLD) {
325
 // In HH, it s OK to trim the R/C. The effect should not be conteracted here.
326
 stickOffsetPitch = stickOffsetRoll = 0;
327
 } else {
328
 stickOffsetPitch = RCChannel(CH_PITCH) * staticParams.StickP;
329
 stickOffsetRoll = RCChannel(CH_ROLL)   * staticParams.StickP;
330
 }
331
 }
332
 */
333
 
334
uint8_t RC_getCommand(void) {
335
  if (commandTimer == COMMAND_TIMER) {
336
    // Stick has been held long enough; command committed.
337
    return lastRCCommand;
338
  }
339
  // Not yet sure what the command is.
340
  return COMMAND_NONE;
341
}
342
 
343
/*
344
 * Command arguments on R/C:
345
 * 2--3--4
346
 * |     |  +
347
 * 1  0  5  ^ 0
348
 * |     |  |  
349
 * 8--7--6
350
 *    
351
 * + <--
352
 *    0
353
 *
354
 * Not in any of these positions: 0
355
 */
356
 
357
#define ARGUMENT_THRESHOLD 70
358
#define ARGUMENT_CHANNEL_VERTICAL CH_PITCH
359
#define ARGUMENT_CHANNEL_HORIZONTAL CH_ROLL
360
 
361
uint8_t RC_getArgument(void) {
362
  if (RCChannel(ARGUMENT_CHANNEL_VERTICAL) > ARGUMENT_THRESHOLD) {
363
    // vertical is up
364
    if (RCChannel(ARGUMENT_CHANNEL_HORIZONTAL) > ARGUMENT_THRESHOLD)
365
      return 2;
366
    if (RCChannel(ARGUMENT_CHANNEL_HORIZONTAL) < -ARGUMENT_THRESHOLD)
367
      return 4;
368
    return 3;
369
  } else if (RCChannel(ARGUMENT_CHANNEL_VERTICAL) < -ARGUMENT_THRESHOLD) {
370
    // vertical is down
371
    if (RCChannel(ARGUMENT_CHANNEL_HORIZONTAL) > ARGUMENT_THRESHOLD)
372
      return 8;
373
    if (RCChannel(ARGUMENT_CHANNEL_HORIZONTAL) < -ARGUMENT_THRESHOLD)
374
      return 6;
375
    return 7;
376
  } else {
377
    // vertical is around center
378
    if (RCChannel(ARGUMENT_CHANNEL_HORIZONTAL) > ARGUMENT_THRESHOLD)
379
      return 1;
380
    if (RCChannel(ARGUMENT_CHANNEL_HORIZONTAL) < -ARGUMENT_THRESHOLD)
381
      return 5;
382
    return 0;
383
  }
384
}
385
 
386
/*
387
uint8_t RC_getLooping(uint8_t looping) {
388
  //  static uint8_t looping = 0;
389
 
390
  if (RCChannel(CH_ROLL) > staticParams.LoopThreshold && staticParams.BitConfig
391
      & CFG_LOOP_LEFT) {
392
    looping |= (LOOPING_ROLL_AXIS | LOOPING_LEFT);
393
  } else if ((looping & LOOPING_LEFT) && RCChannel(CH_ROLL)
394
      < staticParams.LoopThreshold - staticParams.LoopHysteresis) {
395
    looping &= (~(LOOPING_ROLL_AXIS | LOOPING_LEFT));
396
  }
397
 
398
  if (RCChannel(CH_ROLL) < -staticParams.LoopThreshold
399
      && staticParams.BitConfig & CFG_LOOP_RIGHT) {
400
    looping |= (LOOPING_ROLL_AXIS | LOOPING_RIGHT);
401
  } else if ((looping & LOOPING_RIGHT) && RCChannel(CH_ROLL)
402
      > -staticParams.LoopThreshold - staticParams.LoopHysteresis) {
403
    looping &= (~(LOOPING_ROLL_AXIS | LOOPING_RIGHT));
404
  }
405
 
406
  if (RCChannel(CH_PITCH) > staticParams.LoopThreshold
407
      && staticParams.BitConfig & CFG_LOOP_UP) {
408
    looping |= (LOOPING_PITCH_AXIS | LOOPING_UP);
409
  } else if ((looping & LOOPING_UP) && RCChannel(CH_PITCH)
410
      < staticParams.LoopThreshold - staticParams.LoopHysteresis) {
411
    looping &= (~(LOOPING_PITCH_AXIS | LOOPING_UP));
412
  }
413
 
414
  if (RCChannel(CH_PITCH) < -staticParams.LoopThreshold
415
      && staticParams.BitConfig & CFG_LOOP_DOWN) {
416
    looping |= (LOOPING_PITCH_AXIS | LOOPING_DOWN);
417
  } else if ((looping & LOOPING_DOWN) && RCChannel(CH_PITCH)
418
      > -staticParams.LoopThreshold - staticParams.LoopHysteresis) {
419
    looping &= (~(LOOPING_PITCH_AXIS | LOOPING_DOWN));
420
  }
421
 
422
  return looping;
423
}
424
*/
425
 
426
uint8_t RC_testCompassCalState(void) {
427
  static uint8_t stick = 1;
428
  // if pitch is centered or top set stick to zero
429
  if (RCChannel(CH_PITCH) > -20)
430
    stick = 0;
431
  // if pitch is down trigger to next cal state
432
  if ((RCChannel(CH_PITCH) < -70) && !stick) {
433
    stick = 1;
434
    return 1;
435
  }
436
  return 0;
437
}
438
/*
439
 * Abstract controls are not used at the moment.
440
 t_control rc_control = {
441
 RC_getPitch,
442
 RC_getRoll,
443
 RC_getYaw,
444
 RC_getThrottle,
445
 RC_getSignalQuality,
446
 RC_calibrate
447
 };
448
 */