EE149
/
FinalProject
Final Project files for mBed development.
control.c
- Committer:
- lsaristo
- Date:
- 2014-11-16
- Revision:
- 11:a30f30d3066e
- Parent:
- 10:94b068b2ce1d
- Child:
- 12:1aa6b8a74136
File content as of revision 11:a30f30d3066e:
/** * @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; extern DigitalOut oled_2; 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: pi.cls(); pi.locate(0,0); pi.printf("PiCO"); pi.locate(0,1); pi.printf("%f mV", pi.battery()); wait(.5); while(start_button) { oled_2 = 1; wait(.5); pi.locate(0,0); pi.printf("Ready"); oled_2 = 0; } pi.cls(); pi.locate(0,0); pi.printf("GO!"); wait(.5); 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); } }