Rev 379 | Rev 385 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 379 | Rev 383 | ||
---|---|---|---|
Line 235... | Line 235... | ||
235 | if (variometer == 0) { |
235 | if (variometer == 0) { |
236 | write_char_xy(x, y, 0xbb); // plain line |
236 | write_char_xy(x, y, 0xbb); // plain line |
237 | } else if (variometer > 0) { // gain height |
237 | } else if (variometer > 0) { // gain height |
238 | switch (variometer / 5){ |
238 | switch (variometer / 5){ |
239 | case 0: |
239 | case 0: |
240 | write_char_xy(x, y, 0xba); // smallest arrow up |
240 | //write_char_xy(x, y, 0xba); // smallest arrow up |
- | 241 | write_char_xy(x, y, 0x70); // one arrow up |
|
241 | break; |
242 | break; |
242 | case 1: |
243 | case 1: |
243 | write_char_xy(x, y, 0xb9); // small arrow up |
244 | //write_char_xy(x, y, 0xb9); // small arrow up |
- | 245 | write_char_xy(x, y, 0x71); // two arrows up |
|
244 | break; |
246 | break; |
245 | case 2: |
247 | case 2: |
246 | write_char_xy(x, y, 0xb8); // large arrow up |
248 | //write_char_xy(x, y, 0xb8); // large arrow up |
- | 249 | write_char_xy(x, y, 0x72); // three arrows up |
|
247 | break; |
250 | break; |
248 | default: |
251 | default: |
249 | write_char_xy(x, y, 0xb7); // largest arrow up |
252 | //write_char_xy(x, y, 0xb7); // largest arrow up |
- | 253 | write_char_xy(x, y, 0x73); // three black arrows up |
|
250 | } |
254 | } |
251 | } else { // sink |
255 | } else { // sink |
252 | switch (variometer / -5){ |
256 | switch (variometer / -5){ |
253 | case 0: |
257 | case 0: |
254 | write_char_xy(x, y, 0xbc); // smallest arrow down |
258 | //write_char_xy(x, y, 0xbc); // smallest arrow down |
- | 259 | write_char_xy(x, y, 0x77); // one arrow down |
|
255 | break; |
260 | break; |
256 | case 1: |
261 | case 1: |
257 | write_char_xy(x, y, 0xbd); // small arrow down |
262 | //write_char_xy(x, y, 0xbd); // small arrow down |
- | 263 | write_char_xy(x, y, 0x76); // two arrows down |
|
258 | break; |
264 | break; |
259 | case 2: |
265 | case 2: |
260 | write_char_xy(x, y, 0xbe); // large arrow down |
266 | //write_char_xy(x, y, 0xbe); // large arrow down |
- | 267 | write_char_xy(x, y, 0x75); // three arrows down |
|
261 | break; |
268 | break; |
262 | default: |
269 | default: |
263 | write_char_xy(x, y, 0xbf); // largest arrow down |
270 | //write_char_xy(x, y, 0xbf); // largest arrow down |
- | 271 | write_char_xy(x, y, 0x74); // three black arrows down |
|
264 | } |
272 | } |
265 | } |
273 | } |
266 | } |
274 | } |
Line 267... | Line 275... | ||
267 | 275 | ||
Line 382... | Line 390... | ||
382 | /** |
390 | /** |
383 | * helper function for menu updating |
391 | * helper function for menu updating |
384 | */ |
392 | */ |
385 | void config_menu_drawings(uint8_t chosen) { |
393 | void config_menu_drawings(uint8_t chosen) { |
386 | // clear prevoius _cursor_ |
394 | // clear prevoius _cursor_ |
387 | write_ascii_string(3, (chosen + 6) % 7, " "); |
395 | write_ascii_string(3, (chosen + 5) % 8, " "); |
388 | // draw current _cursor_ |
396 | // draw current _cursor_ |
389 | write_ascii_string(3, chosen + 6, ">"); |
397 | write_ascii_string(3, chosen + 5, ">"); |
390 | if (COSD_FLAGS & COSD_FLAG_HUD) { |
398 | if (COSD_FLAGS & COSD_FLAG_HUD) { |
- | 399 | write_ascii_string_pgm(23, 5, ON); |
|
- | 400 | } else { |
|
- | 401 | write_ascii_string_pgm(23, 5, OFF); |
|
- | 402 | } |
|
- | 403 | if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) { |
|
391 | write_ascii_string_pgm(23, 6, ON); |
404 | write_ascii_string_pgm(23, 6, ON); |
392 | } else { |
405 | } else { |
393 | write_ascii_string_pgm(23, 6, OFF); |
406 | write_ascii_string_pgm(23, 6, OFF); |
394 | } |
407 | } |
395 | if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) { |
408 | if (COSD_FLAGS & COSD_FLAG_BIGVARIO) { |
396 | write_ascii_string_pgm(23, 7, ON); |
409 | write_ascii_string_pgm(23, 7, ON); |
397 | } else { |
410 | } else { |
398 | write_ascii_string_pgm(23, 7, OFF); |
411 | write_ascii_string_pgm(23, 7, OFF); |
399 | } |
412 | } |
400 | if (COSD_FLAGS & COSD_FLAG_STATS) { |
413 | if (COSD_FLAGS & COSD_FLAG_STATS) { |
Line 411... | Line 424... | ||
411 | 424 | ||
412 | /** |
425 | /** |
413 | * some sort of clicking response in the menu |
426 | * some sort of clicking response in the menu |
414 | */ |
427 | */ |
415 | void config_menu_doclick(uint8_t chosen, char** menu) { |
428 | void config_menu_doclick(uint8_t chosen, char** menu) { |
416 | write_ascii_string(4, chosen + 6, "DONE "); |
429 | write_ascii_string(4, chosen + 5, "DONE "); |
417 | _delay_ms(1000); |
430 | _delay_ms(1000); |
418 | write_ascii_string(4, chosen + 6, menu[chosen]); |
431 | write_ascii_string(4, chosen + 5, menu[chosen]); |
Line 419... | Line 432... | ||
419 | } |
432 | } |
420 | 433 | ||
421 | /** |
434 | /** |
Line 426... | Line 439... | ||
426 | cli(); |
439 | cli(); |
Line 427... | Line 440... | ||
427 | 440 | ||
428 | // clear screen |
441 | // clear screen |
Line 429... | Line 442... | ||
429 | clear(); |
442 | clear(); |
430 | 443 | ||
- | 444 | char* menu[9] = {"Full HUD", |
|
431 | char* menu[8] = {"Full HUD", |
445 | "Art.Horizon in HUD", |
432 | "Art.Horizon in HUD", |
446 | "Big Vario bar", |
433 | "Statistics", |
447 | "Statistics", |
434 | "Warnings", // TODO: do it! |
448 | "Warnings", // TODO: do it! |
435 | "Reset uptime", |
449 | "Reset uptime", |
Line 442... | Line 456... | ||
442 | write_ascii_string(6, 2, "C-OSD Config Menu"); |
456 | write_ascii_string(6, 2, "C-OSD Config Menu"); |
Line 443... | Line 457... | ||
443 | 457 | ||
444 | // wait a bit before doing stuff so user has chance to release button |
458 | // wait a bit before doing stuff so user has chance to release button |
Line -... | Line 459... | ||
- | 459 | _delay_ms(250); |
|
445 | _delay_ms(250); |
460 | |
446 | 461 | write_ascii_string(4, 5, menu[0]); |
|
447 | write_ascii_string(4, 6, menu[0]); |
462 | write_ascii_string(4, 6, menu[1]); |
448 | write_ascii_string(4, 7, menu[1]); |
463 | write_ascii_string(4, 7, menu[2]); |
449 | write_ascii_string(4, 8, menu[2]); |
464 | write_ascii_string(4, 8, menu[3]); |
450 | write_ascii_string(4, 9, menu[3]); |
465 | write_ascii_string(4, 9, menu[4]); |
451 | write_ascii_string(4, 10, menu[4]); |
466 | write_ascii_string(4, 10, menu[5]); |
452 | write_ascii_string(4, 11, menu[5]); |
467 | write_ascii_string(4, 11, menu[6]); |
Line 453... | Line 468... | ||
453 | write_ascii_string(4, 12, menu[6]); |
468 | write_ascii_string(4, 12, menu[7]); |
Line 454... | Line 469... | ||
454 | write_ascii_string(4, 13, menu[7]); |
469 | write_ascii_string(4, 13, menu[8]); |
455 | 470 | ||
456 | config_menu_drawings(chosen); |
471 | config_menu_drawings(chosen); |
457 | 472 | ||
458 | while (inmenu) { |
473 | while (inmenu) { |
459 | if (s2_pressed()) { |
474 | if (s2_pressed()) { |
460 | write_ascii_string(3, chosen+6, " "); |
475 | write_ascii_string(3, chosen+5, " "); |
461 | chosen = (chosen + 1) % 8; |
476 | chosen = (chosen + 1) % 9; |
462 | write_ascii_string(3, chosen+6, ">"); |
477 | write_ascii_string(3, chosen+5, ">"); |
463 | _delay_ms(500); |
478 | _delay_ms(500); |
Line 469... | Line 484... | ||
469 | break; |
484 | break; |
470 | case 1: // art horizon |
485 | case 1: // art horizon |
471 | COSD_FLAGS ^= COSD_FLAG_ARTHORIZON; |
486 | COSD_FLAGS ^= COSD_FLAG_ARTHORIZON; |
472 | config_menu_drawings(chosen); |
487 | config_menu_drawings(chosen); |
473 | break; |
488 | break; |
- | 489 | case 2: // big vario |
|
- | 490 | COSD_FLAGS ^= COSD_FLAG_BIGVARIO; |
|
- | 491 | config_menu_drawings(chosen); |
|
- | 492 | break; |
|
474 | case 2: // statistics |
493 | case 3: // statistics |
475 | COSD_FLAGS ^= COSD_FLAG_STATS; |
494 | COSD_FLAGS ^= COSD_FLAG_STATS; |
476 | config_menu_drawings(chosen); |
495 | config_menu_drawings(chosen); |
477 | break; |
496 | break; |
478 | case 3: // warnings |
497 | case 4: // warnings |
479 | COSD_FLAGS ^= COSD_FLAG_WARNINGS; |
498 | COSD_FLAGS ^= COSD_FLAG_WARNINGS; |
480 | config_menu_drawings(chosen); |
499 | config_menu_drawings(chosen); |
481 | break; |
500 | break; |
482 | case 4: // reset uptime |
501 | case 5: // reset uptime |
483 | uptime = 0; |
502 | uptime = 0; |
484 | config_menu_doclick(chosen, menu); |
503 | config_menu_doclick(chosen, menu); |
485 | break; |
504 | break; |
486 | case 5: // re-request OSD data |
505 | case 6: // re-request OSD data |
487 | // request OSD Data from NC every 100ms |
506 | // request OSD Data from NC every 100ms |
488 | usart1_request_mk_data(1, 'o', 100); |
507 | usart1_request_mk_data(1, 'o', 100); |
489 | config_menu_doclick(chosen, menu); |
508 | config_menu_doclick(chosen, menu); |
490 | break; |
509 | break; |
491 | case 6: // disable debug data |
510 | case 7: // disable debug data |
492 | // disable sending of debug data |
511 | // disable sending of debug data |
493 | // may result in smoother ddata display |
512 | // may result in smoother ddata display |
494 | usart1_request_mk_data(0, 'd', 0); |
513 | usart1_request_mk_data(0, 'd', 0); |
495 | config_menu_doclick(chosen, menu); |
514 | config_menu_doclick(chosen, menu); |
496 | break; |
515 | break; |
497 | case 7: // exit |
516 | case 8: // exit |
498 | inmenu = 0; |
517 | inmenu = 0; |
499 | break; |
518 | break; |
500 | } |
519 | } |
501 | _delay_ms(250); |
520 | _delay_ms(250); |
502 | } |
521 | } |
Line 519... | Line 538... | ||
519 | int main(void) { |
538 | int main(void) { |
520 | // set up FLAGS, compiler should flatten this one |
539 | // set up FLAGS, compiler should flatten this one |
521 | COSD_FLAGS = (NTSC << 0); |
540 | COSD_FLAGS = (NTSC << 0); |
522 | COSD_FLAGS |= (HUD << 1); |
541 | COSD_FLAGS |= (HUD << 1); |
523 | COSD_FLAGS |= (ARTHORIZON << 2); |
542 | COSD_FLAGS |= (ARTHORIZON << 2); |
- | 543 | COSD_FLAGS |= (BIGVARIO << 3); |
|
524 | COSD_FLAGS |= (STATS << 3); |
544 | COSD_FLAGS |= (STATS << 4); |
525 | COSD_FLAGS |= (WARNINGS << 4); |
545 | COSD_FLAGS |= (WARNINGS << 5); |
Line 526... | Line 546... | ||
526 | 546 | ||
527 | // set up Atmega162 Ports |
547 | // set up Atmega162 Ports |
528 | DDRA |= (1 << PA1); // PA1 output (/CS) |
548 | DDRA |= (1 << PA1); // PA1 output (/CS) |
529 | MAX_CS_HIGH |
549 | MAX_CS_HIGH |
Line 679... | Line 699... | ||
679 | // write icons at init or after menu/mode-switch |
699 | // write icons at init or after menu/mode-switch |
680 | if (!(COSD_FLAGS & COSD_ICONS_WRITTEN) && (COSD_FLAGS & COSD_FLAG_HUD)) { |
700 | if (!(COSD_FLAGS & COSD_ICONS_WRITTEN) && (COSD_FLAGS & COSD_FLAG_HUD)) { |
681 | write_char_xy(5, top_line, 203); // km/h |
701 | write_char_xy(5, top_line, 203); // km/h |
682 | write_char_xy(10, top_line, 202); // RC-transmitter |
702 | write_char_xy(10, top_line, 202); // RC-transmitter |
683 | write_char_xy(16, top_line, 208); // degree symbol |
703 | write_char_xy(16, top_line, 208); // degree symbol |
684 | write_char_xy(27, top_line, 204); // small meters m |
704 | write_char_xy(27, top_line, 204); // small meters m height |
- | 705 | write_char_xy(20, top_line+1, 0xb0); // left circle |
|
- | 706 | write_char_xy(22, top_line+1, 0xb2); // right circle |
|
- | 707 | write_char_xy(27, top_line+1, 204); // small meters m home |
|
685 | //write_ascii_string(6, bottom_line, "V"); // voltage |
708 | //write_ascii_string(6, bottom_line, "V"); // voltage |
686 | write_char_xy(14, bottom_line, 209); // on clock |
709 | write_char_xy(14, bottom_line, 209); // on clock |
687 | write_char_xy(22, bottom_line, 210); // fly clock |
710 | write_char_xy(22, bottom_line, 210); // fly clock |
688 | write_char_xy(26, bottom_line, 200); // sat1 |
711 | write_char_xy(26, bottom_line, 200); // sat1 |
689 | write_char_xy(27, bottom_line, 201); // sat2 |
712 | write_char_xy(27, bottom_line, 201); // sat2 |
Line 704... | Line 727... | ||
704 | write_number_s(12, 8, debugData.Analog[11]);// Gyro compass*/ |
727 | write_number_s(12, 8, debugData.Analog[11]);// Gyro compass*/ |
705 | } else if (rxd_buffer[2] == 'O') { // NC OSD Data |
728 | } else if (rxd_buffer[2] == 'O') { // NC OSD Data |
706 | Decode64(); |
729 | Decode64(); |
707 | naviData = *((NaviData_t*) pRxData); |
730 | naviData = *((NaviData_t*) pRxData); |
Line 708... | Line -... | ||
708 | - | ||
709 | draw_big_variometer(27, 8, naviData.Variometer); |
- | |
710 | 731 | ||
711 | // first line |
732 | // first line |
Line 712... | Line 733... | ||
712 | write_ndigit_number_u(2, top_line, (uint16_t) (((uint32_t) naviData.GroundSpeed * (uint32_t)9) / (uint32_t)250), 100, 0); |
733 | write_ndigit_number_u(2, top_line, (uint16_t) (((uint32_t) naviData.GroundSpeed * (uint32_t)9) / (uint32_t)250), 100, 0); |
713 | 734 | ||
Line 723... | Line 744... | ||
723 | 744 | ||
Line 724... | Line 745... | ||
724 | write_ndigit_number_u(13, top_line, naviData.CompassHeading, 100, 0); |
745 | write_ndigit_number_u(13, top_line, naviData.CompassHeading, 100, 0); |
Line 725... | Line 746... | ||
725 | 746 | ||
Line 726... | Line 747... | ||
726 | write_ascii_string(17, top_line, directions[heading_conv(naviData.CompassHeading)]); |
747 | write_ascii_string(17, top_line, directions[heading_conv(naviData.CompassHeading)]); |
727 | 748 | ||
728 | draw_variometer(20, top_line, naviData.Variometer); |
749 | draw_variometer(21, top_line, naviData.Variometer); |
729 | 750 | ||
Line 740... | Line 761... | ||
740 | // seccond line |
761 | // seccond line |
741 | draw_compass(11, top_line + 1, naviData.CompassHeading); |
762 | draw_compass(11, top_line + 1, naviData.CompassHeading); |
Line 742... | Line 763... | ||
742 | 763 | ||
743 | // TODO: verify correctness |
764 | // TODO: verify correctness |
744 | uint16_t heading_home = (naviData.HomePositionDeviation.Bearing + 360 - naviData.CompassHeading) % 360; |
765 | uint16_t heading_home = (naviData.HomePositionDeviation.Bearing + 360 - naviData.CompassHeading) % 360; |
745 | //write_char_xy(27, top_line + 1, arrowdir[heading_conv(heading_home)]); |
766 | //write_char_xy(21, top_line + 1, arrowdir[heading_conv(heading_home)]); |
746 | // finer resolution, 0xa0 is first character and we add the index 0 <= index < 16 |
767 | // finer resolution, 0xa0 is first character and we add the index 0 <= index < 16 |
Line 747... | Line 768... | ||
747 | write_char_xy(27, top_line + 1, 0xa0 + heading_fine_conv(heading_home)); |
768 | write_char_xy(21, top_line + 1, 0xa0 + heading_fine_conv(heading_home)); |
Line 748... | Line 769... | ||
748 | 769 | ||
749 | write_ndigit_number_u(24, top_line + 1, naviData.HomePositionDeviation.Distance / 10, 100, 0); |
770 | write_ndigit_number_u(24, top_line + 1, naviData.HomePositionDeviation.Distance / 10, 100, 0); |
Line 778... | Line 799... | ||
778 | write_char_xy(22, 9, 210); // fly clock |
799 | write_char_xy(22, 9, 210); // fly clock |
779 | } else if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) { // if no stats there is space horizon |
800 | } else if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) { // if no stats there is space horizon |
780 | draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll); |
801 | draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll); |
781 | } |
802 | } |
782 | } |
803 | } |
- | 804 | if (COSD_FLAGS & COSD_FLAG_BIGVARIO) { |
|
- | 805 | draw_big_variometer(27, 8, naviData.Variometer); |
|
- | 806 | } |
|
Line 783... | Line 807... | ||
783 | 807 | ||
784 | // bottom line |
808 | // bottom line |
785 | write_ndigit_number_u_10th(2, bottom_line, naviData.UBat, 100, 0); |
809 | write_ndigit_number_u_10th(2, bottom_line, naviData.UBat, 100, 0); |
786 | if (naviData.UBat <= UBAT_WRN && last_UBat > UBAT_WRN) { |
810 | if (naviData.UBat <= UBAT_WRN && last_UBat > UBAT_WRN) { |