Rev 1448 Rev 1450
Line 1... Line 1...
1 #include "main.h" 1 #include "main.h"
2   2  
-   3 #define REV "$Revision$"
-   4  
3 unsigned int32 section[4]; 5 unsigned int32 section[4];
4 unsigned int32 time; // pocitadlo preteceni casovace 6 unsigned int32 time; // pocitadlo preteceni casovace
5   7  
6 #Define INORDER 1 8 #Define INORDER 1
7   9  
Line 72... Line 74...
72 usb_init(); 74 usb_init();
73   75  
74 lcd_gotoxy(1,1); 76 lcd_gotoxy(1,1);
75 printf(lcd_putc,"\f STOPWATCH01A"); 77 printf(lcd_putc,"\f STOPWATCH01A");
76 lcd_gotoxy(1,2); 78 lcd_gotoxy(1,2);
77 printf(lcd_putc," Kaklik 2010"); 79 printf(lcd_putc," Kaklik 2010");
78 delay_ms(1000); 80 delay_ms(1000);
79   81  
80 while (TRUE) 82 while (TRUE)
81 { 83 {
82   84  
83 printf(lcd_putc,"\fWaiting for PC... "); 85 printf(lcd_putc,"\fWaiting for PC... ");
84 lcd_gotoxy(1,2); -  
85 printf(lcd_putc,"sensors:"); -  
86 while(!usb_cdc_connected()) // pockej nez se pripoji seriovy port PC 86 while(!usb_cdc_connected()); // pockej nez se pripoji seriovy port PC
87 { -  
88 lcd_gotoxy(10,2); -  
89 printf(lcd_putc," %x",input_b()); -  
90 delay_ms(100); -  
91 } -  
92 printf(lcd_putc,"\f PC connected..."); 87 printf(lcd_putc,"\f PC connected...");
93 beep(10); 88 beep(10);
94 89
95 run=0; 90 run=0;
96 section[0] = 0; -  
97 section[1] = 0; -  
98 section[2] = 0; -  
99 section[3] = 0; -  
100   91  
101 while(usb_cdc_connected()) // pockej nez se pripoji seriovy port PC 92 while(usb_cdc_connected()) // pockej nez se pripoji seriovy port PC
102 { 93 {
103 run++; 94 run++;
-   95 section[0] = 0;
-   96 section[1] = 0;
-   97 section[2] = 0;
-   98 section[3] = 0;
-   99
104 printf(lcd_putc,"\f\nSTART"); 100 printf(lcd_putc,"\f\nSTART ESC TEST");
105 101
106 while(input(BUTTON1)); // ceka na zmacknuti startovaciho tlacitka 102 while(input(BUTTON1)) // ceka na zmacknuti startovaciho tlacitka
-   103 if(!input(BUTTON4))
-   104 {
-   105 while(input(BUTTON3))
-   106 {
-   107 lcd_gotoxy(1,1);
-   108 printf(lcd_putc,"%1u %1u %1u %1u %1u %1u %1u %1u",input(START1),input(STOP1),input(START2), input(STOP2),input(START3),input(STOP3),input(START4),input(STOP4));
-   109 delay_ms(100);
-   110 }
-   111 }
107 printf(lcd_putc,"\f\n STOP"); // 112 printf(lcd_putc,"\f\n STOP"); //
108   113  
-   114 // mereni casu ve ctyrech usecich
109 while((!input(START1)) && (input(BUTTON2))); // cekame na tlacitko stop nebo na preruseni paprsku 115 while((!input(START1)) && (input(BUTTON2))); // cekame na tlacitko stop nebo na preruseni paprsku
110 time = 0; 116 time = 0;
111 set_timer0(0); 117 set_timer0(0);
112 while((input(STOP1)) && (input(BUTTON2))) 118 while((!input(STOP1)) && (input(BUTTON2)))
113 section[0] = (time << 16) + get_timer0(); 119 section[0] = (time << 16) + get_timer0();
-   120  
-   121 while((!input(START2)) && (input(BUTTON2))); // cekame na tlacitko stop nebo na preruseni paprsku
-   122 time = 0;
-   123 set_timer0(0);
-   124 while((!input(STOP2)) && (input(BUTTON2)))
-   125 section[1] = (time << 16) + get_timer0();
-   126  
-   127 while((!input(START3)) && (input(BUTTON2))); // cekame na tlacitko stop nebo na preruseni paprsku
-   128 time = 0;
-   129 set_timer0(0);
-   130 while((!input(STOP3)) && (input(BUTTON2)))
-   131 section[2] = (time << 16) + get_timer0();
-   132  
-   133 while((!input(START4)) && (input(BUTTON2))); // cekame na tlacitko stop nebo na preruseni paprsku
-   134 time = 0;
-   135 set_timer0(0);
-   136 while((!input(STOP4)) && (input(BUTTON2)))
-   137 section[3] = (time << 16) + get_timer0();
-   138  
114 // odesli namerene hodnoty 139 // odesli namerene hodnoty
115 printf(usb_cdc_putc, "\n\r %5lu %5.0f %5lu %5lu %5lu", run, section[0]/15.625, section[1], section[2], section[3]); 140 printf(usb_cdc_putc, "\n\r %7lu %7.0f %7.0f %7.0f %7.0f", run, section[0]/15.625, section[1]/15.625, section[2]/15.625, section[3]/15.625);
116 } 141 }
117 } 142 }
118 } 143 }