Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
2 kaklik 1
#define  DOLEVA   0
2
#define  DOPRAVA  1
3
 
4
void cikcak()
5
{
6
unsigned int8 i;
7
 
8
   uhel=KOLMO1;
9
   Delay_ms(100);
10
   if (line==L2) line=L3;
11
   if (line==S) line=L3;
12
   if (line==R2) line=R3;
13
 
14
   Delay_ms(3);
15
 
16
   output_low(STROBE);              // vypni zobrazovani na posuvnem registru   
17
   sensors = spi_read(0);           // cteni senzoru
18
   sensors=~sensors;
19
   output_high(STROBE);             // vypni zobrazovani na posuvnem registru
20
 
21
   while(!bit_test(sensors,3))
22
   {
23
      while(true)
24
      {
25
         Delay_ms(3);
26
 
27
         if (line==L3)
28
         {
29
            GO(L,B,160);GO(R,F,160);
30
         };
31
         if (line==R3)
32
         {
33
            GO(R,B,160);GO(L,F,160);   
34
         };
35
         if (line==S) {STOPL;STOPR; i++;}
36
         else i=0;
37
 
38
         if (i>=100) break;
39
 
40
         output_low(STROBE);              // vypni zobrazovani na posuvnem registru   
41
         sensors = spi_read(0);         // cteni senzoru
42
         sensors=~sensors;
43
         output_high(STROBE);              // vypni zobrazovani na posuvnem registru
44
 
45
         if(bit_test(sensors,3)) //...|...//
46
         {
47
            line=S;
48
            continue;
49
         }
50
 
51
         if(bit_test(sensors,0)) //|......//     // z duvodu zkraceni doby reakce se cidla nevyhodnocuji poporade ale od krajnich k prostrednimu
52
         {
53
            line=L3;
54
            continue;
55
         }
56
 
57
         if(bit_test(sensors,6)) //......|//
58
         {
59
            line=R3;
60
            continue;
61
         }
62
 
63
         if(bit_test(sensors,1)) //.|.....//
64
         {
65
            line=L3;
66
            continue;
67
         }
68
 
69
         if(bit_test(sensors,5)) //.....|.//
70
         {
71
            line=R3;
72
            continue;
73
         }
74
 
75
         if (bit_test(sensors,2)) //..|....//
76
         {
77
            line=L3;
78
            continue;
79
         }
80
 
81
         if (bit_test(sensors,4)) //....|..//
82
         {
83
            line=R3;
84
            continue;
85
         }
86
      }
87
      delay_ms(100);
88
 
89
      output_low(STROBE);              // vypni zobrazovani na posuvnem registru   
90
      sensors = spi_read(0);         // cteni senzoru
91
      sensors=~sensors;
92
      output_high(STROBE);              // vypni zobrazovani na posuvnem registru
93
   }   
94
}
95
 
96
/*
97
void cikcak()
98
{
99
short int movement;
100
unsigned int8 n,i=0;
101
 
102
   if(uhel>=STRED)
103
   {
104
      uhel=KOLMO1;
105
      Delay_ms(100);
106
   }
107
 
108
   if(uhel<=STRED)
109
   {
110
      uhel=KOLMO2;
111
      Delay_ms(100);
112
   }
113
 
114
 
115
   sensors = spi_read(0);         // cteni senzoru
116
   sensors=~sensors;
117
   Delay_ms(5);
118
 
119
if ((sensors & 0b11100000)!=0) movement=DOPRAVA;
120
 
121
   while(i<=100)
122
   {
123
      while(!bit_test(sensors,3))
124
      {
125
         if(DOPRAVA == movement)
126
         {
127
            FR;BL;
128
            movement=DOLEVA;
129
            n=0;
130
//if ((sensors & 0b11100000)!=0) line=L1;
131
//if ((sensors & 0b00001110)!=0) line=R1;
132
//if ((sensors & 0b00010000)!=0) line=S;
133
 
134
            for(n=0; n<=100; n++)
135
            {
136
               sensors = spi_read(0);         // cteni senzoru
137
               sensors=~sensors;
138
               Delay_ms(5);                     // cekani na SLAVE nez pripravi data od cidel
139
               if(bit_test(sensors,3)) break;
140
               else i=0;
141
            }
142
            STOPL;STOPR;
143
         }
144
 
145
         if(DOLEVA == movement)
146
         {
147
            FL;BR;
148
            movement=DOPRAVA;
149
            n=0;
150
 
151
            for(n=0; n<=100; n++)
152
            {
153
               sensors = spi_read(0);
154
               sensors =~ sensors;
155
               Delay_ms(5);
156
               if(bit_test(sensors,3)) break;
157
               else i=0;
158
            }
159
            STOPL;STOPR;
160
         }
161
         sensors = spi_read(0);         // cteni senzoru
162
         sensors=~sensors;
163
         Delay_ms(5);
164
      }
165
      i++;
166
   }
167
}
168
*/
169
////////////////////////////////////////////////////////////////////////////////
170
void objizdka()
171
{
172
   BL;FR;
173
   Delay_ms(300);
174
   FL;BR;
175
   Delay_ms(100);
176
   STOPL;STOPR;
177
 
178
   uhel=STRED;
179
   FL;FR;
180
   Delay_ms(400);       // rovne
181
 
182
   uhel=STRED+55;
183
   STOPR;FL;
184
   Delay_ms(190);       // doprava
185
 
186
   uhel=STRED;
187
   FR;FL;
188
   Delay_ms(400);       // rovne
189
 
190
   uhel=STRED+55;
191
   FL;STOPR;
192
   Delay_ms(250);       // doprava
193
 
194
   uhel=STRED;
195
   FR;FL;
196
   Delay_ms(150);       // rovne
197
 
198
   While((sensors & 0b11111110)!=0) //dokud neni cara
199
   {
200
       sensors = spi_read(0);         // cteni senzoru
201
       sensors=~sensors;
202
       Delay_ms(4);              // cekani na SLAVE nez pripravi data od cidel
203
   }
204
   BL;BR;
205
   Delay_ms(400);
206
 
207
   uhel=STRED-55;
208
   FR;STOPL;         // doleva
209
   delay_ms(250);
210
 
211
   line=L3;
212
   cikcak();
213
}
214