Rev 762 | Rev 783 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 762 | Rev 772 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | #include <avr/interrupt.h> |
29 | #include <avr/interrupt.h> |
30 | #include <util/delay.h> |
30 | #include <util/delay.h> |
31 | #include <avr/pgmspace.h> |
31 | #include <avr/pgmspace.h> |
32 | #include "main.h" |
32 | #include "main.h" |
33 | #include "max7456_software_spi.h" |
33 | #include "max7456_software_spi.h" |
- | 34 | #ifdef ANTENNATRACKTEST |
|
- | 35 | #include "usart0.h" |
|
- | 36 | #endif |
|
34 | #include "usart1.h" |
37 | #include "usart1.h" |
35 | #include "osd_helpers.h" |
38 | #include "osd_helpers.h" |
36 | #include "config.h" |
39 | #include "config.h" |
37 | #include "spi.h" |
40 | #include "spi.h" |
38 | #include "buttons.h" |
41 | #include "buttons.h" |
Line 224... | Line 227... | ||
224 | COSD_FLAGS_CONFIG |= COSD_FLAG_FCMODE; |
227 | COSD_FLAGS_CONFIG |= COSD_FLAG_FCMODE; |
225 | #endif |
228 | #endif |
Line 226... | Line 229... | ||
226 | 229 | ||
227 | 230 | ||
228 | // set up Atmega162 Ports |
231 | // set up Atmega162 Ports |
229 | DDRA |= (1 << PA1); // PA1 output (/CS) |
- | |
230 | MAX_CS_HIGH |
232 | DDRA |= ((1 << PA1) | (1 << PA2) | (1 << PA3) | (1 << PA5)); // PA1 output (/CS) | PA2 output (SDIN) | PA3 output (SCLK) | PA5 output (RESET) |
231 | DDRA |= (1 << PA2); // PA2 output (SDIN) |
- | |
232 | MAX_SDIN_LOW |
233 | MAX_CS_HIGH |
233 | DDRA |= (1 << PA3); // PA3 output (SCLK) |
- | |
234 | MAX_SCLK_LOW |
234 | MAX_SDIN_LOW |
Line 235... | Line 235... | ||
235 | DDRA |= (1 << PA5); // PA5 output (RESET) |
235 | MAX_SCLK_LOW |
236 | MAX_RESET_HIGH |
236 | MAX_RESET_HIGH |
237 | - | ||
238 | DDRC |= (1 << PC0); // PC0 output (LED1 gn) |
237 | |
239 | LED1_OFF |
- | |
240 | DDRC |= (1 << PC1); // PC1 output (LED2 rt) |
238 | DDRC |= ((1 << PC0) | (1 << PC1) | (1 << PC2) | (1 << PC3)); // PC0 output (LED1 gn) | PC1 output (LED2 rt) | PC2 output (LED3 gn) | PC3 output (LED4 rt) |
241 | LED2_OFF |
- | |
242 | DDRC |= (1 << PC2); // PC2 output (LED3 gn) |
239 | LED1_OFF |
Line 243... | Line 240... | ||
243 | LED3_OFF |
240 | LED2_OFF |
244 | DDRC |= (1 << PC3); // PC3 output (LED4 rt) |
- | |
245 | LED4_OFF |
- | |
246 | 241 | LED3_OFF |
|
Line 247... | Line 242... | ||
247 | DDRC &= ~(1 << PC4); // PC4 input (MODE) |
242 | LED4_OFF |
248 | PORTC |= (1 << PC4); // pullup |
243 | |
249 | DDRC &= ~(1 << PC5); // PC5 input (SET) |
244 | DDRC &= ~((1 << PC4) | (1 << PC5)); // PC4 input (MODE) | PC5 input (SET) |
Line 295... | Line 290... | ||
295 | 290 | ||
296 | #if !(ALLCHARSDEBUG|(WRITECHARS != -1)) |
291 | #if !(ALLCHARSDEBUG|(WRITECHARS != -1)) |
297 | // init usart |
292 | // init usart |
Line -... | Line 293... | ||
- | 293 | usart1_init(); |
|
- | 294 | ||
- | 295 | ||
- | 296 | ||
- | 297 | #ifdef ANTENNATRACKTEST |
|
- | 298 | usart0_init(); |
|
298 | usart1_init(); |
299 | #endif |
299 | 300 | ||
Line 300... | Line 301... | ||
300 | // keep serial port clean |
301 | // keep serial port clean |
301 | usart1_DisableTXD(); |
302 | usart1_DisableTXD(); |
Line 391... | Line 392... | ||
391 | osd_ncmode(); |
392 | osd_ncmode(); |
392 | } |
393 | } |
393 | //seconds_since_last_data = 0; |
394 | //seconds_since_last_data = 0; |
394 | } |
395 | } |
395 | #endif |
396 | #endif |
- | 397 | ||
- | 398 | // ONLY FOR TESTING |
|
- | 399 | #ifdef ANTENNATRACKTEST |
|
- | 400 | #include <stdlib.h> |
|
- | 401 | //#include <float.h> |
|
- | 402 | //#include <math.h> |
|
- | 403 | ||
- | 404 | //usart0_puts("\x1B[2J\x1B[H"); |
|
- | 405 | ||
- | 406 | ||
- | 407 | /* |
|
- | 408 | naviData.HomePositionDeviation.Distance = 23 * 100; // 23m away (cm * 100) |
|
- | 409 | naviData.HomePositionDeviation.Bearing = 35; // 35° |
|
- | 410 | altimeter_offset = 50; // 50m start height |
|
- | 411 | naviData.CurrentPosition.Altitude = (int32_t) ((int32_t)250 * (int32_t)1000); // 250m height (mm * 1000) |
|
- | 412 | */ |
|
- | 413 | ||
- | 414 | static char conv_array[7]; |
|
- | 415 | ||
- | 416 | // should be float |
|
- | 417 | int tanheight = (naviData.HomePositionDeviation.Distance * 100) / (naviData.CurrentPosition.Altitude - altimeter_offset); |
|
- | 418 | ||
- | 419 | // we need math.h and some faster AVR :) |
|
- | 420 | //tanheight = rad2deg(atan(tanheight)); |
|
- | 421 | ||
- | 422 | itoa((naviData.HomePositionDeviation.Bearing + 180) % 360, conv_array, 10); |
|
- | 423 | usart0_puts("Bearing: "); |
|
- | 424 | usart0_puts(conv_array); |
|
- | 425 | usart0_puts("\tHeightangle: "); |
|
- | 426 | itoa(tanheight, conv_array, 10); |
|
- | 427 | usart0_puts(conv_array); |
|
- | 428 | usart0_puts("\r\n"); |
|
- | 429 | #endif |
|
- | 430 | ||
- | 431 | ||
396 | rxd_buffer_locked = 0; |
432 | rxd_buffer_locked = 0; |
397 | } |
433 | } |
398 | // handle keypress |
434 | // handle keypress |
399 | if (s1_pressed()) { |
435 | if (s1_pressed()) { |
400 | config_menu(); |
436 | config_menu(); |