EE149
/
FinalProject
Final Project files for mBed development.
Diff: control.c
- Revision:
- 10:94b068b2ce1d
- Child:
- 11:a30f30d3066e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/control.c Sat Nov 15 23:03:06 2014 +0000 @@ -0,0 +1,48 @@ +/** + * @file control.c + * @brief Implemention of robot control algorithms. + * + * This file should also contain the logic needed to parse + * any drawing file and issue motor commands through functions + * defined in main.h + * + * @author John Wilkey + */ +#include "control.h" +#include "main.h" +extern m3pi pi; +extern DigitalIn start_button; + +void get_ps_file(char* moves) +{ + char* contents; + FILE* fp = fopen(_CANVAS_FILE, "r"); + fseek(fp, 0L, SEEK_END); + int size = ftell(fp); + fseek(fp, 0L, SEEK_SET); + contents = (char*)malloc(size); + fread(contents, size, 1, fp); + fclose(fp); +} + +void robot_loop() +{ + start: + while(1) { + if(start_button) { + pi.stop(); + goto start; + } + + // + // Right now the robot controller is clearly a very basic + // 'hello world' loop that must be changed. + forward(10); + right(90); + forward(10); + right(90); + forward(10); + wait(2); + left(180); + } +} \ No newline at end of file