Rev 1437 | Rev 1866 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1437 | Rev 1801 | ||
---|---|---|---|
Line 28... | Line 28... | ||
28 | #include "main.h" |
28 | #include "main.h" |
29 | #include <avr/io.h> |
29 | #include <avr/io.h> |
30 | #include <avr/interrupt.h> |
30 | #include <avr/interrupt.h> |
31 | #include <util/delay.h> |
31 | #include <util/delay.h> |
32 | #include <avr/pgmspace.h> |
32 | #include <avr/pgmspace.h> |
- | 33 | #include <string.h> |
|
33 | #include "max7456_software_spi.h" |
34 | #include "max7456_software_spi.h" |
34 | #ifdef ANTENNATRACKTEST |
35 | #ifdef ANTENNATRACKTEST |
35 | #include "usart0.h" |
36 | #include "usart0.h" |
36 | #endif |
37 | #endif |
37 | #include "usart1.h" |
38 | #include "usart1.h" |
Line 62... | Line 63... | ||
62 | 63 | ||
63 | #if FCONLY |
64 | #if FCONLY |
64 | volatile str_DebugOut debugData; |
65 | volatile str_DebugOut debugData; |
65 | #else |
66 | #else |
- | 67 | volatile NaviData_t naviData; |
|
66 | volatile NaviData_t naviData; |
68 | volatile Data3D_t data3d; |
Line 67... | Line 69... | ||
67 | #endif |
69 | #endif |
68 | 70 | ||
69 | // cache old vars for blinking attribute, checkup is faster than full |
71 | // cache old vars for blinking attribute, checkup is faster than full |
Line 373... | Line 375... | ||
373 | seconds_since_last_data = 0; |
375 | seconds_since_last_data = 0; |
374 | } |
376 | } |
375 | #else |
377 | #else |
376 | if (rxd_buffer[2] == 'O') { // NC OSD Data |
378 | if (rxd_buffer[2] == 'O') { // NC OSD Data |
377 | Decode64(); |
379 | Decode64(); |
378 | naviData = *((NaviData_t*)pRxData); |
380 | //naviData = *((NaviData_t*)pRxData); |
- | 381 | memcpy((char*)(&naviData), (char*)pRxData, sizeof(NaviData_t)); |
|
- | 382 | rxd_buffer_locked = 0; |
|
Line 379... | Line 383... | ||
379 | 383 | ||
380 | #ifdef SHIFTBYminus45 |
384 | #ifdef SHIFTBYminus45 |
381 | naviData.AngleNick = (int8_t)(((int16_t)naviData.AngleRoll + (int16_t)naviData.AngleNick) / 2); |
385 | naviData.AngleNick = (int8_t)(((int16_t)naviData.AngleRoll + (int16_t)naviData.AngleNick) / 2); |
382 | naviData.AngleRoll = (int8_t)(((int16_t)naviData.AngleRoll - (int16_t)naviData.AngleNick) / 2); |
386 | naviData.AngleRoll = (int8_t)(((int16_t)naviData.AngleRoll - (int16_t)naviData.AngleNick) / 2); |
Line 393... | Line 397... | ||
393 | } |
397 | } |
394 | } else { |
398 | } else { |
395 | osd_ncmode(); |
399 | osd_ncmode(); |
396 | } |
400 | } |
397 | //seconds_since_last_data = 0; |
401 | //seconds_since_last_data = 0; |
- | 402 | // } else if (rxd_buffer[2] == 'C') { // 3D and Stick Data |
|
- | 403 | // Decode64(); |
|
- | 404 | // memcpy((char*)(&data3d), (char*)pRxData, sizeof(Data3D_t)); |
|
- | 405 | // rxd_buffer_locked = 0; |
|
398 | } |
406 | } else { |
- | 407 | rxd_buffer_locked = 0; |
|
- | 408 | } |
|
399 | #endif |
409 | #endif |
Line 400... | Line 410... | ||
400 | 410 | ||
401 | // ONLY FOR TESTING |
411 | // ONLY FOR TESTING |
402 | #ifdef ANTENNATRACKTEST |
412 | #ifdef ANTENNATRACKTEST |
Line 428... | Line 438... | ||
428 | usart0_puts("\tHeightangle: "); |
438 | usart0_puts("\tHeightangle: "); |
429 | itoa(tanheight, conv_array, 10); |
439 | itoa(tanheight, conv_array, 10); |
430 | usart0_puts(conv_array); |
440 | usart0_puts(conv_array); |
431 | usart0_puts("\r\n"); |
441 | usart0_puts("\r\n"); |
432 | #endif |
442 | #endif |
433 | rxd_buffer_locked = 0; |
- | |
- | 443 | ||
434 | } |
444 | } |
435 | // handle keypress |
445 | // handle keypress |
436 | if (s1_pressed()) { |
446 | if (s1_pressed()) { |
437 | config_menu(); |
447 | config_menu(); |
438 | } |
448 | } |
Line 449... | Line 459... | ||
449 | #else |
459 | #else |
450 | // request OSD Data from NC every 100ms |
460 | // request OSD Data from NC every 100ms |
451 | //usart1_request_mk_data(1, 'o', 100); |
461 | //usart1_request_mk_data(1, 'o', 100); |
452 | usart1_puts_pgm(PSTR(REQUEST_OSD_DATA)); |
462 | usart1_puts_pgm(PSTR(REQUEST_OSD_DATA)); |
Line -... | Line 463... | ||
- | 463 | ||
- | 464 | ||
- | 465 | ||
- | 466 | // request 3D Data from NC every 100ms |
|
- | 467 | //usart1_request_mk_data(1, 'c', 100); |
|
- | 468 | // _delay_ms(10); |
|
- | 469 | // usart1_puts_pgm(PSTR(REQUEST_3DDATA)); |
|
453 | 470 | ||
454 | // and disable debug... |
471 | // and disable debug... |
455 | //usart1_request_mk_data(0, 'd', 0); |
472 | //usart1_request_mk_data(0, 'd', 0); |
456 | #endif |
473 | #endif |
457 | // reset last time counter |
474 | // reset last time counter |
458 | seconds_since_last_data = 0; |
475 | seconds_since_last_data = 0; |
Line 459... | Line 476... | ||
459 | usart1_DisableTXD(); |
476 | usart1_DisableTXD(); |
460 | 477 | ||
461 | // do not spam too much |
478 | // do not spam too much |
462 | if (!(COSD_FLAGS_RUNTIME & COSD_DATARECEIVED)) { |
479 | if (!(COSD_FLAGS_RUNTIME & COSD_DATARECEIVED)) { |
463 | _delay_ms(300); |
480 | _delay_ms(100); |
Line 464... | Line 481... | ||
464 | } |
481 | } |