Rev 787 | Rev 826 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 787 | Rev 800 | ||
---|---|---|---|
Line 23... | Line 23... | ||
23 | * Gregor "killagreg" Stobrawa for making the MK code readable * |
23 | * Gregor "killagreg" Stobrawa for making the MK code readable * |
24 | * Klaus "akku" Buettner for the hardware * |
24 | * Klaus "akku" Buettner for the hardware * |
25 | * Manuel "KeyOz" Schrape for explaining the MK protocol to me * |
25 | * Manuel "KeyOz" Schrape for explaining the MK protocol to me * |
26 | ****************************************************************************/ |
26 | ****************************************************************************/ |
Line -... | Line 27... | ||
- | 27 | ||
27 | 28 | #include "main.h" |
|
28 | #include <avr/io.h> |
29 | #include <avr/io.h> |
29 | #include <avr/interrupt.h> |
30 | #include <avr/interrupt.h> |
30 | #include <util/delay.h> |
31 | #include <util/delay.h> |
31 | #include <avr/pgmspace.h> |
- | |
32 | #include "main.h" |
32 | #include <avr/pgmspace.h> |
33 | #include "max7456_software_spi.h" |
33 | #include "max7456_software_spi.h" |
34 | #ifdef ANTENNATRACKTEST |
34 | #ifdef ANTENNATRACKTEST |
35 | #include "usart0.h" |
35 | #include "usart0.h" |
36 | #endif |
36 | #endif |
Line 244... | Line 244... | ||
244 | LED2_OFF |
244 | LED2_OFF |
245 | LED3_OFF |
245 | LED3_OFF |
246 | LED4_OFF |
246 | LED4_OFF |
Line 247... | Line 247... | ||
247 | 247 | ||
248 | DDRC &= ~((1 << PC4) | (1 << PC5)); // PC4 input (MODE) | PC5 input (SET) |
248 | DDRC &= ~((1 << PC4) | (1 << PC5)); // PC4 input (MODE) | PC5 input (SET) |
Line 249... | Line 249... | ||
249 | PORTC |= ((1 << PC4) | (1 << PC5)); // pullup |
249 | PORTC |= ((1 << PC4) | (1 << PC5)); // pullup |
250 | 250 | ||
251 | // reset the MAX7456 to be sure any undefined states do no harm |
251 | // reset the MAX7456 to be sure any undefined states do no harm |
Line 257... | Line 257... | ||
257 | _delay_ms(1000); |
257 | _delay_ms(1000); |
258 | LED4_OFF |
258 | LED4_OFF |
Line 259... | Line 259... | ||
259 | 259 | ||
260 | //Pushing NEW chars to the MAX7456 |
260 | //Pushing NEW chars to the MAX7456 |
261 | #if (WRITECHARS != -1) |
261 | #if (WRITECHARS != -1) |
262 | // DISABLE display (VM0) |
262 | // DISABLE display (VM0) |
263 | spi_send_byte(0x00, 0b00000000); |
263 | spi_send_byte(0x00, 0b00000000); |
264 | learn_all_chars_pgm(); |
264 | learn_all_chars_pgm(); |
265 | #else |
265 | #else |
266 | // read out config for NTSC/PAL distinguishing |
266 | // read out config for NTSC/PAL distinguishing |
267 | get_eeprom(0); |
267 | get_eeprom(0); |
Line 297... | Line 297... | ||
297 | usart1_init(); |
297 | usart1_init(); |
Line 298... | Line 298... | ||
298 | 298 | ||
299 | 299 | ||
300 | 300 | ||
Line 301... | Line 301... | ||
301 | #ifdef ANTENNATRACKTEST |
301 | #ifdef ANTENNATRACKTEST |
302 | usart0_init(); |
302 | usart0_init(); |
Line 336... | Line 336... | ||
336 | 336 | ||
337 | 337 | ||
Line 338... | Line 338... | ||
338 | // clear serial screen |
338 | // clear serial screen |
339 | //usart1_puts("\x1B[2J\x1B[H"); |
339 | //usart1_puts("\x1B[2J\x1B[H"); |
340 | 340 | ||
341 | #if !FCONLY |
341 | #if !FCONLY |
342 | usart1_request_nc_uart(); |
342 | usart1_request_nc_uart(); |
343 | #endif |
343 | #endif |
344 | 344 | ||
345 | while (1) { |
345 | while (1) { |
346 | // in case SPI is ready and there is nothing to send right now |
346 | // in case SPI is ready and there is nothing to send right now |
Line 401... | Line 401... | ||
401 | } |
401 | } |
402 | //seconds_since_last_data = 0; |
402 | //seconds_since_last_data = 0; |
403 | } |
403 | } |
404 | #endif |
404 | #endif |
Line 405... | Line 405... | ||
405 | 405 | ||
406 | // ONLY FOR TESTING |
406 | // ONLY FOR TESTING |
407 | #ifdef ANTENNATRACKTEST |
407 | #ifdef ANTENNATRACKTEST |
408 | #include <stdlib.h> |
408 | #include <stdlib.h> |
409 | //#include <float.h> |
409 | //#include <float.h> |
410 | //#include <math.h> |
410 | //#include <math.h> |
411 | 411 | ||
412 | //usart0_puts("\x1B[2J\x1B[H"); |
412 | //usart0_puts("\x1B[2J\x1B[H"); |
413 | 413 | ||
414 | 414 | ||
415 | /* |
415 | /* |
416 | naviData.HomePositionDeviation.Distance = 23 * 100; // 23m away (cm * 100) |
416 | naviData.HomePositionDeviation.Distance = 23 * 100; // 23m away (cm * 100) |
417 | naviData.HomePositionDeviation.Bearing = 35; // 35° |
417 | naviData.HomePositionDeviation.Bearing = 35; // 35� |
418 | altimeter_offset = 50; // 50m start height |
418 | altimeter_offset = 50; // 50m start height |
419 | naviData.CurrentPosition.Altitude = (int32_t) ((int32_t)250 * (int32_t)1000); // 250m height (mm * 1000) |
419 | naviData.CurrentPosition.Altitude = (int32_t) ((int32_t)250 * (int32_t)1000); // 250m height (mm * 1000) |
420 | */ |
420 | */ |
421 | 421 | ||
422 | static char conv_array[7]; |
422 | static char conv_array[7]; |
423 | 423 | ||
424 | // should be float |
424 | // should be float |
425 | int tanheight = (naviData.HomePositionDeviation.Distance * 100) / (naviData.CurrentPosition.Altitude - altimeter_offset); |
425 | int tanheight = (naviData.HomePositionDeviation.Distance * 100) / (naviData.CurrentPosition.Altitude - altimeter_offset); |
426 | 426 | ||
427 | // we need math.h and some faster AVR :) |
427 | // we need math.h and some faster AVR :) |
428 | //tanheight = rad2deg(atan(tanheight)); |
428 | //tanheight = rad2deg(atan(tanheight)); |
429 | 429 | ||
430 | itoa((naviData.HomePositionDeviation.Bearing + 180) % 360, conv_array, 10); |
430 | itoa((naviData.HomePositionDeviation.Bearing + 180) % 360, conv_array, 10); |
431 | usart0_puts("Bearing: "); |
431 | usart0_puts("Bearing: "); |
432 | usart0_puts(conv_array); |
432 | usart0_puts(conv_array); |
433 | usart0_puts("\tHeightangle: "); |
433 | usart0_puts("\tHeightangle: "); |
434 | itoa(tanheight, conv_array, 10); |
434 | itoa(tanheight, conv_array, 10); |
435 | usart0_puts(conv_array); |
435 | usart0_puts(conv_array); |
436 | usart0_puts("\r\n"); |
436 | usart0_puts("\r\n"); |
Line 437... | Line 437... | ||
437 | #endif |
437 | #endif |
438 | 438 | ||
439 | 439 | ||
Line 454... | Line 454... | ||
454 | // request OSD Data from NC every 100ms |
454 | // request OSD Data from NC every 100ms |
455 | //usart1_request_mk_data(1, 'o', 100); |
455 | //usart1_request_mk_data(1, 'o', 100); |
456 | usart1_puts_pgm(PSTR(REQUEST_OSD_DATA)); |
456 | usart1_puts_pgm(PSTR(REQUEST_OSD_DATA)); |
Line 457... | Line 457... | ||
457 | 457 | ||
458 | // and disable debug... |
458 | // and disable debug... |
459 | //usart1_request_mk_data(0, 'd', 0); |
459 | //usart1_request_mk_data(0, 'd', 0); |
460 | #endif |
460 | #endif |
461 | // reset last time counter |
461 | // reset last time counter |
462 | seconds_since_last_data = 0; |
462 | seconds_since_last_data = 0; |
463 | usart1_DisableTXD(); |
463 | usart1_DisableTXD(); |
464 | } |
464 | } |
Line 465... | Line 465... | ||
465 | } |
465 | } |
466 | 466 | ||
467 | #else // character flashing... |
467 | #else // character flashing... |
468 | clear(); |
468 | clear(); |
469 | write_all_chars(); |
469 | write_all_chars(); |
470 | LED1_ON |
470 | LED1_ON |
471 | LED2_ON |
471 | LED2_ON |
472 | LED3_ON |
472 | LED3_ON |
Line 473... | Line 473... | ||
473 | LED4_ON |
473 | LED4_ON |
474 | while(1) { |
474 | while (1) { |
Line 475... | Line 475... | ||
475 | 475 | ||
476 | }; |
476 | }; |