25,11 → 25,11 |
* Manuel "KeyOz" Schrape for explaining the MK protocol to me * |
****************************************************************************/ |
|
#include "main.h" |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <util/delay.h> |
#include <avr/pgmspace.h> |
#include "main.h" |
#include "max7456_software_spi.h" |
#ifdef ANTENNATRACKTEST |
#include "usart0.h" |
246,7 → 246,7 |
LED4_OFF |
|
DDRC &= ~((1 << PC4) | (1 << PC5)); // PC4 input (MODE) | PC5 input (SET) |
PORTC |= ((1 << PC4) | (1 << PC5)); // pullup |
PORTC |= ((1 << PC4) | (1 << PC5)); // pullup |
|
// reset the MAX7456 to be sure any undefined states do no harm |
MAX_RESET_LOW |
259,8 → 259,8 |
|
//Pushing NEW chars to the MAX7456 |
#if (WRITECHARS != -1) |
// DISABLE display (VM0) |
spi_send_byte(0x00, 0b00000000); |
// DISABLE display (VM0) |
spi_send_byte(0x00, 0b00000000); |
learn_all_chars_pgm(); |
#else |
// read out config for NTSC/PAL distinguishing |
299,7 → 299,7 |
|
|
#ifdef ANTENNATRACKTEST |
usart0_init(); |
usart0_init(); |
#endif |
|
// keep serial port clean |
338,10 → 338,10 |
// clear serial screen |
//usart1_puts("\x1B[2J\x1B[H"); |
|
#if !FCONLY |
usart1_request_nc_uart(); |
#endif |
|
#if !FCONLY |
usart1_request_nc_uart(); |
#endif |
|
while (1) { |
// in case SPI is ready and there is nothing to send right now |
if (!icnt && spi_ready) { |
403,40 → 403,40 |
} |
#endif |
|
// ONLY FOR TESTING |
#ifdef ANTENNATRACKTEST |
#include <stdlib.h> |
//#include <float.h> |
//#include <math.h> |
// ONLY FOR TESTING |
#ifdef ANTENNATRACKTEST |
#include <stdlib.h> |
//#include <float.h> |
//#include <math.h> |
|
//usart0_puts("\x1B[2J\x1B[H"); |
//usart0_puts("\x1B[2J\x1B[H"); |
|
|
/* |
naviData.HomePositionDeviation.Distance = 23 * 100; // 23m away (cm * 100) |
naviData.HomePositionDeviation.Bearing = 35; // 35° |
altimeter_offset = 50; // 50m start height |
naviData.CurrentPosition.Altitude = (int32_t) ((int32_t)250 * (int32_t)1000); // 250m height (mm * 1000) |
*/ |
/* |
naviData.HomePositionDeviation.Distance = 23 * 100; // 23m away (cm * 100) |
naviData.HomePositionDeviation.Bearing = 35; // 35� |
altimeter_offset = 50; // 50m start height |
naviData.CurrentPosition.Altitude = (int32_t) ((int32_t)250 * (int32_t)1000); // 250m height (mm * 1000) |
*/ |
|
static char conv_array[7]; |
|
// should be float |
int tanheight = (naviData.HomePositionDeviation.Distance * 100) / (naviData.CurrentPosition.Altitude - altimeter_offset); |
|
// we need math.h and some faster AVR :) |
//tanheight = rad2deg(atan(tanheight)); |
static char conv_array[7]; |
|
itoa((naviData.HomePositionDeviation.Bearing + 180) % 360, conv_array, 10); |
usart0_puts("Bearing: "); |
usart0_puts(conv_array); |
usart0_puts("\tHeightangle: "); |
itoa(tanheight, conv_array, 10); |
usart0_puts(conv_array); |
usart0_puts("\r\n"); |
#endif |
// should be float |
int tanheight = (naviData.HomePositionDeviation.Distance * 100) / (naviData.CurrentPosition.Altitude - altimeter_offset); |
|
// we need math.h and some faster AVR :) |
//tanheight = rad2deg(atan(tanheight)); |
|
itoa((naviData.HomePositionDeviation.Bearing + 180) % 360, conv_array, 10); |
usart0_puts("Bearing: "); |
usart0_puts(conv_array); |
usart0_puts("\tHeightangle: "); |
itoa(tanheight, conv_array, 10); |
usart0_puts(conv_array); |
usart0_puts("\r\n"); |
#endif |
|
|
rxd_buffer_locked = 0; |
} |
// handle keypress |
456,7 → 456,7 |
usart1_puts_pgm(PSTR(REQUEST_OSD_DATA)); |
|
// and disable debug... |
//usart1_request_mk_data(0, 'd', 0); |
//usart1_request_mk_data(0, 'd', 0); |
#endif |
// reset last time counter |
seconds_since_last_data = 0; |
465,15 → 465,15 |
} |
|
#else // character flashing... |
clear(); |
clear(); |
write_all_chars(); |
LED1_ON |
LED2_ON |
LED3_ON |
LED4_ON |
while(1) { |
while (1) { |
|
}; |
}; |
#endif |
|
|