Project

General

Profile

Revision 1901

Updated main to work for the demo. It now switches states properly, but button1 seems to trigger accidentally sometimes (but strangely consistently at the same point in the program). Also edited the random turn generator to use the rtc instead of a rangefinder for the seed.

View differences:

main.c
31 31
	sign = 0;
32 32
	
33 33
	//Test code
34
	state = SHIGHWAY;
34
	state = SROAD;
35 35

  
36 36
	sendBuffer[1] = id;
37
/*
38
	doDrive(255);
37

  
38
	/*
39
	doDrive(200);
39 40
	turn(DOUBLE, ILEFT);
40
*/	
41
	*/
41 42
/*	while(1)
42 43
		doDrive(255);
43 44
	*/
......
50 51
			//other road behaviors
51 52
				//tailgating?
52 53
			//read barcode
53
			sign = doDrive(255);
54
			if((sign >= 0) || button1_click()){
54
			sign = doDrive(200);
55
			if(button1_click()){
55 56
				state = SINTERSECTION;
56 57
			}
57 58
			break;
......
84 85
			orb1_set_color(ORANGE);
85 86
			while(1){
86 87
				stop();
87
				sign = doDrive(255);
88
				sign = doDrive(200);
88 89
				if((sign >= 0) || button1_click()){
89 90
					start();
90 91
					if(0){
......
98 99
			}
99 100
			break;
100 101
		case SHIGHWAY:/*On highway*/
101
		//	while(!button1_click()){
102
			orb1_set_color(CYAN);
103
			while(!button1_click()){
102 104
				highwayFSM();
103
		//	}
104
			//state = SINTERSECTION;
105
			}
106
			state = SINTERSECTION;
105 107
			break;
106 108
		default:
107 109
			usb_puts("I got stuck in an unknown state! My state is ");
......
225 227
	//But here's the code to handle wireless while in the intersection...
226 228
	start();
227 229
	turn(getIntersectType(sign), turnDir);
228
	while(doDrive(255) != FINISHED){
230
	while(doDrive(200) != FINISHED){
229 231
		dataLength = 0;
230 232
		packet = NULL;
231 233
		packet = wl_basic_do_default(&dataLength);		
......
262 264
			*/
263 265
		}
264 266
	}
265
}
267
}

Also available in: Unified diff