EE149
/
FinalProject
Final Project files for mBed development.
Diff: main.c
- Revision:
- 27:44a4a0abc8ee
- Parent:
- 26:a74edc4c6acb
- Child:
- 28:9976a94efa83
--- a/main.c Mon Dec 08 04:27:33 2014 +0000 +++ b/main.c Mon Dec 08 05:00:23 2014 +0000 @@ -180,6 +180,9 @@ while (1) { memset(instbuf+offset, 0, instbuflen-offset); bytes_read = fread(instbuf+offset, sizeof(char), instbuflen-1-offset, ps_file); + if (instbuf[0] == '\0') { + break; + } cur = instbuf; err = retrieve_inst(instbuf, &x, &y, &draw); if (err == 0) { @@ -194,6 +197,9 @@ /* Compute turn angle and turn. */ theta = atan(((double) delta_y)/((double) delta_x)); theta *= 57.29; + if (delta_x < 0 && delta_y > 0) { + theta += 180; + } delta_a = theta-angle; if (delta_x < 0 && delta_y < 0) { delta_a += 180; @@ -239,6 +245,7 @@ pi.cls(); pi.locate(0,0); pi.printf("done"); + while (1); return 0; }