Final Project files for mBed development.

Dependencies:   m3pi mbed

Committer:
lsaristo
Date:
Mon Dec 08 22:43:09 2014 +0000
Revision:
29:459ff10d2a07
Parent:
22:46b9d9b2e35c
Child:
31:1e950ee04481
Small cleanup and removed unused functions

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lsaristo 8:12d780f7443e 1 /**
lsaristo 10:94b068b2ce1d 2 * @file main.h
lsaristo 8:12d780f7443e 3 * @brief Main header file for includes and whatnot
lsaristo 8:12d780f7443e 4 * for the other project files.
lsaristo 8:12d780f7443e 5 * @author John Wilkey
lsaristo 29:459ff10d2a07 6 * @author Alec Guertin
lsaristo 29:459ff10d2a07 7 * @author Chester Chu
lsaristo 8:12d780f7443e 8 */
lsaristo 8:12d780f7443e 9
lsaristo 10:94b068b2ce1d 10 #ifndef _MAIN_H
lsaristo 10:94b068b2ce1d 11 #define _MAIN_H
lsaristo 8:12d780f7443e 12
lsaristo 8:12d780f7443e 13 #include "mbed.h"
lsaristo 8:12d780f7443e 14 #include "m3pi.h"
lsaristo 9:3a0433c391cb 15 #include <string.h>
lsaristo 9:3a0433c391cb 16 #include <stdarg.h>
lsaristo 9:3a0433c391cb 17 #include <stdio.h>
lsaristo 21:0c80a5d89ea3 18 #include <math.h>
lsaristo 21:0c80a5d89ea3 19 #define TURN_SPEED 0.15
lsaristo 21:0c80a5d89ea3 20 #define DRIVE_SPEED 0.2
lsaristo 8:12d780f7443e 21 #define ERR_SUCCESS 0
lsaristo 8:12d780f7443e 22 #define ERR_FAILURE 1
lsaristo 9:3a0433c391cb 23 #define DRIVE_RATE 1/50
lsaristo 21:0c80a5d89ea3 24 #define TIME_FACT 1820
lsaristo 21:0c80a5d89ea3 25 #define CAL_SPEED .1
alecguertin 22:46b9d9b2e35c 26 #define CLOSE_ENOUGH .0008
lsaristo 8:12d780f7443e 27
alecguertin 18:eab7b0e89398 28
lsaristo 29:459ff10d2a07 29 /** @brief Move the robot from its current position to (x,y) */
alecguertin 18:eab7b0e89398 30 void move(int x, int y, int draw);
alecguertin 18:eab7b0e89398 31
lsaristo 8:12d780f7443e 32 /**
alecguertin 17:c72c092fcdf7 33 * @brief get values of next PostScript instruction.
alecguertin 17:c72c092fcdf7 34 *
alecguertin 17:c72c092fcdf7 35 * @param buf Buffer with PS instructions.
alecguertin 17:c72c092fcdf7 36 * @param x Pointer to storage for x coordinate.
alecguertin 17:c72c092fcdf7 37 * @param y Pointer to storage for y coordinate.
alecguertin 17:c72c092fcdf7 38 * @param draw Pointer to storage for draw/move boolean.
alecguertin 17:c72c092fcdf7 39 *
alecguertin 17:c72c092fcdf7 40 * @return Success or failure code.
alecguertin 17:c72c092fcdf7 41 */
alecguertin 17:c72c092fcdf7 42 int retrieve_inst(char *buf, int *x, int *y, int *draw);
alecguertin 17:c72c092fcdf7 43
alecguertin 17:c72c092fcdf7 44 /**
lsaristo 29:459ff10d2a07 45 * @brief Driver forward for a time.
lsaristo 8:12d780f7443e 46 *
lsaristo 29:459ff10d2a07 47 * @param[in] amt Amount to drive forward. In milliseconds.
lsaristo 8:12d780f7443e 48 */
lsaristo 29:459ff10d2a07 49 void forward(int amt);
lsaristo 8:12d780f7443e 50
lsaristo 8:12d780f7443e 51 /**
lsaristo 29:459ff10d2a07 52 * @brief Drive backward for a time.
lsaristo 8:12d780f7443e 53 *
lsaristo 29:459ff10d2a07 54 * @param[in] amt Amount to drive backward. In milliseconds.
lsaristo 8:12d780f7443e 55 */
lsaristo 29:459ff10d2a07 56 void backward(int amt);
lsaristo 8:12d780f7443e 57
lsaristo 8:12d780f7443e 58 /**
lsaristo 29:459ff10d2a07 59 * @brief Turn right by some angle.
lsaristo 8:12d780f7443e 60 *
lsaristo 29:459ff10d2a07 61 * @param[in] deg Desired final turn angle in degrees from start.
lsaristo 29:459ff10d2a07 62 * Note that a negative angle will turn in the opposite
lsaristo 29:459ff10d2a07 63 * direction.
lsaristo 8:12d780f7443e 64 */
lsaristo 29:459ff10d2a07 65 void right(float deg);
lsaristo 8:12d780f7443e 66
lsaristo 8:12d780f7443e 67 /**
lsaristo 29:459ff10d2a07 68 * @brief Turn left by some angle.
lsaristo 8:12d780f7443e 69 *
lsaristo 29:459ff10d2a07 70 * @param[in] deg Desired final turn angle in degrees from start.
lsaristo 29:459ff10d2a07 71 * Note that a negative angle will turn in the opposite
lsaristo 29:459ff10d2a07 72 * direction.
lsaristo 8:12d780f7443e 73 */
lsaristo 29:459ff10d2a07 74 void left (float deg);
lsaristo 8:12d780f7443e 75
lsaristo 29:459ff10d2a07 76 /** @brief Lower pen intro drawing position */
lsaristo 10:94b068b2ce1d 77 void pen_down();
lsaristo 10:94b068b2ce1d 78
lsaristo 29:459ff10d2a07 79 /** @brief Raise pen into moveto position */
lsaristo 29:459ff10d2a07 80 void pen_up();
lsaristo 10:94b068b2ce1d 81
lsaristo 10:94b068b2ce1d 82 /**
lsaristo 8:12d780f7443e 83 * @brief Controller decision logic.
lsaristo 8:12d780f7443e 84 *
lsaristo 8:12d780f7443e 85 * Decide what to do next based on the status of the drawing so far.
lsaristo 8:12d780f7443e 86 */
lsaristo 8:12d780f7443e 87 void next_action();
lsaristo 21:0c80a5d89ea3 88
lsaristo 21:0c80a5d89ea3 89 /**
lsaristo 29:459ff10d2a07 90 * @brief Wait for a number of seconds, possibly fractional.
lsaristo 29:459ff10d2a07 91 *
lsaristo 29:459ff10d2a07 92 * Timer resolution is on the order of microseconds. A negative wait
lsaristo 29:459ff10d2a07 93 * time does nothing.
lsaristo 21:0c80a5d89ea3 94 *
lsaristo 29:459ff10d2a07 95 * @param[in] amt Time to wait, in seconds.
lsaristo 21:0c80a5d89ea3 96 */
lsaristo 29:459ff10d2a07 97 void timerWait(float amt);
lsaristo 29:459ff10d2a07 98 #endif