Final Project files for mBed development.

Dependencies:   m3pi mbed

Committer:
alecguertin
Date:
Mon Dec 01 01:02:42 2014 +0000
Revision:
18:eab7b0e89398
Parent:
17:c72c092fcdf7
Child:
21:0c80a5d89ea3
added logic to calculate angle to drive at -- untested

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 8:12d780f7443e 6 */
lsaristo 8:12d780f7443e 7
lsaristo 10:94b068b2ce1d 8 #ifndef _MAIN_H
lsaristo 10:94b068b2ce1d 9 #define _MAIN_H
lsaristo 8:12d780f7443e 10
lsaristo 8:12d780f7443e 11 #include "mbed.h"
lsaristo 8:12d780f7443e 12 #include "m3pi.h"
lsaristo 9:3a0433c391cb 13 #include <string.h>
lsaristo 9:3a0433c391cb 14 #include <stdarg.h>
lsaristo 9:3a0433c391cb 15 #include <stdio.h>
lsaristo 9:3a0433c391cb 16 #define TURN_SPEED 0.25
alecguertin 15:14d4e7021125 17 #define DRIVE_SPEED 0.1
lsaristo 8:12d780f7443e 18 #define ERR_SUCCESS 0
lsaristo 8:12d780f7443e 19 #define ERR_FAILURE 1
lsaristo 9:3a0433c391cb 20 #define DRIVE_RATE 1/50
lsaristo 8:12d780f7443e 21
alecguertin 18:eab7b0e89398 22
alecguertin 18:eab7b0e89398 23 /**
alecguertin 18:eab7b0e89398 24 * @brief move the robot from its current position to (x,y)
alecguertin 18:eab7b0e89398 25 *
alecguertin 18:eab7b0e89398 26 */
alecguertin 18:eab7b0e89398 27 void move(int x, int y, int draw);
alecguertin 18:eab7b0e89398 28
lsaristo 8:12d780f7443e 29 /**
alecguertin 17:c72c092fcdf7 30 * @brief get values of next PostScript instruction.
alecguertin 17:c72c092fcdf7 31 *
alecguertin 17:c72c092fcdf7 32 * @param buf Buffer with PS instructions.
alecguertin 17:c72c092fcdf7 33 * @param x Pointer to storage for x coordinate.
alecguertin 17:c72c092fcdf7 34 * @param y Pointer to storage for y coordinate.
alecguertin 17:c72c092fcdf7 35 * @param draw Pointer to storage for draw/move boolean.
alecguertin 17:c72c092fcdf7 36 *
alecguertin 17:c72c092fcdf7 37 * @return Success or failure code.
alecguertin 17:c72c092fcdf7 38 */
alecguertin 17:c72c092fcdf7 39 int retrieve_inst(char *buf, int *x, int *y, int *draw);
alecguertin 17:c72c092fcdf7 40
alecguertin 17:c72c092fcdf7 41 /**
lsaristo 8:12d780f7443e 42 * @brief Driver forward.
lsaristo 8:12d780f7443e 43 *
lsaristo 9:3a0433c391cb 44 * @param[in] amt Amount to drive forward. In centimeters.
lsaristo 8:12d780f7443e 45 * @return Success or failure.
lsaristo 8:12d780f7443e 46 */
lsaristo 9:3a0433c391cb 47 int forward(int amt);
lsaristo 8:12d780f7443e 48
lsaristo 8:12d780f7443e 49 /**
lsaristo 8:12d780f7443e 50 * @brief Drive backward.
lsaristo 8:12d780f7443e 51 *
lsaristo 9:3a0433c391cb 52 * @param[in] amt Amount to drive backward. In centimeters.
lsaristo 8:12d780f7443e 53 * @return Success or failure.
lsaristo 8:12d780f7443e 54 */
lsaristo 9:3a0433c391cb 55 int backward(int amt);
lsaristo 8:12d780f7443e 56
lsaristo 8:12d780f7443e 57 /**
lsaristo 8:12d780f7443e 58 * @brief Turn right.
lsaristo 8:12d780f7443e 59 *
lsaristo 8:12d780f7443e 60 * @param[in] deg Desired final turn angle from starting position.
lsaristo 8:12d780f7443e 61 * @param[in] spd Desired turning speed.
lsaristo 8:12d780f7443e 62 * @return Success or failure.
lsaristo 8:12d780f7443e 63 */
lsaristo 8:12d780f7443e 64 int right(float deg);
lsaristo 8:12d780f7443e 65
lsaristo 8:12d780f7443e 66 /**
lsaristo 8:12d780f7443e 67 * @brief Turn left.
lsaristo 8:12d780f7443e 68 *
lsaristo 8:12d780f7443e 69 * @param[in] deg Desired final turn angle from starting position.
lsaristo 8:12d780f7443e 70 * @param[in] spd Desired turning speed.
lsaristo 8:12d780f7443e 71 * @return Success or failure.
lsaristo 8:12d780f7443e 72 */
lsaristo 8:12d780f7443e 73 int left (float deg);
lsaristo 8:12d780f7443e 74
lsaristo 8:12d780f7443e 75 /**
lsaristo 10:94b068b2ce1d 76 * @brief Enable pen motion.
lsaristo 10:94b068b2ce1d 77 *
lsaristo 10:94b068b2ce1d 78 * Note that at the moment, for simplicity, this method just activates an LED
lsaristo 10:94b068b2ce1d 79 * on the expansion board to indicate that the pen should be in DOWN mode.
lsaristo 10:94b068b2ce1d 80 */
lsaristo 10:94b068b2ce1d 81 void pen_down();
lsaristo 10:94b068b2ce1d 82
lsaristo 10:94b068b2ce1d 83 /**
lsaristo 10:94b068b2ce1d 84 * @brief Raise pen
lsaristo 10:94b068b2ce1d 85 */
lsaristo 10:94b068b2ce1d 86 void pen_up();
lsaristo 10:94b068b2ce1d 87
lsaristo 10:94b068b2ce1d 88
lsaristo 10:94b068b2ce1d 89 /**
lsaristo 8:12d780f7443e 90 * @brief Controller decision logic.
lsaristo 8:12d780f7443e 91 *
lsaristo 8:12d780f7443e 92 * Decide what to do next based on the status of the drawing so far.
lsaristo 8:12d780f7443e 93 */
lsaristo 8:12d780f7443e 94 void next_action();
lsaristo 8:12d780f7443e 95 #endif