Rev 1743 | Rev 2011 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1743 | Rev 1928 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | Decodieren eines RC Summen Signals oder Spektrum Empfänger-Satellit |
2 | Decodieren eines RC Summen Signals oder Spektrum Empfänger-Satellit |
3 | #######################################################################################*/ |
3 | #######################################################################################*/ |
Line 4... | Line 4... | ||
4 | 4 | ||
5 | #include "Spektrum.h" |
5 | #include "Spektrum.h" |
6 | #include "main.h" |
6 | #include "main.h" |
Line 7... | Line 7... | ||
7 | // Achtung: RECEIVER_SPEKTRUM_EXP wird in der Main.h gesetzt |
7 | // Achtung: RECEIVER_SPEKTRUM_DX7EXP oder RECEIVER_SPEKTRUM_DX8EXP wird in der Main.h gesetzt |
Line 8... | Line 8... | ||
8 | 8 | ||
9 | unsigned char SpektrumTimer = 0; |
9 | unsigned char SpektrumTimer = 0; |
10 | 10 | ||
11 | #ifdef RECEIVER_SPEKTRUM_EXP |
11 | #if defined (RECEIVER_SPEKTRUM_DX7EXP) || defined (RECEIVER_SPEKTRUM_DX8EXP) |
12 | unsigned char s_excnt = 0; // Counter for Spektrum-Expander |
12 | unsigned char s_excnt = 0; // Counter for Spektrum-Expander |
13 | unsigned char s_exparity = 0; // Parity Bit for Spektrum-Expander |
13 | unsigned char s_exparity = 0; // Parity Bit for Spektrum-Expander |
Line 307... | Line 307... | ||
307 | 307 | ||
308 | index++; |
308 | index++; |
309 | if(index < 13) |
309 | if(index < 13) |
310 | { |
310 | { |
311 | // Stabiles Signal |
311 | // Stabiles Signal |
312 | #ifdef RECEIVER_SPEKTRUM_EXP |
312 | #if defined (RECEIVER_SPEKTRUM_DX7EXP) || defined (RECEIVER_SPEKTRUM_DX8EXP) |
313 | if (index == 2) index = 4; // Analog channel reassigment (2 <-> 4) for logical numbering (1,2,3,4) |
313 | if (index == 2) index = 4; // Analog channel reassigment (2 <-> 4) for logical numbering (1,2,3,4) |
314 | else if (index == 4) index = 2; |
314 | else if (index == 4) index = 2; |
315 | #endif |
315 | #endif |
316 | if(abs(signal - PPM_in[index]) < 6) |
316 | if(abs(signal - PPM_in[index]) < 6) |
Line 324... | Line 324... | ||
324 | } |
324 | } |
325 | tmp = (3 * (PPM_in[index]) + signal) / 4; |
325 | tmp = (3 * (PPM_in[index]) + signal) / 4; |
326 | if(tmp > signal+1) tmp--; else |
326 | if(tmp > signal+1) tmp--; else |
327 | if(tmp < signal-1) tmp++; |
327 | if(tmp < signal-1) tmp++; |
Line 328... | Line 328... | ||
328 | 328 | ||
329 | #ifdef RECEIVER_SPEKTRUM_EXP |
329 | #ifdef RECEIVER_SPEKTRUM_DX7EXP |
330 | if(index == 6) // FLIGHT-MODE - The channel used for our data uplink |
330 | if(index == 6) // FLIGHT-MODE - The channel used for our data uplink |
331 | { |
331 | { |
332 | if (signal > 100) // SYNC received |
332 | if (signal > 100) // SYNC received |
333 | { |
333 | { |
Line 362... | Line 362... | ||
362 | s_exdata[s_excnt] = 125; // Bit = 1 -> value = 125 (max) |
362 | s_exdata[s_excnt] = 125; // Bit = 1 -> value = 125 (max) |
363 | s_exparity = ~s_exparity; // Bit = 1 -> Invert parity bit |
363 | s_exparity = ~s_exparity; // Bit = 1 -> Invert parity bit |
364 | } |
364 | } |
Line 365... | Line 365... | ||
365 | 365 | ||
- | 366 | } |
|
- | 367 | ||
- | 368 | #elif defined RECEIVER_SPEKTRUM_DX8EXP |
|
- | 369 | if(index == 6) // FLIGHT-MODE - The channel used for our data uplink |
|
- | 370 | { |
|
- | 371 | if (signal > 100) // SYNC received |
|
- | 372 | { |
|
- | 373 | if (s_exdata[s_excnt] == 125) s_exparity = ~s_exparity; // Bit = 1 -> Re-Invert parity bit |
|
- | 374 | if (s_excnt == 9 && ((s_exparity == 0 && s_exdata[s_excnt] == -125) || (s_exparity != 0 && s_exdata[s_excnt] == 125))) // Parity check |
|
- | 375 | { |
|
- | 376 | if (s_exdata[1] == 125 && s_exdata[2] == -125) PPM_in[5] = -125; // Reconstruct tripole Flight-Mode value (CH5) |
|
- | 377 | else if (s_exdata[1] == -125 && s_exdata[2] == -125) PPM_in[5] = 0; // Reconstruct tripole Flight-Mode value (CH5) |
|
- | 378 | else if (s_exdata[1] == -125 && s_exdata[2] == 125) PPM_in[5] = 125; // Reconstruct tripole Flight-Mode value (CH5) |
|
- | 379 | ||
- | 380 | if (s_exdata[3] == 125 && s_exdata[6] == -125) PPM_in[6] = 125; // Reconstruct tripole Elev D/R value (CH6) |
|
- | 381 | else if (s_exdata[3] == -125 && s_exdata[6] == -125) PPM_in[6] = 0; // Reconstruct tripole Elev D/R value (CH6) |
|
- | 382 | else if (s_exdata[3] == -125 && s_exdata[6] == 125) PPM_in[6] = -125; // Reconstruct tripole Elev D/R value (CH6) |
|
- | 383 | ||
- | 384 | ||
- | 385 | if (s_exdata[7] == 125 && s_exdata[8] == -125) PPM_in[9] = -125; // Reconstruct tripole AIL D/R value (CH9) |
|
- | 386 | else if (s_exdata[7] == -125 && s_exdata[8] == -125) PPM_in[9] = 0; // Reconstruct tripole AIL D/R value (CH9) |
|
- | 387 | else if (s_exdata[7] == -125 && s_exdata[8] == 125) PPM_in[9] = 125; // Reconstruct tripole AIL D/R value (CH9) |
|
- | 388 | ||
- | 389 | PPM_in[10] = s_exdata[5]; // Gear (CH10) |
|
- | 390 | PPM_in[12] = s_exdata[4]; // Mix (CH12) |
|
- | 391 | } |
|
- | 392 | ||
- | 393 | s_excnt = 0; // Reset bitcounter |
|
- | 394 | s_exparity = 0; // Reset parity bit |
|
- | 395 | } |
|
- | 396 | ||
- | 397 | if (signal < 10) s_exdata[++s_excnt] = -125; // Bit = 0 -> value = -125 (min) |
|
- | 398 | if (s_excnt == 10) s_excnt = 0; // Overflow protection |
|
- | 399 | if (signal < -100) |
|
- | 400 | { |
|
- | 401 | s_exdata[s_excnt] = 125; // Bit = 1 -> value = 125 (max) |
|
- | 402 | s_exparity = ~s_exparity; // Bit = 1 -> Invert parity bit |
|
- | 403 | } |
|
- | 404 | ||
366 | } |
405 | } |
367 | #endif |
406 | #endif |
368 | if(SenderOkay >= 180) PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; |
407 | if(SenderOkay >= 180) PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; |
Line 369... | Line 408... | ||
369 | else PPM_diff[index] = 0; |
408 | else PPM_diff[index] = 0; |
370 | 409 | ||
371 | #ifdef RECEIVER_SPEKTRUM_EXP |
410 | #ifdef RECEIVER_SPEKTRUM_DX7EXP |
372 | if (index < 5 ) PPM_in[index] = tmp; // Update normal potis (CH1-4) |
411 | if (index < 5 ) PPM_in[index] = tmp; // Update normal potis (CH1-4) |
- | 412 | else if (index == 5) PPM_in[7] = signal; // Gear (CH7) |
|
- | 413 | else if (index == 7) PPM_in[9] = signal; // Hover Throttle (CH9) |
|
- | 414 | #elif defined RECEIVER_SPEKTRUM_DX8EXP |
|
- | 415 | if (index < 5 ) PPM_in[index] = tmp; // Update normal potis (CH1-4) |
|
- | 416 | else if (index == 7) PPM_in[7] = signal; // R Trim (CH7) |
|
373 | else if (index == 5) PPM_in[7] = signal; // Gear (CH7) |
417 | else if (index == 5) PPM_in[8] = signal; // AUX2 (CH8) |
374 | else if (index == 7) PPM_in[9] = signal; // Hover Throttle (CH9) |
418 | else if (index == 8) PPM_in[11] = signal; // AUX3 (CH11) |
375 | #else |
419 | #else |
376 | PPM_in[index] = tmp; |
420 | PPM_in[index] = tmp; |
377 | #endif |
421 | #endif |
Line 403... | Line 447... | ||
403 | Sync = 0; |
447 | Sync = 0; |
404 | SpektrumTimer = MIN_FRAMEGAP; |
448 | SpektrumTimer = MIN_FRAMEGAP; |
405 | } |
449 | } |
406 | } |
450 | } |
407 | } |
451 | } |
- | 452 |