Final Project files for mBed development.

Dependencies:   m3pi mbed

control.c

Committer:
lsaristo
Date:
2014-11-15
Revision:
10:94b068b2ce1d
Child:
11:a30f30d3066e

File content as of revision 10:94b068b2ce1d:

/**
 * @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);
    }
}