Go to most recent revision | Blame | Last modification | View Log | Download
#define DOLEVA 0
#define DOPRAVA 1
void cikcak()
{
unsigned int8 i;
uhel=KOLMO1;
Delay_ms(100);
if (line==L2) line=L3;
if (line==S) line=L3;
if (line==R2) line=R3;
Delay_ms(3);
output_low(STROBE); // vypni zobrazovani na posuvnem registru
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
output_high(STROBE); // vypni zobrazovani na posuvnem registru
while(!bit_test(sensors,3))
{
while(true)
{
Delay_ms(3);
if (line==L3)
{
GO(L,B,160);GO(R,F,160);
};
if (line==R3)
{
GO(R,B,160);GO(L,F,160);
};
if (line==S) {STOPL;STOPR; i++;}
else i=0;
if (i>=100) break;
output_low(STROBE); // vypni zobrazovani na posuvnem registru
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
output_high(STROBE); // vypni zobrazovani na posuvnem registru
if(bit_test(sensors,3)) //...|...//
{
line=S;
continue;
}
if(bit_test(sensors,0)) //|......// // z duvodu zkraceni doby reakce se cidla nevyhodnocuji poporade ale od krajnich k prostrednimu
{
line=L3;
continue;
}
if(bit_test(sensors,6)) //......|//
{
line=R3;
continue;
}
if(bit_test(sensors,1)) //.|.....//
{
line=L3;
continue;
}
if(bit_test(sensors,5)) //.....|.//
{
line=R3;
continue;
}
if (bit_test(sensors,2)) //..|....//
{
line=L3;
continue;
}
if (bit_test(sensors,4)) //....|..//
{
line=R3;
continue;
}
}
delay_ms(100);
output_low(STROBE); // vypni zobrazovani na posuvnem registru
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
output_high(STROBE); // vypni zobrazovani na posuvnem registru
}
}
/*
void cikcak()
{
short int movement;
unsigned int8 n,i=0;
if(uhel>=STRED)
{
uhel=KOLMO1;
Delay_ms(100);
}
if(uhel<=STRED)
{
uhel=KOLMO2;
Delay_ms(100);
}
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
Delay_ms(5);
if ((sensors & 0b11100000)!=0) movement=DOPRAVA;
while(i<=100)
{
while(!bit_test(sensors,3))
{
if(DOPRAVA == movement)
{
FR;BL;
movement=DOLEVA;
n=0;
//if ((sensors & 0b11100000)!=0) line=L1;
//if ((sensors & 0b00001110)!=0) line=R1;
//if ((sensors & 0b00010000)!=0) line=S;
for(n=0; n<=100; n++)
{
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
Delay_ms(5); // cekani na SLAVE nez pripravi data od cidel
if(bit_test(sensors,3)) break;
else i=0;
}
STOPL;STOPR;
}
if(DOLEVA == movement)
{
FL;BR;
movement=DOPRAVA;
n=0;
for(n=0; n<=100; n++)
{
sensors = spi_read(0);
sensors =~ sensors;
Delay_ms(5);
if(bit_test(sensors,3)) break;
else i=0;
}
STOPL;STOPR;
}
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
Delay_ms(5);
}
i++;
}
}
*/
////////////////////////////////////////////////////////////////////////////////
void objizdka()
{
BL;FR;
Delay_ms(300);
FL;BR;
Delay_ms(100);
STOPL;STOPR;
uhel=STRED;
FL;FR;
Delay_ms(500); // rovne
uhel=STRED+55;
STOPR;FL;
Delay_ms(190); // doprava
uhel=STRED;
FR;FL;
Delay_ms(500); // rovne
uhel=STRED+55;
FL;STOPR;
Delay_ms(200); // doprava
uhel=STRED;
FR;FL;
Delay_ms(150); // rovne
While((sensors & 0b11111110)!=0) //dokud neni cara
{
sensors = spi_read(0); // cteni senzoru
sensors=~sensors;
Delay_ms(4); // cekani na SLAVE nez pripravi data od cidel
}
BL;BR;
Delay_ms(400);
uhel=STRED-55;
FR;STOPL; // doleva
delay_ms(250);
line=L3;
cikcak();
}