Line 49... |
Line 49... |
49 |
delay_us(800); |
49 |
delay_us(800); |
50 |
period--; |
50 |
period--; |
51 |
} |
51 |
} |
52 |
} |
52 |
} |
53 |
|
53 |
|
54 |
void test_mode() //Testovaci mod stopek |
- |
|
55 |
{ |
- |
|
56 |
printf(lcd_putc,"\f TEST MODE"); |
- |
|
57 |
lcd_gotoxy(1,2); |
- |
|
58 |
printf(lcd_putc,"ESC"); |
- |
|
59 |
while(input(BUTTON1)) // testuje dokud nekdo nezmackne tlacitlo |
- |
|
60 |
{ |
- |
|
61 |
lcd_gotoxy(5,2); |
- |
|
62 |
delay_ms(100); |
- |
|
63 |
printf(lcd_putc,"%x ",input_b()); |
- |
|
64 |
} |
- |
|
65 |
} |
- |
|
66 |
void send_measuring() |
- |
|
67 |
{ |
- |
|
68 |
printf(usb_cdc_putc, "\n\r %5lu %5lu %5lu %5lu %5lu", run, section[0], section[1], section[2], section[3]); |
- |
|
69 |
} //*0.000010667 |
- |
|
70 |
|
- |
|
71 |
void main() |
54 |
void main() |
72 |
{ |
55 |
{ |
73 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
56 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
74 |
port_b_pullups(TRUE); |
57 |
port_b_pullups(TRUE); |
75 |
setup_adc(ADC_OFF); |
58 |
setup_adc(ADC_OFF); |
Line 91... |
Line 74... |
91 |
lcd_gotoxy(1,1); |
74 |
lcd_gotoxy(1,1); |
92 |
printf(lcd_putc,"\f STOPWATCH01A"); |
75 |
printf(lcd_putc,"\f STOPWATCH01A"); |
93 |
lcd_gotoxy(1,2); |
76 |
lcd_gotoxy(1,2); |
94 |
printf(lcd_putc," Kaklik 2010"); |
77 |
printf(lcd_putc," Kaklik 2010"); |
95 |
delay_ms(1000); |
78 |
delay_ms(1000); |
96 |
lcd_gotoxy(1,1); |
- |
|
97 |
printf(lcd_putc,"\f Waiting for PC... "); |
- |
|
98 |
lcd_gotoxy(1,2); |
- |
|
99 |
printf(lcd_putc,"TEST"); |
- |
|
100 |
|
79 |
|
101 |
while(!usb_cdc_connected()) if(!input(BUTTON1)) test_mode(); // pockej nez se pripoji seriovy port PC |
80 |
while (TRUE) |
- |
|
81 |
{ |
102 |
|
82 |
|
- |
|
83 |
printf(lcd_putc,"\fWaiting for PC... "); |
103 |
lcd_gotoxy(1,1); |
84 |
lcd_gotoxy(1,2); |
- |
|
85 |
printf(lcd_putc,"sensors:"); |
- |
|
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 |
} |
104 |
printf(lcd_putc,"\f PC connected..."); |
92 |
printf(lcd_putc,"\f PC connected..."); |
105 |
beep(10); |
93 |
beep(10); |
106 |
|
94 |
|
107 |
run=0; |
95 |
run=0; |
108 |
section[0] = 0; |
96 |
section[0] = 0; |
109 |
section[1] = 0; |
97 |
section[1] = 0; |
110 |
section[2] = 0; |
98 |
section[2] = 0; |
111 |
section[3] = 0; |
99 |
section[3] = 0; |
112 |
|
100 |
|
113 |
while (TRUE) |
101 |
while(usb_cdc_connected()) // pockej nez se pripoji seriovy port PC |
114 |
{ |
102 |
{ |
115 |
run++; |
103 |
run++; |
116 |
printf(lcd_putc,"\f\nSTART"); |
104 |
printf(lcd_putc,"\f\nSTART"); |
117 |
|
105 |
|
118 |
while(input(BUTTON1)); // ceka na zmacknuti startovaciho tlacitka |
106 |
while(input(BUTTON1)); // ceka na zmacknuti startovaciho tlacitka |
Line 121... |
Line 109... |
121 |
while((!input(START1)) && (input(BUTTON2))); // cekame na tlacitko stop nebo na preruseni paprsku |
109 |
while((!input(START1)) && (input(BUTTON2))); // cekame na tlacitko stop nebo na preruseni paprsku |
122 |
time = 0; |
110 |
time = 0; |
123 |
set_timer0(0); |
111 |
set_timer0(0); |
124 |
while((input(STOP1)) && (input(BUTTON2))) |
112 |
while((input(STOP1)) && (input(BUTTON2))) |
125 |
section[0] = (time << 16) + get_timer0(); |
113 |
section[0] = (time << 16) + get_timer0(); |
- |
|
114 |
// 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]); |
126 |
|
116 |
} |
127 |
send_measuring(); |
- |
|
128 |
} |
117 |
} |
129 |
} |
118 |
} |