Rev 2177 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2177 | Rev 2312 | ||
---|---|---|---|
Line 10... | Line 10... | ||
10 | #warning : "### without SPECTRUM Code ###" |
10 | #warning : "### without SPECTRUM Code ###" |
11 | #endif |
11 | #endif |
Line 12... | Line 12... | ||
12 | 12 | ||
Line -... | Line 13... | ||
- | 13 | unsigned char SpektrumTimer = 0; |
|
13 | unsigned char SpektrumTimer = 0; |
14 | |
14 | 15 | // Achtung: RECEIVER_SPEKTRUM_DX7EXP oder RECEIVER_SPEKTRUM_DX8EXP wird in der main.h gesetzt |
|
15 | #if defined (RECEIVER_SPEKTRUM_DX7EXP) || defined (RECEIVER_SPEKTRUM_DX8EXP) |
16 | #if defined (RECEIVER_SPEKTRUM_DX7EXP) || defined (RECEIVER_SPEKTRUM_DX8EXP) |
16 | unsigned char s_excnt = 0; // Counter for Spektrum-Expander |
17 | unsigned char s_excnt = 0; // Bitcounter for Spektrum-Expander |
- | 18 | unsigned char s_exparity = 0; // Parity Bit for Spektrum-Expander |
|
- | 19 | signed char s_exdata[11]; // Data for Spektrum-Expander |
|
- | 20 | ||
- | 21 | void s_update(unsigned char channel, signed int value) // Channel-Diff numbercrunching and finally assign new stickvalue to PPM_in |
|
- | 22 | { |
|
- | 23 | if(SenderOkay >= 180) PPM_diff[channel] = ((value - PPM_in[channel]) / 3) * 3; |
|
- | 24 | else PPM_diff[channel] = 0; |
|
17 | unsigned char s_exparity = 0; // Parity Bit for Spektrum-Expander |
25 | PPM_in[channel] = value; |
- | 26 | } |
|
18 | signed char s_exdata[11]; // Data for Spektrum-Expander |
27 | #endif |
19 | #endif |
28 | |
20 | //--------------------------------------------------------------// |
29 | //--------------------------------------------------------------// |
21 | //--------------------------------------------------------------// |
30 | //--------------------------------------------------------------// |
22 | /* |
31 | /* |
Line 319... | Line 328... | ||
319 | index++; |
328 | index++; |
320 | if(index < 13) |
329 | if(index < 13) |
321 | { |
330 | { |
322 | // Stabiles Signal |
331 | // Stabiles Signal |
323 | #if defined (RECEIVER_SPEKTRUM_DX7EXP) || defined (RECEIVER_SPEKTRUM_DX8EXP) |
332 | #if defined (RECEIVER_SPEKTRUM_DX7EXP) || defined (RECEIVER_SPEKTRUM_DX8EXP) |
324 | if (index == 2) index = 4; // Analog channel reassigment (2 <-> 4) for logical numbering (1,2,3,4) |
333 | if (index == 2) index = 4; // Analog channel reassigment (2 <-> 4) for logical numbering (1,2,3,4) |
325 | else if (index == 4) index = 2; |
334 | else if (index == 4) index = 2; |
326 | #endif |
335 | #endif |
327 | if(abs(signal - PPM_in[index]) < 6) |
336 | if(abs(signal - PPM_in[index]) < 6) |
328 | { |
337 | { |
329 | if(EE_Parameter.FailsafeChannel == 0 || PPM_in[EE_Parameter.FailsafeChannel] < 100) // forces Failsafe if the receiver doesn't have 'signal loss' on Failsafe |
338 | if(EE_Parameter.FailsafeChannel == 0 || PPM_in[EE_Parameter.FailsafeChannel] < 100) // forces Failsafe if the receiver doesn't have 'signal loss' on Failsafe |
Line 339... | Line 348... | ||
339 | tmp = (3 * (PPM_in[index]) + signal) / 4; |
348 | tmp = (3 * (PPM_in[index]) + signal) / 4; |
340 | if(tmp > signal+1) tmp--; else |
349 | if(tmp > signal+1) tmp--; else |
341 | if(tmp < signal-1) tmp++; |
350 | if(tmp < signal-1) tmp++; |
Line 342... | Line 351... | ||
342 | 351 | ||
343 | #ifdef RECEIVER_SPEKTRUM_DX7EXP |
352 | #ifdef RECEIVER_SPEKTRUM_DX7EXP |
344 | if(index == 6) // FLIGHT-MODE - The channel used for our data uplink |
353 | if(index == 6) // FLIGHT-MODE - The channel used for our data uplink |
345 | { |
354 | { |
346 | if (signal > 100) // SYNC received |
355 | if (signal > 100) // SYNC received |
347 | { |
356 | { |
348 | if (s_exdata[s_excnt] == 125) s_exparity = ~s_exparity; // Bit = 1 -> Re-Invert parity bit |
357 | if (s_exdata[s_excnt] == 125) s_exparity = ~s_exparity; // Bit = 1 -> Re-Invert parity bit |
349 | if ((s_excnt == 6 && ((s_exparity != 0 && s_exdata[s_excnt] == -125) || (s_exparity == 0 && s_exdata[s_excnt] == 125))) || (s_excnt == 9 && ((s_exparity == 0 && s_exdata[s_excnt] == -125) || (s_exparity != 0 && s_exdata[s_excnt] == 125)))) // Parity check |
358 | if ((s_excnt == 6 && ((s_exparity != 0 && s_exdata[s_excnt] == -125) || (s_exparity == 0 && s_exdata[s_excnt] == 125))) || (s_excnt == 9 && ((s_exparity == 0 && s_exdata[s_excnt] == -125) || (s_exparity != 0 && s_exdata[s_excnt] == 125)))) // Parity check |
350 | { |
359 | { |
351 | if (s_exdata[1] == 125 && s_exdata[2] == -125) PPM_in[5] = -125; // Reconstruct tripole Flight-Mode value (CH5) |
360 | if (s_exdata[1] == 125 && s_exdata[2] == -125) s_update(5,-125); // Reconstruct tripole Flight-Mode value (CH5) |
352 | else if (s_exdata[1] == -125 && s_exdata[2] == -125) PPM_in[5] = 0; // Reconstruct tripole Flight-Mode value (CH5) |
361 | else if (s_exdata[1] == -125 && s_exdata[2] == -125) s_update(5,0); // Reconstruct tripole Flight-Mode value (CH5) |
353 | else if (s_exdata[1] == -125 && s_exdata[2] == 125) PPM_in[5] = 125; // Reconstruct tripole Flight-Mode value (CH5) |
362 | else if (s_exdata[1] == -125 && s_exdata[2] == 125) s_update(5,125); // Reconstruct tripole Flight-Mode value (CH5) |
354 | PPM_in[6] = s_exdata[3]; // Elevator (CH6) |
363 | s_update(6,s_exdata[3]); // Elevator (CH6) |
355 | PPM_in[11] = s_exdata[4]; // Aileron (CH11) |
364 | s_update(11,s_exdata[4]); // Aileron (CH11) |
Line 356... | Line 365... | ||
356 | PPM_in[12] = s_exdata[5]; // Rudder (CH12) |
365 | s_update(12,s_exdata[5]); // Rudder (CH12) |
357 | 366 | ||
358 | if (s_excnt == 9) // New Mode (12 Channels) |
367 | if (s_excnt == 9) // New Mode (12 Channels) |
359 | { |
368 | { |
360 | if (s_exdata[7] == 125) PPM_in[8] += 5; // Hover Pitch UP (CH8) |
369 | if (s_exdata[7] == 125) s_update(8,PPM_in[8]+5); // Hover Pitch UP (CH8) |
361 | if (s_exdata[8] == 125) PPM_in[8] -= 5; // Hover Pitch DN (CH8) |
370 | if (s_exdata[8] == 125) s_update(8,PPM_in[8]-5); // Hover Pitch DN (CH8) |
362 | if (PPM_in[8] < -125) PPM_in[8] = -125; // Range-Limit |
371 | if (PPM_in[8] < -125) PPM_in[8] = -125; // Range-Limit |
363 | else if (PPM_in[8] > 125) PPM_in[8] = 125; // Range-Limit |
372 | else if (PPM_in[8] > 125) PPM_in[8] = 125; // Range-Limit |
364 | PPM_in[10] = s_exdata[6]; // AUX2 (CH10) |
373 | s_update(10,s_exdata[6]); // AUX2 (CH10) |
Line 365... | Line 374... | ||
365 | } |
374 | } |
366 | } |
375 | } |
367 | 376 | ||
Line 368... | Line 377... | ||
368 | s_excnt = 0; // Reset bitcounter |
377 | s_excnt = 0; // Reset bitcounter |
369 | s_exparity = 0; // Reset parity bit |
378 | s_exparity = 0; // Reset parity bit |
370 | } |
379 | } |
371 | 380 | ||
372 | if (signal < 10) s_exdata[++s_excnt] = -125; // Bit = 0 -> value = -125 (min) |
381 | if (signal < 10) s_exdata[++s_excnt] = -125; // Bit = 0 -> value = -125 (min) |
373 | if (s_excnt == 10) s_excnt = 0; // Overflow protection |
382 | if (s_excnt == 10) s_excnt = 0; // Overflow protection |
374 | if (signal < -100) |
383 | if (signal < -100) |
Line 375... | Line 384... | ||
375 | { |
384 | { |
Line -... | Line 385... | ||
- | 385 | s_exdata[s_excnt] = 125; // Bit = 1 -> value = 125 (max) |
|
- | 386 | s_exparity = ~s_exparity; // Bit = 1 -> Invert parity bit |
|
- | 387 | } |
|
- | 388 | ||
376 | s_exdata[s_excnt] = 125; // Bit = 1 -> value = 125 (max) |
389 | } |
377 | s_exparity = ~s_exparity; // Bit = 1 -> Invert parity bit |
390 | |
378 | } |
391 | if (index < 5 ) s_update(index,tmp); // Update normal potis (CH1-4) |
379 | 392 | else if (index == 5) s_update(7,signal); // Gear (CH7) |
|
380 | } |
393 | else if (index == 7) s_update(9,signal); // Hover Throttle (CH9) |
381 | 394 | ||
382 | #elif defined RECEIVER_SPEKTRUM_DX8EXP |
395 | #elif defined RECEIVER_SPEKTRUM_DX8EXP |
383 | if(index == 6) // FLIGHT-MODE - The channel used for our data uplink |
396 | if(index == 6) // FLIGHT-MODE - The channel used for our data uplink |
384 | { |
397 | { |
385 | if (signal > 100) // SYNC received |
398 | if (signal > 100) // SYNC received |
386 | { |
399 | { |
Line 387... | Line 400... | ||
387 | if (s_exdata[s_excnt] == 125) s_exparity = ~s_exparity; // Bit = 1 -> Re-Invert parity bit |
400 | if (s_exdata[s_excnt] == 125) s_exparity = ~s_exparity; // Bit = 1 -> Re-Invert parity bit |
388 | if (s_excnt == 9 && ((s_exparity == 0 && s_exdata[s_excnt] == -125) || (s_exparity != 0 && s_exdata[s_excnt] == 125))) // Parity check |
401 | if (s_excnt == 9 && ((s_exparity == 0 && s_exdata[s_excnt] == -125) || (s_exparity != 0 && s_exdata[s_excnt] == 125))) // Parity check |
389 | { |
402 | { |
Line 390... | Line 403... | ||
390 | if (s_exdata[1] == 125 && s_exdata[2] == -125) PPM_in[5] = -125; // Reconstruct tripole Flight-Mode value (CH5) |
403 | if (s_exdata[1] == 125 && s_exdata[2] == -125) s_update(5,-125); // Reconstruct tripole Flight-Mode value (CH5) |
391 | else if (s_exdata[1] == -125 && s_exdata[2] == -125) PPM_in[5] = 0; // Reconstruct tripole Flight-Mode value (CH5) |
404 | else if (s_exdata[1] == -125 && s_exdata[2] == -125) s_update(5,0); // Reconstruct tripole Flight-Mode value (CH5) |
392 | else if (s_exdata[1] == -125 && s_exdata[2] == 125) PPM_in[5] = 125; // Reconstruct tripole Flight-Mode value (CH5) |
405 | else if (s_exdata[1] == -125 && s_exdata[2] == 125) s_update(5,125); // Reconstruct tripole Flight-Mode value (CH5) |
Line 393... | Line 406... | ||
393 | 406 | ||
394 | if (s_exdata[3] == 125 && s_exdata[6] == -125) PPM_in[6] = 125; // Reconstruct tripole Elev D/R value (CH6) |
407 | if (s_exdata[3] == 125 && s_exdata[6] == -125) s_update(6,125); // Reconstruct tripole Elev D/R value (CH6) |
395 | else if (s_exdata[3] == -125 && s_exdata[6] == -125) PPM_in[6] = 0; // Reconstruct tripole Elev D/R value (CH6) |
408 | else if (s_exdata[3] == -125 && s_exdata[6] == -125) s_update(6,0); // Reconstruct tripole Elev D/R value (CH6) |
Line 396... | Line 409... | ||
396 | else if (s_exdata[3] == -125 && s_exdata[6] == 125) PPM_in[6] = -125; // Reconstruct tripole Elev D/R value (CH6) |
409 | else if (s_exdata[3] == -125 && s_exdata[6] == 125) s_update(6,-125); // Reconstruct tripole Elev D/R value (CH6) |
397 | 410 | ||
398 | 411 | ||
Line 415... | Line 428... | ||
415 | s_exdata[s_excnt] = 125; // Bit = 1 -> value = 125 (max) |
428 | s_exdata[s_excnt] = 125; // Bit = 1 -> value = 125 (max) |
416 | s_exparity = ~s_exparity; // Bit = 1 -> Invert parity bit |
429 | s_exparity = ~s_exparity; // Bit = 1 -> Invert parity bit |
417 | } |
430 | } |
Line 418... | Line 431... | ||
418 | 431 | ||
419 | } |
- | |
420 | #endif |
- | |
421 | if(SenderOkay >= 180) PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; |
- | |
Line 422... | Line -... | ||
422 | else PPM_diff[index] = 0; |
- | |
423 | 432 | } |
|
424 | #ifdef RECEIVER_SPEKTRUM_DX7EXP |
- | |
425 | if (index < 5 ) PPM_in[index] = tmp; // Update normal potis (CH1-4) |
- | |
426 | else if (index == 5) PPM_in[7] = signal; // Gear (CH7) |
- | |
427 | else if (index == 7) PPM_in[9] = signal; // Hover Throttle (CH9) |
- | |
428 | #elif defined RECEIVER_SPEKTRUM_DX8EXP |
433 | |
429 | if (index < 5 ) PPM_in[index] = tmp; // Update normal potis (CH1-4) |
434 | if (index < 5 ) s_update(index,tmp); // Update normal potis (CH1-4) |
430 | else if (index == 7) PPM_in[7] = signal; // R Trim (CH7) |
435 | else if (index == 7) s_update(7,signal); // R Trim (CH7) |
- | 436 | else if (index == 5) s_update(8,signal); // AUX2 (CH8) |
|
431 | else if (index == 5) PPM_in[8] = signal; // AUX2 (CH8) |
437 | else if (index == 8) s_update(11,signal); // AUX3 (CH11) |
- | 438 | ||
- | 439 | #else |
|
432 | else if (index == 8) PPM_in[11] = signal; // AUX3 (CH11) |
440 | if(SenderOkay >= 180) PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; |
433 | #else |
441 | else PPM_diff[index] = 0; |
434 | PPM_in[index] = tmp; |
442 | PPM_in[index] = tmp; |
435 | #endif |
443 | #endif |
436 | } |
444 | } |