Final Project files for mBed development.

Dependencies:   m3pi mbed

control.c

Committer:
lsaristo
Date:
2014-11-13
Revision:
7:6e5cc24e1ce7
Parent:
6:00b7198f0b51

File content as of revision 7:6e5cc24e1ce7:

/**
 * @file    control.c
 * @brief   Motor control functions implemented from project.h
 * @author  John Wilkey
 */

#include "project.h"
extern m3pi pi;

int forward(float amt, float spd)
{
    if(amt > 1) { spd = 1; }
    pi.forward(spd);
    wait(amt);
    return EXIT_SUCCESS;
}

int backward(float amt, float spd)
{
    if(amt > 1) { spd = 1; }
    pi.backward(spd);
    wait(amt);
    return EXIT_SUCCESS;
}

int right(float deg)
{
    pi.right(TURN_SPEED);
    wait(deg/360);
    return EXIT_SUCCESS;
}

int left(float deg)
{
    pi.left(TURN_SPEED);
    wait(deg/360);
    return EXIT_SUCCESS;
}

void pretty_print(char* msg)
{
    pi.locate(0,1);
    pi.printf(msg);
}