Final Project files for mBed development.

Dependencies:   m3pi mbed

Committer:
John Wilkey
Date:
Wed Nov 12 23:48:26 2014 -0500
Revision:
5:01882c3de2dc
Parent:
3:d744a6e2c4c0
Child:
6:00b7198f0b51
Small additions to skeleton code

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