Final Project files for mBed development.

Dependencies:   m3pi mbed

Files at this revision

API Documentation at this revision

Comitter:
John Wilkey
Date:
Wed Nov 12 23:48:26 2014 -0500
Parent:
4:13c13a098d2b
Child:
6:00b7198f0b51
Commit message:
Small additions to skeleton code

Changed in this revision

control.c Show annotated file Show diff for this revision Revisions of this file
driver.c Show diff for this revision Revisions of this file
main.c Show annotated file Show diff for this revision Revisions of this file
project.h Show annotated file Show diff for this revision Revisions of this file
--- a/control.c	Thu Nov 13 01:46:51 2014 +0000
+++ b/control.c	Wed Nov 12 23:48:26 2014 -0500
@@ -1,3 +1,43 @@
 /**
  * @file    control.c
- */
\ No newline at end of file
+ * @brief   Motor control functions implemented from project.h
+ * @author  John Wilkey
+ */
+
+#include "project.h"
+extern pi;
+extern out_pins;
+
+int forward(float amt, float spd)
+{
+    pi.forward(spd);
+    wait(amt);
+    return EXIT_SUCCESS;
+}
+
+int backward(float amt, float spd)
+{
+    pi.backward(spd);
+    wait(amt);
+    return EXIT_SUCCESS;
+}
+
+int right(float deg)
+{
+    pi.right(TURN_SPEED);
+    wait(deg/360);
+    return EXIT_SUCCESS;
+}
+
+int left(float deg)
+{
+    pi.left(TURN_SPEED);
+    wait(deg/360);
+    return EXIT_SUCCESS;
+}
+
+void pretty_print(char* msg)
+{
+    pi.locate(0,1);
+    pi.printf(msg);
+}
--- a/driver.c	Thu Nov 13 01:46:51 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-/**
- * @file    driver.c
- * @brief   Basic driver program for our robot's controller logic. 
- *
- * Maybe add lots of stuff here or maybe split it off into
- * multiple subfiles?
- *
- * @author  John Wilkey
- */
- #include "project.h"
- 
- /**
-  * @brief Entry point. Main loop.
-  */
- int main()
- {
-       printf("This doesn't do anything yet...\n");
-       return 0;
- }
- 
- 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.c	Wed Nov 12 23:48:26 2014 -0500
@@ -0,0 +1,25 @@
+/**
+ * @file    driver.c
+ * @brief   Basic driver program for our robot's controller logic. 
+ *
+ * Maybe add lots of stuff here or maybe split it off into
+ * multiple subfiles?
+ *
+ * @author  John Wilkey
+ */
+#include "project.h"
+
+/** 
+ * These are global data Used externally in all other files 
+ */
+m3pi            pi;
+digi_out_pins   out_pins;
+
+/**
+ * @brief Entry point. Main loop.
+ */
+int main()
+{
+    pretty_print("PiCO");
+    return EXIT_SUCCESS;
+}
--- a/project.h	Thu Nov 13 01:46:51 2014 +0000
+++ b/project.h	Wed Nov 12 23:48:26 2014 -0500
@@ -9,32 +9,53 @@
 #define _PROJECT_H
 
 #include <stdio.h>
+#include "mbed.h"
 #include "m3pi.h"
+#define TURN_SPEED 0.25
+#define ERR_SUCCESS 0
+#define ERR_FAILURE 1
+
+/**
+ * @brief   Provides access to the digital outputs on the mbed controller.
+ *
+ * Note that by default these output pins are hardwired to the 6 LEDs that 
+ * stripe the development extension board. 
+ */
+typedef struct {
+    DigitalOut pin15(p15),
+    DigitalOut pin15(p15),
+    DigitalOut pin15(p15),
+    DigitalOut pin15(p16),
+    DigitalOut pin15(p17),
+    DigitalOut pin15(p18),
+    DigitalOut pin15(p19),
+    DigitalOut pin15(p20)
+} digi_out_pins;
 
 /**
  * @brief Driver forward.
  *
  * @param[in]   amt     Amount to drive forward.
  * @param[in]   spd     Drive speed.
- * @return              Distance driven.
+ * @return              Success or failure. 
  */
-float foward(float amt, float spd);
+int foward(float amt, float spd);
 
 /**
  * @brief Drive backward.
  *
  * @param[in]   amt     Amount to drive backward.
  * @param[in]   spd     Drive speed.
- * @return              Distance driven.
+ * @return              Success or failure. 
  */
-float backward(float amt);
+int backward(float amt);
 
 /**
  * @brief Turn right.
  *
  * @param[in]   deg     Desired final turn angle from starting position.
  * @param[in]   spd     Desired turning speed.
- * @return              0 if successful, or an error condition.
+ * @return              Success or failure. 
  */
 int right(float deg);
 
@@ -43,9 +64,9 @@
  *
  * @param[in]   deg     Desired final turn angle from starting position.
  * @param[in]   spd     Desired turning speed.
- * @return              0 if successful, or an error condition.
+ * @return              Success or failure. 
  */
-int left (float def);
+int left (float deg);
 
 /**
  * @brief Controller decision logic.
@@ -53,6 +74,13 @@
  * Decide what to do next based on the status of the drawing so far.
  *
  */
- void next_action();
+void next_action();
 
-#endif
\ No newline at end of file
+/**
+ * @brief Print a formatted message to the LCD
+ */
+void pretty_print(char* msg);
+
+
+
+#endif