Project

General

Profile

Revision 1596

Added by Alex Zirbel over 14 years ago

Added comments and minor changes to circle.c

View differences:

circle.c
191 191
	int distance=1000;						// how far away to stop.
192 192
	int onefoot=300, speed=200;				// one foot is 490 for bot 1; one foot is 200 for bot6
193 193
	
194
	while(1) {
195
		switch(state) {
194
	while(1)
195
	{
196
		switch(state)
197
		{
196 198
			case 0:			// EDGE
197 199
				
198 200
				orb_set_color(GREEN);
......
210 212
					}
211 213
				}
212 214
				
213
				while(1){
215
				while(1)		// wait for the center bot to count all the robots and send a "done" packet
216
				{
214 217
					orb_set_color(RED);
215 218
					packet_data=wl_basic_do_default(&data_length);
216 219
					wl_basic_send_global_packet(42,send_buffer,2);
217

  
220
					
218 221
					if(packet_data != 0 && data_length>=2 && packet_data[0]==CIRCLE_ACTION_DONE)
219 222
					{
220 223
						break;
......
248 251
				break;
249 252
				
250 253
				
254
				
255
				
251 256
			case 1:			// BEACON
252 257
				switch(beacon_State) {
253
				case 0:
258
				case 0:		// wait for a button to be pressed, then go to state 1
254 259
					bom_on();
255 260
					orb_set_color(PURPLE);
256 261
					if(button1_click()) beacon_State=1;
257 262
				break;	
258
				case 1:
263
				case 1:		// sends a global exist packet to see how many robots there are
259 264
					send_buffer[0]=CIRCLE_ACTION_EXIST;
260 265
					send_buffer[1]=get_robotid();
261 266
					wl_basic_send_global_packet(42,send_buffer,2);
262 267
					beacon_State=2;
263 268
				break;
264
				case 2: 
269
				case 2: 	// find out how many robots there are
265 270
				orb_set_color(ORANGE);
266 271
				packet_data=wl_basic_do_default(&data_length);
267 272
				if(packet_data!=0 && data_length>=2 && packet_data[0]==CIRCLE_ACTION_ACK)
268 273
				{
269 274
					orb_set_color(WHITE);
270
					if(used[packet_data[1]]==0){//only add to robots seen if you haven't gotten an ACK from this robot
275
					if(used[packet_data[1]]==0){		//only add to robots seen if you haven't gotten an ACK from this robot
271 276
						robotsRecieved++;
272 277
						used[packet_data[1]]=1;
273 278
					}

Also available in: Unified diff