/Designs/STOPWATCH02A/SW/main.c
1,5 → 1,7
#include "main.h"
 
#define REV "$Revision$"
 
unsigned int32 section[4];
unsigned int32 time; // pocitadlo preteceni casovace
 
74,7 → 76,7
lcd_gotoxy(1,1);
printf(lcd_putc,"\f STOPWATCH01A");
lcd_gotoxy(1,2);
printf(lcd_putc," Kaklik 2010");
printf(lcd_putc," Kaklik 2010");
delay_ms(1000);
 
while (TRUE)
81,38 → 83,61
{
 
printf(lcd_putc,"\fWaiting for PC... ");
lcd_gotoxy(1,2);
printf(lcd_putc,"sensors:");
while(!usb_cdc_connected()) // pockej nez se pripoji seriovy port PC
{
lcd_gotoxy(10,2);
printf(lcd_putc," %x",input_b());
delay_ms(100);
}
while(!usb_cdc_connected()); // pockej nez se pripoji seriovy port PC
printf(lcd_putc,"\f PC connected...");
beep(10);
run=0;
section[0] = 0;
section[1] = 0;
section[2] = 0;
section[3] = 0;
 
while(usb_cdc_connected()) // pockej nez se pripoji seriovy port PC
{
run++;
printf(lcd_putc,"\f\nSTART");
run++;
section[0] = 0;
section[1] = 0;
section[2] = 0;
section[3] = 0;
printf(lcd_putc,"\f\nSTART ESC TEST");
while(input(BUTTON1)); // ceka na zmacknuti startovaciho tlacitka
while(input(BUTTON1)) // ceka na zmacknuti startovaciho tlacitka
if(!input(BUTTON4))
{
while(input(BUTTON3))
{
lcd_gotoxy(1,1);
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));
delay_ms(100);
}
}
printf(lcd_putc,"\f\n STOP"); //
 
// mereni casu ve ctyrech usecich
while((!input(START1)) && (input(BUTTON2))); // cekame na tlacitko stop nebo na preruseni paprsku
time = 0;
set_timer0(0);
while((input(STOP1)) && (input(BUTTON2)))
while((!input(STOP1)) && (input(BUTTON2)))
section[0] = (time << 16) + get_timer0();
 
while((!input(START2)) && (input(BUTTON2))); // cekame na tlacitko stop nebo na preruseni paprsku
time = 0;
set_timer0(0);
while((!input(STOP2)) && (input(BUTTON2)))
section[1] = (time << 16) + get_timer0();
 
while((!input(START3)) && (input(BUTTON2))); // cekame na tlacitko stop nebo na preruseni paprsku
time = 0;
set_timer0(0);
while((!input(STOP3)) && (input(BUTTON2)))
section[2] = (time << 16) + get_timer0();
 
while((!input(START4)) && (input(BUTTON2))); // cekame na tlacitko stop nebo na preruseni paprsku
time = 0;
set_timer0(0);
while((!input(STOP4)) && (input(BUTTON2)))
section[3] = (time << 16) + get_timer0();
 
// odesli namerene hodnoty
printf(usb_cdc_putc, "\n\r %5lu %5.0f %5lu %5lu %5lu", run, section[0]/15.625, section[1], section[2], section[3]);
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);
}
}
}