EE149
/
FinalProject
Final Project files for mBed development.
main.h@35:a1c14c6d9282, 2014-12-10 (annotated)
- Committer:
- lsaristo
- Date:
- Wed Dec 10 19:15:52 2014 +0000
- Revision:
- 35:a1c14c6d9282
- Parent:
- 34:3066686d5152
- Child:
- 37:1d51cf101b03
Added upper bound on 'wiggle' and removed some unused constants.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lsaristo | 8:12d780f7443e | 1 | /** |
lsaristo | 10:94b068b2ce1d | 2 | * @file main.h |
lsaristo | 35:a1c14c6d9282 | 3 | * @brief Main header file for includes and defs |
lsaristo | 8:12d780f7443e | 4 | * @author John Wilkey |
lsaristo | 29:459ff10d2a07 | 5 | * @author Alec Guertin |
lsaristo | 29:459ff10d2a07 | 6 | * @author Chester Chu |
lsaristo | 8:12d780f7443e | 7 | */ |
lsaristo | 8:12d780f7443e | 8 | |
lsaristo | 10:94b068b2ce1d | 9 | #ifndef _MAIN_H |
lsaristo | 10:94b068b2ce1d | 10 | #define _MAIN_H |
lsaristo | 8:12d780f7443e | 11 | |
lsaristo | 8:12d780f7443e | 12 | #include "mbed.h" |
lsaristo | 8:12d780f7443e | 13 | #include "m3pi.h" |
lsaristo | 9:3a0433c391cb | 14 | #include <string.h> |
lsaristo | 9:3a0433c391cb | 15 | #include <stdarg.h> |
lsaristo | 9:3a0433c391cb | 16 | #include <stdio.h> |
lsaristo | 21:0c80a5d89ea3 | 17 | #include <math.h> |
lsaristo | 35:a1c14c6d9282 | 18 | |
lsaristo | 35:a1c14c6d9282 | 19 | // Constants used in main.c |
lsaristo | 35:a1c14c6d9282 | 20 | #define TURN_SPEED 0.15 /**< Motor power for turning */ |
lsaristo | 35:a1c14c6d9282 | 21 | #define DRIVE_SPEED 0.25 /**< Motor power for drawing/moving */ |
lsaristo | 35:a1c14c6d9282 | 22 | #define TIME_FACT 1780 /**< Multiplier for forward() and backward() */ |
lsaristo | 35:a1c14c6d9282 | 23 | #define CAL_SPEED .25 /**< Drive speed during calibration */ |
lsaristo | 35:a1c14c6d9282 | 24 | #define CLOSE_ENOUGH .0008 /**< Threshold for calibration line centering */ |
lsaristo | 35:a1c14c6d9282 | 25 | #define WIGGLE_MAX 15 /**< Max 'wiggles' during calibration */ |
lsaristo | 8:12d780f7443e | 26 | |
lsaristo | 29:459ff10d2a07 | 27 | /** @brief Move the robot from its current position to (x,y) */ |
alecguertin | 18:eab7b0e89398 | 28 | void move(int x, int y, int draw); |
alecguertin | 18:eab7b0e89398 | 29 | |
lsaristo | 8:12d780f7443e | 30 | /** |
alecguertin | 17:c72c092fcdf7 | 31 | * @brief get values of next PostScript instruction. |
alecguertin | 17:c72c092fcdf7 | 32 | * |
alecguertin | 17:c72c092fcdf7 | 33 | * @param buf Buffer with PS instructions. |
alecguertin | 17:c72c092fcdf7 | 34 | * @param x Pointer to storage for x coordinate. |
alecguertin | 17:c72c092fcdf7 | 35 | * @param y Pointer to storage for y coordinate. |
alecguertin | 17:c72c092fcdf7 | 36 | * @param draw Pointer to storage for draw/move boolean. |
alecguertin | 17:c72c092fcdf7 | 37 | * |
alecguertin | 17:c72c092fcdf7 | 38 | * @return Success or failure code. |
alecguertin | 17:c72c092fcdf7 | 39 | */ |
alecguertin | 17:c72c092fcdf7 | 40 | int retrieve_inst(char *buf, int *x, int *y, int *draw); |
alecguertin | 17:c72c092fcdf7 | 41 | |
alecguertin | 17:c72c092fcdf7 | 42 | /** |
lsaristo | 29:459ff10d2a07 | 43 | * @brief Driver forward for a time. |
lsaristo | 8:12d780f7443e | 44 | * |
lsaristo | 29:459ff10d2a07 | 45 | * @param[in] amt Amount to drive forward. In milliseconds. |
lsaristo | 8:12d780f7443e | 46 | */ |
lsaristo | 29:459ff10d2a07 | 47 | void forward(int amt); |
lsaristo | 8:12d780f7443e | 48 | |
lsaristo | 8:12d780f7443e | 49 | /** |
lsaristo | 29:459ff10d2a07 | 50 | * @brief Drive backward for a time. |
lsaristo | 8:12d780f7443e | 51 | * |
lsaristo | 29:459ff10d2a07 | 52 | * @param[in] amt Amount to drive backward. In milliseconds. |
lsaristo | 8:12d780f7443e | 53 | */ |
lsaristo | 29:459ff10d2a07 | 54 | void backward(int amt); |
lsaristo | 8:12d780f7443e | 55 | |
lsaristo | 8:12d780f7443e | 56 | /** |
lsaristo | 29:459ff10d2a07 | 57 | * @brief Turn right by some angle. |
lsaristo | 8:12d780f7443e | 58 | * |
lsaristo | 29:459ff10d2a07 | 59 | * @param[in] deg Desired final turn angle in degrees from start. |
lsaristo | 29:459ff10d2a07 | 60 | * Note that a negative angle will turn in the opposite |
lsaristo | 29:459ff10d2a07 | 61 | * direction. |
lsaristo | 8:12d780f7443e | 62 | */ |
lsaristo | 29:459ff10d2a07 | 63 | void right(float deg); |
lsaristo | 8:12d780f7443e | 64 | |
lsaristo | 8:12d780f7443e | 65 | /** |
lsaristo | 29:459ff10d2a07 | 66 | * @brief Turn left by some angle. |
lsaristo | 8:12d780f7443e | 67 | * |
lsaristo | 29:459ff10d2a07 | 68 | * @param[in] deg Desired final turn angle in degrees from start. |
lsaristo | 29:459ff10d2a07 | 69 | * Note that a negative angle will turn in the opposite |
lsaristo | 29:459ff10d2a07 | 70 | * direction. |
lsaristo | 8:12d780f7443e | 71 | */ |
lsaristo | 29:459ff10d2a07 | 72 | void left (float deg); |
lsaristo | 8:12d780f7443e | 73 | |
lsaristo | 21:0c80a5d89ea3 | 74 | /** |
lsaristo | 29:459ff10d2a07 | 75 | * @brief Wait for a number of seconds, possibly fractional. |
lsaristo | 29:459ff10d2a07 | 76 | * |
lsaristo | 29:459ff10d2a07 | 77 | * Timer resolution is on the order of microseconds. A negative wait |
lsaristo | 29:459ff10d2a07 | 78 | * time does nothing. |
lsaristo | 21:0c80a5d89ea3 | 79 | * |
lsaristo | 29:459ff10d2a07 | 80 | * @param[in] amt Time to wait, in seconds. |
lsaristo | 21:0c80a5d89ea3 | 81 | */ |
lsaristo | 29:459ff10d2a07 | 82 | void timerWait(float amt); |
lsaristo | 29:459ff10d2a07 | 83 | #endif |