Rev 1217 Rev 1220
Line 9... Line 9...
9   9  
10   10  
11 //************************************************************************ 11 //************************************************************************
12 // defines 12 // defines
13   13  
-   14 #define MY_LAT 48*60+57.7647
-   15 #define MY_LON 14*60+28.0836
-   16  
14 #define KEY_TIME_DEAD 5 //cca 50ms 8*5 17 #define KEY_TIME_DEAD 5 //cca 50ms 8*5
15 //#define KEY_TIME_START_REPEAT 100 //cca 1s 18 //#define KEY_TIME_START_REPEAT 100 //cca 1s
16 //#define KEY_TIME_REPEAT 20 //cca 240ms 19 //#define KEY_TIME_REPEAT 20 //cca 240ms
17 #define KEY_TIME_FIRST 50 20 #define KEY_TIME_FIRST 50
18   21  
19 #define TEMP_TIME_REPEAT 100 22 #define TEMP_TIME_REPEAT 100
20   23  
21 #define OFF_TIME 200 24 #define OFF_TIME 200
-   25 #define TIME_KEY_LONG 200
22   26  
23 #define REFRESH_TIME 100 27 #define REFRESH_TIME 100
24   28  
25 #define STATUS_REFRESH_TIME 100 29 #define STATUS_REFRESH_TIME 100
26   30  
Line 269... Line 273...
269 if (!TL2_INPUT && USB_INPUT) 273 if (!TL2_INPUT && USB_INPUT)
270 { 274 {
271 cli(); 275 cli();
272 buffer_clr(); 276 buffer_clr();
273 gotoxy(2,3); 277 gotoxy(2,3);
274 fprintf(&mystdout2,"programing"); 278 fprintf(&mystdout2,"update");
275 gotoxy(6,5); 279 gotoxy(2,5);
276 fprintf(&mystdout2,"mod"); 280 fprintf(&mystdout2,"firmware");
277 lcd_refresh(); 281 lcd_refresh();
278 delay_ms(1000); 282 delay_ms(1000);
279 BOOT(); 283 BOOT();
280 } 284 }
281 285
Line 310... Line 314...
310 volatile uint8_t timer_key; 314 volatile uint8_t timer_key;
311 volatile uint8_t timer_temp; 315 volatile uint8_t timer_temp;
312 volatile uint8_t timer_off; 316 volatile uint8_t timer_off;
313 volatile uint8_t timer_refresh; 317 volatile uint8_t timer_refresh;
314 volatile uint8_t timer_status; 318 volatile uint8_t timer_status;
-   319 volatile uint8_t timer_key_long;
315   320  
316 void timer1_tik(void) 321 void timer1_tik(void)
317 { 322 {
318 uint8_t key_temp; 323 uint8_t key_temp;
319 324
Line 321... Line 326...
321 { 326 {
322 timer1_ovf--; 327 timer1_ovf--;
323 if (timer_status) timer_status--; 328 if (timer_status) timer_status--;
324 if (timer_refresh) timer_refresh--; 329 if (timer_refresh) timer_refresh--;
325 if (timer_off) timer_off--; 330 if (timer_off) timer_off--;
-   331 if (timer_key_long) timer_key_long--;
326 if (timer_temp) timer_temp--; 332 if (timer_temp) timer_temp--;
327 if (timer_key) timer_key--; 333 if (timer_key) timer_key--;
328 else 334 else
329 { 335 {
330 key_temp = 0; 336 key_temp = 0;
331 if (!TL1_INPUT) key_temp = _BV(KEY1); 337 if (!TL1_INPUT) key_temp = _BV(KEY1);
332 if (!TL2_INPUT) key_temp |= _BV(KEY2); 338 if (!TL2_INPUT) key_temp |= _BV(KEY2);
333 if (!TL3_INPUT) key_temp |= _BV(KEY3); 339 if (!TL3_INPUT) key_temp |= _BV(KEY3);
-   340 //if (key_temp != key_press)
-   341 {
334 if (key_temp != key_press) 342 if (key_temp != key_press)
335 { 343 {
-   344 timer_off= OFF_TIME;
-   345 timer_key_long=TIME_KEY_LONG;
-   346 }
336 timer_key = KEY_TIME_DEAD; 347 timer_key = KEY_TIME_DEAD;
337 key_press = key_temp; 348 key_press = key_temp;
338 if (!key_flag) key_flag = key_press; 349 if (!key_flag) key_flag = key_press;
339 timer_off= OFF_TIME; 350
340 } 351 }
341 } 352 }
342 } 353 }
343 } 354 }
344   355  
Line 509... Line 520...
509 date.year=yRTC; 520 date.year=yRTC;
510 return date; 521 return date;
511 } 522 }
512   523  
513 //********************************************************************* 524 //*********************************************************************
-   525 // key
-   526  
-   527 uint8_t test_key(void)
-   528 {
-   529 static uint8_t key_next = 0;
-   530  
-   531 if (key_press)
-   532 {
-   533 if (key_next)
-   534 {
-   535 key_read();
-   536 return 0;
-   537 }
-   538  
-   539 if(!timer_key_long)
-   540 {
-   541 key_next = 1;
-   542 timer_key = KEY_TIME_FIRST;
-   543 switch(key_read())
-   544 {
-   545 case _BV(KEY1): return KEY1_LONG;
-   546 case _BV(KEY2): return KEY2_LONG;
-   547 case _BV(KEY3): return KEY3_LONG;
-   548 }
-   549 }
-   550 return 0;
-   551 }
-   552 key_next=0;
-   553 switch(key_read())
-   554 {
-   555 case _BV(KEY1): return KEY1_SHORT;
-   556 case _BV(KEY2): return KEY2_SHORT;
-   557 case _BV(KEY3): return KEY3_SHORT;
-   558 }
-   559 return 0;
-   560 }
-   561  
-   562 //*********************************************************************
514 //status 563 //status
515   564  
516 void status(void) 565 void status(void)
517 { 566 {
518 uint8_t a,b; 567 uint8_t a,b;
Line 561... Line 610...
561 // mod 610 // mod
562   611  
563 void displ_time(void) 612 void displ_time(void)
564 { 613 {
565 GPS_ON; 614 GPS_ON;
-   615
-   616 switch(test_key())
-   617 {
-   618 case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
-   619 case KEY2_LONG: id_mod=ID_OFF;return;
-   620 case KEY3_LONG: return;
-   621 case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
-   622 case KEY2_SHORT:
-   623 case KEY3_SHORT:break;
-   624 }
-   625  
566 if (!timer_refresh) 626 if (!timer_refresh)
567 { 627 {
568 timer_refresh = CLOCK1S; 628 timer_refresh = CLOCK1S;
569 buffer_clr(); 629 buffer_clr();
570 status(); 630 status();
Line 581... Line 641...
581 void displ_location(void) 641 void displ_location(void)
582 { 642 {
583 uint8_t a,b; 643 uint8_t a,b;
584 uint8_t *ptr; 644 uint8_t *ptr;
585   645  
-   646 switch(test_key())
-   647 {
-   648 case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
-   649 case KEY2_LONG: id_mod=ID_OFF;return;
-   650 case KEY3_LONG: return;
-   651 case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
-   652 case KEY2_SHORT:
-   653 case KEY3_SHORT:break;
-   654 }
-   655  
586 if (!timer_refresh) 656 if (!timer_refresh)
587 { 657 {
588 timer_refresh = CLOCK1S; 658 timer_refresh = CLOCK1S;
589 buffer_clr(); 659 buffer_clr();
590 status(); 660 status();
Line 607... Line 677...
607 } 677 }
608 } 678 }
609   679  
610 void displ_speed(void) 680 void displ_speed(void)
611 { 681 {
-   682 switch(test_key())
-   683 {
-   684 case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
-   685 case KEY2_LONG: id_mod=ID_OFF;return;
-   686 case KEY3_LONG: return;
-   687 case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
-   688 case KEY2_SHORT:
-   689 case KEY3_SHORT:break;
-   690 }
-   691  
612 if (!timer_refresh) 692 if (!timer_refresh)
613 { 693 {
614 timer_refresh = CLOCK1S; 694 timer_refresh = CLOCK1S;
615 buffer_clr(); 695 buffer_clr();
616 status(); 696 status();
Line 622... Line 702...
622 } 702 }
623 } 703 }
624   704  
625 void displ_course(void) 705 void displ_course(void)
626 { 706 {
-   707 switch(test_key())
-   708 {
-   709 case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
-   710 case KEY2_LONG: id_mod=ID_OFF;return;
-   711 case KEY3_LONG: return;
-   712 case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
-   713 case KEY2_SHORT:
-   714 case KEY3_SHORT:break;
-   715 }
-   716  
627 if (!timer_refresh) 717 if (!timer_refresh)
628 { 718 {
629 timer_refresh = CLOCK1S; 719 timer_refresh = CLOCK1S;
630 buffer_clr(); 720 buffer_clr();
631 status(); 721 status();
Line 646... Line 736...
646 uint8_t a,x,y,b; 736 uint8_t a,x,y,b;
647 static uint8_t d = 0; 737 static uint8_t d = 0;
648 static uint8_t c = 0; 738 static uint8_t c = 0;
649 double elevace,azimut; 739 double elevace,azimut;
650   740  
-   741 switch(test_key())
-   742 {
-   743 case KEY1_LONG:if (LED_INPUT) LED_OFF;else LED_ON;break;
-   744 case KEY2_LONG: c=0;id_mod=ID_OFF;return;
-   745 case KEY3_LONG: c=0;return;
-   746 case KEY1_SHORT:c=0;timer_refresh = 0;++id_mod;return;
-   747 case KEY2_SHORT:c=0;d++;timer_refresh = 0;break;
-   748 case KEY3_SHORT: break;
-   749 }
-   750  
651 if (!timer_refresh) 751 if (!timer_refresh)
652 { 752 {
653 timer_refresh = CLOCK1S; 753 timer_refresh = CLOCK1S;
654 if (c--) return; 754 if (c--) return;
655 c=3; 755 c=5;
656 buffer_clr(); 756 buffer_clr();
657 //status(); 757 //status();
658 #ifdef DEBUG 758 #ifdef DEBUG
659 if(gps.gsv_satelites_view > 12) 759 if(gps.gsv_satelites_view > 12)
660 { 760 {
661 printf("error view satelites"); 761 printf("error view satelites");
662 lcd_refresh(); 762 lcd_refresh();
663 c=20; 763 c=5;
664 return; 764 return;
665 } 765 }
666 #endif 766 #endif
667 if (++d >= gps.gsv_satelites_view) d = 0; 767 if (d >= gps.gsv_satelites_view) d = 0;
668 gotoxy(12,1); 768 gotoxy(12,1);
669 printf("%d",gps.gsv_satelites_view); 769 printf("%d",gps.gsv_satelites_view);
670 gotoxy(12,2); 770 gotoxy(12,2);
671 printf("%d",gps.satelit_detail[d].id); 771 printf("%d",gps.satelit_detail[d].id);
672 gotoxy(12,3); 772 gotoxy(12,3);
Line 711... Line 811...
711 } 811 }
712 } 812 }
713   813  
714 void displ_all_position() 814 void displ_all_position()
715 { 815 {
-   816
-   817 switch(test_key())
-   818 {
-   819 case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
-   820 case KEY2_LONG: id_mod=ID_OFF;return;
-   821 case KEY3_LONG: return;
-   822 case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
-   823 case KEY2_SHORT:
-   824 case KEY3_SHORT:break;
-   825 }
-   826  
716 if (!timer_refresh) 827 if (!timer_refresh)
717 { 828 {
718 timer_refresh = CLOCK1S; 829 timer_refresh = CLOCK1S;
719 buffer_clr(); 830 buffer_clr();
720 status(); 831 status();
Line 740... Line 851...
740 double course; 851 double course;
741 uint8_t x,y,xl,yl,xp,yp; 852 uint8_t x,y,xl,yl,xp,yp;
742 uint8_t a,b; 853 uint8_t a,b;
743 uint8_t *ptr; 854 uint8_t *ptr;
744   855  
-   856 switch(test_key())
-   857 {
-   858 case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
-   859 case KEY2_LONG: id_mod=ID_OFF;return;
-   860 case KEY3_LONG: return;
-   861 case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
-   862 case KEY2_SHORT:
-   863 case KEY3_SHORT:break;
-   864 }
-   865  
745 if (!timer_refresh) 866 if (!timer_refresh)
746 { 867 {
747 timer_refresh = CLOCK1S; 868 timer_refresh = CLOCK1S;
748 buffer_clr(); 869 buffer_clr();
749 status(); 870 status();
750 871
751 const float gc_lat=48*60+57.7647,gc_lon=14*60+28.0836; // DOMA 872 const float gc_lat= MY_LAT,gc_lon=MY_LON; // DOMA
752   873  
753 lon=(gc_lon-gps.longitude*60)*1214; 874 lon=(gc_lon-gps.longitude*60)*1214;
754 lat=(gc_lat-gps.latitude*60)*1854; 875 lat=(gc_lat-gps.latitude*60)*1854;
755 temp = sqrt((lon*lon) + (lat*lat)); 876 temp = sqrt((lon*lon) + (lat*lat));
756 877
Line 839... Line 960...
839   960  
840 void displ_service(char *buf) 961 void displ_service(char *buf)
841 { 962 {
842 uint8_t a; 963 uint8_t a;
843   964
-   965 switch(test_key())
-   966 {
-   967 case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
-   968 case KEY2_LONG: id_mod=ID_OFF;return;
-   969 case KEY3_LONG: return;
-   970 case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
-   971 case KEY2_SHORT:
-   972 case KEY3_SHORT:break;
-   973 }
-   974
844 if (!timer_refresh) 975 if (!timer_refresh)
845 { 976 {
846 timer_refresh = CLOCK1S; 977 timer_refresh = CLOCK1S;
847 buffer_clr(); 978 buffer_clr();
848 for (a = 0; a<80; a++) putchar(*(buf++)); 979 for (a = 0; a<80; a++) putchar(*(buf++));
Line 858... Line 989...
858 uint8_t xp,yp; 989 uint8_t xp,yp;
859 uint8_t xl,yl; 990 uint8_t xl,yl;
860 //uint8_t xs,ys; 991 //uint8_t xs,ys;
861 double course; 992 double course;
862   993  
-   994 switch(test_key())
-   995 {
-   996 case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
-   997 case KEY2_LONG: id_mod=ID_OFF;return;
-   998 case KEY3_LONG: return;
-   999 case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
-   1000 case KEY2_SHORT:
-   1001 case KEY3_SHORT:break;
-   1002 }
-   1003  
863 if (!timer_refresh) 1004 if (!timer_refresh)
864 { 1005 {
865 timer_refresh = CLOCK1S; 1006 timer_refresh = CLOCK1S;
866 buffer_clr(); 1007 buffer_clr();
867 status(); 1008 status();
Line 912... Line 1053...
912   1053  
913 void displ_all_service(void) 1054 void displ_all_service(void)
914 { 1055 {
915 uint8_t a; 1056 uint8_t a;
916   1057  
-   1058 switch(test_key())
-   1059 {
-   1060 case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
-   1061 case KEY2_LONG: id_mod=ID_OFF;return;
-   1062 case KEY3_LONG: return;
-   1063 case KEY1_SHORT:timer_refresh = 0;++id_mod;return;
-   1064 case KEY2_SHORT:
-   1065 case KEY3_SHORT:break;
-   1066 }
-   1067  
917 if (!timer_refresh) 1068 if (!timer_refresh)
918 { 1069 {
919 timer_refresh = CLOCK1S; 1070 timer_refresh = CLOCK1S;
920 buffer_clr(); 1071 buffer_clr();
921 status(); 1072 status();
Line 947... Line 1098...
947 } 1098 }
948 lcd_refresh(); 1099 lcd_refresh();
949 } 1100 }
950 } 1101 }
951   1102  
952 void displ_temp() 1103 void temp(void)
953 { -  
954 //GPS_OFF; -  
955 //ADC_OFF; -  
956 //REF_OFF; -  
957   -  
958 if(!timer_temp) -  
959 { 1104 {
960 timer_temp = TEMP_TIME_REPEAT; 1105 timer_temp = TEMP_TIME_REPEAT;
961 now.temperature=read_temp(); 1106 now.temperature=read_temp();
962 now.time=actual_time(); 1107 now.time=actual_time();
963 now.date=actual_date(); 1108 now.date=actual_date();
Line 996... Line 1141...
996 offset_text-= 2; 1141 offset_text-= 2;
997 print_time(min.time); 1142 print_time(min.time);
998 lcd_refresh(); 1143 lcd_refresh();
999 start_MCP9800(); 1144 start_MCP9800();
1000 } 1145 }
-   1146  
-   1147 void displ_temp()
-   1148 {
-   1149 //GPS_OFF;
-   1150 //ADC_OFF;
-   1151 //REF_OFF;
-   1152  
-   1153 switch(test_key())
-   1154 {
-   1155 case KEY1_LONG: timer_refresh = 0;if (LED_INPUT) LED_OFF;else LED_ON;break;
-   1156 case KEY2_LONG: id_mod=ID_OFF;return;
-   1157 case KEY3_LONG: return;
-   1158 case KEY1_SHORT:timer_refresh = 0;id_mod++;return;
-   1159 case KEY2_SHORT:timer_temp = 0; max.temperature=0x8000;min.temperature=0x7FFF;
-   1160 if (GPS_INPUT && (gps.status == 'A'))
-   1161 {
-   1162 sRTC=gps.second;
-   1163 mRTC=gps.minute;
-   1164 hRTC=gps.hour+2;
-   1165  
-   1166 dRTC=gps.day;
-   1167 mdRTC=gps.month;
-   1168 yRTC=gps.year;
-   1169 }break;
-   1170 case KEY3_SHORT: break;
-   1171 }
-   1172  
-   1173 if(!timer_temp)
-   1174 {
-   1175 temp();
-   1176 }
1001 } 1177 }
1002   1178  
-   1179  
1003 void displ_start(void) 1180 void displ_start(void)
1004 { 1181 {
1005 buffer_clr(); 1182 buffer_clr();
1006 gotoxy(6,3); 1183 gotoxy(6,3);
1007 fprintf(&mystdout2,"GPS"); 1184 fprintf(&mystdout2,"GPS");
1008 lcd_refresh(); 1185 lcd_refresh();
1009 delay_ms(1000); 1186 delay_ms(1000);
1010 id_mod = ID_TEMP; 1187 id_mod = ID_TEMP;
1011   -  
1012 } 1188 }
1013   1189  
1014 void all_off(void) 1190 void all_off(void)
1015 { 1191 {
-   1192 uint8_t temp_wiev;
-   1193  
1016 buffer_clr(); 1194 buffer_clr();
1017 gotoxy(6,3); 1195 gotoxy(6,3);
1018 fprintf(&mystdout2,"OFF"); 1196 fprintf(&mystdout2,"OFF");
1019 lcd_refresh(); 1197 lcd_refresh();
1020 GPS_OFF; 1198 GPS_OFF;
1021 REF_OFF; 1199 REF_OFF;
-   1200 ADC_OFF;
1022 delay_ms(1000); 1201 delay_ms(1000);
1023 LED_OFF; 1202 LED_OFF;
1024 N5110_send_command(POWER_DOWN); 1203 N5110_send_command(POWER_DOWN);
1025 1204
-   1205 temp_wiev = 0;
1026 while (TL2_INPUT) 1206 while (TL2_INPUT)
1027 { 1207 {
1028 sleep_cpu(); 1208 sleep_cpu();
-   1209 if (!TL1_INPUT)
-   1210 {
-   1211 if (!temp_wiev) N5110_send_command(ACTIVE_CHIP);
-   1212 temp_wiev = 1;
-   1213 timer1_ovf = 0;
-   1214 while ((!TL1_INPUT) && (timer1_ovf<200));
-   1215 if (timer1_ovf==200)
-   1216 {
-   1217 max.temperature=0x8000;
-   1218 min.temperature=0x7FFF;
-   1219 }
-   1220 }
-   1221 if (!TL3_INPUT) {N5110_send_command(POWER_DOWN);temp_wiev = 0;}
-   1222 if (temp_wiev) temp();
1029   1223  
1030 } 1224 }
1031 null_variables(); 1225 null_variables();
1032 LCD_N5110_INIT(); 1226 LCD_N5110_INIT();
1033 displ_start(); 1227 displ_start();
Line 1164... Line 1358...
1164 case RETURN_VTG: nmea_vtg(scan_buf,pgps);break; 1358 case RETURN_VTG: nmea_vtg(scan_buf,pgps);break;
1165 } 1359 }
1166   1360  
1167 timer1_tik(); 1361 timer1_tik();
1168   1362  
1169 id_mod = key(id_mod); 1363 //id_mod = key(id_mod);
1170   1364  
1171 } 1365 }
1172 return 0; 1366 return 0;
1173 } 1367 }
1174   1368