Final Project files for mBed development.

Dependencies:   m3pi mbed

Committer:
John Wilkey
Date:
Thu Nov 13 00:00:14 2014 -0500
Revision:
6:00b7198f0b51
Parent:
5:01882c3de2dc
Child:
7:6e5cc24e1ce7
Untested additions to skelton

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lsaristo 1:7e0243c27ecb 1 /**
lsaristo 1:7e0243c27ecb 2 * @file project.h
lsaristo 1:7e0243c27ecb 3 * @brief Main header file for includes and whatnot
lsaristo 1:7e0243c27ecb 4 * for the other project files.
lsaristo 1:7e0243c27ecb 5 * @author John Wilkey
lsaristo 1:7e0243c27ecb 6 */
lsaristo 1:7e0243c27ecb 7
lsaristo 1:7e0243c27ecb 8 #ifndef _PROJECT_H
lsaristo 1:7e0243c27ecb 9 #define _PROJECT_H
lsaristo 1:7e0243c27ecb 10
lsaristo 1:7e0243c27ecb 11 #include <stdio.h>
John Wilkey 5:01882c3de2dc 12 #include "mbed.h"
lsaristo 3:d744a6e2c4c0 13 #include "m3pi.h"
John Wilkey 5:01882c3de2dc 14 #define TURN_SPEED 0.25
John Wilkey 6:00b7198f0b51 15 #define DRIVE_SPEED 0.5
John Wilkey 5:01882c3de2dc 16 #define ERR_SUCCESS 0
John Wilkey 5:01882c3de2dc 17 #define ERR_FAILURE 1
John Wilkey 5:01882c3de2dc 18
John Wilkey 5:01882c3de2dc 19 /**
John Wilkey 5:01882c3de2dc 20 * @brief Provides access to the digital outputs on the mbed controller.
John Wilkey 5:01882c3de2dc 21 *
John Wilkey 5:01882c3de2dc 22 * Note that by default these output pins are hardwired to the 6 LEDs that
John Wilkey 5:01882c3de2dc 23 * stripe the development extension board.
John Wilkey 5:01882c3de2dc 24 */
John Wilkey 5:01882c3de2dc 25 typedef struct {
John Wilkey 5:01882c3de2dc 26 DigitalOut pin15(p15),
John Wilkey 5:01882c3de2dc 27 DigitalOut pin15(p15),
John Wilkey 5:01882c3de2dc 28 DigitalOut pin15(p15),
John Wilkey 5:01882c3de2dc 29 DigitalOut pin15(p16),
John Wilkey 5:01882c3de2dc 30 DigitalOut pin15(p17),
John Wilkey 5:01882c3de2dc 31 DigitalOut pin15(p18),
John Wilkey 5:01882c3de2dc 32 DigitalOut pin15(p19),
John Wilkey 5:01882c3de2dc 33 DigitalOut pin15(p20)
John Wilkey 5:01882c3de2dc 34 } digi_out_pins;
lsaristo 1:7e0243c27ecb 35
lsaristo 1:7e0243c27ecb 36 /**
lsaristo 1:7e0243c27ecb 37 * @brief Driver forward.
lsaristo 1:7e0243c27ecb 38 *
lsaristo 1:7e0243c27ecb 39 * @param[in] amt Amount to drive forward.
lsaristo 1:7e0243c27ecb 40 * @param[in] spd Drive speed.
John Wilkey 5:01882c3de2dc 41 * @return Success or failure.
lsaristo 1:7e0243c27ecb 42 */
John Wilkey 5:01882c3de2dc 43 int foward(float amt, float spd);
lsaristo 1:7e0243c27ecb 44
lsaristo 1:7e0243c27ecb 45 /**
lsaristo 1:7e0243c27ecb 46 * @brief Drive backward.
lsaristo 1:7e0243c27ecb 47 *
lsaristo 1:7e0243c27ecb 48 * @param[in] amt Amount to drive backward.
lsaristo 1:7e0243c27ecb 49 * @param[in] spd Drive speed.
John Wilkey 5:01882c3de2dc 50 * @return Success or failure.
lsaristo 1:7e0243c27ecb 51 */
John Wilkey 5:01882c3de2dc 52 int backward(float amt);
lsaristo 1:7e0243c27ecb 53
lsaristo 1:7e0243c27ecb 54 /**
lsaristo 1:7e0243c27ecb 55 * @brief Turn right.
lsaristo 1:7e0243c27ecb 56 *
lsaristo 1:7e0243c27ecb 57 * @param[in] deg Desired final turn angle from starting position.
lsaristo 1:7e0243c27ecb 58 * @param[in] spd Desired turning speed.
John Wilkey 5:01882c3de2dc 59 * @return Success or failure.
lsaristo 1:7e0243c27ecb 60 */
lsaristo 1:7e0243c27ecb 61 int right(float deg);
lsaristo 1:7e0243c27ecb 62
lsaristo 1:7e0243c27ecb 63 /**
lsaristo 1:7e0243c27ecb 64 * @brief Turn left.
lsaristo 1:7e0243c27ecb 65 *
lsaristo 1:7e0243c27ecb 66 * @param[in] deg Desired final turn angle from starting position.
lsaristo 1:7e0243c27ecb 67 * @param[in] spd Desired turning speed.
John Wilkey 5:01882c3de2dc 68 * @return Success or failure.
lsaristo 1:7e0243c27ecb 69 */
John Wilkey 5:01882c3de2dc 70 int left (float deg);
lsaristo 1:7e0243c27ecb 71
lsaristo 1:7e0243c27ecb 72 /**
lsaristo 2:c2764165a23d 73 * @brief Controller decision logic.
lsaristo 1:7e0243c27ecb 74 *
lsaristo 1:7e0243c27ecb 75 * Decide what to do next based on the status of the drawing so far.
lsaristo 1:7e0243c27ecb 76 *
lsaristo 1:7e0243c27ecb 77 */
John Wilkey 5:01882c3de2dc 78 void next_action();
lsaristo 1:7e0243c27ecb 79
John Wilkey 5:01882c3de2dc 80 /**
John Wilkey 5:01882c3de2dc 81 * @brief Print a formatted message to the LCD
John Wilkey 5:01882c3de2dc 82 */
John Wilkey 5:01882c3de2dc 83 void pretty_print(char* msg);
John Wilkey 5:01882c3de2dc 84
John Wilkey 5:01882c3de2dc 85
John Wilkey 5:01882c3de2dc 86
John Wilkey 5:01882c3de2dc 87 #endif