k

Dependencies:   m3pi mbed

Fork of m3pi_HelloWorld by Chris Styles

Files at this revision

API Documentation at this revision

Comitter:
pietor
Date:
Wed Apr 19 09:51:15 2017 +0000
Parent:
7:d0689e8f23bf
Commit message:
k

Changed in this revision

Controller.cpp Show annotated file Show diff for this revision Revisions of this file
Controller.h Show annotated file Show diff for this revision Revisions of this file
Receiver.h Show annotated file Show diff for this revision Revisions of this file
Reveiver.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r d0689e8f23bf -r a6afbbc052e2 Controller.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Controller.cpp	Wed Apr 19 09:51:15 2017 +0000
@@ -0,0 +1,34 @@
+/**
+    Controller.cpp
+    Purpose:
+
+    @author Pieter Berteloot
+*/
+
+#include "mbed.h"
+#include "Controller.h"
+#include "m3pi.h"
+
+m3pi m3pi;
+
+//constructor
+Controller::Controller() {
+        
+    m3pi.locate(0,1);
+};
+
+
+void Controller::leftMotor(float speedLeft)
+{
+    
+m3pi.left_motor(speedLeft); 
+
+}
+
+void Controller::rightMotor(float speedRight)
+{
+    
+m3pi.right_motor(speedRight); 
+
+}
+
diff -r d0689e8f23bf -r a6afbbc052e2 Controller.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Controller.h	Wed Apr 19 09:51:15 2017 +0000
@@ -0,0 +1,16 @@
+#ifndef Controller_h
+#define Controller_h
+#include "mbed.h"
+
+class Controller
+{
+private:
+
+
+public:
+    Controller();
+    void rightMotor(float speedRight);
+    void leftMotor(float speedLeft);
+
+};
+#endif
\ No newline at end of file
diff -r d0689e8f23bf -r a6afbbc052e2 Receiver.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Receiver.h	Wed Apr 19 09:51:15 2017 +0000
@@ -0,0 +1,15 @@
+#ifndef Receiver_h
+#define Receiver_h
+#include "mbed.h"
+
+class Receiver
+{
+private:
+
+
+public:
+    Receiver();
+    float convertBitsToFloat(char *dataIn);
+
+};
+#endif
\ No newline at end of file
diff -r d0689e8f23bf -r a6afbbc052e2 Reveiver.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Reveiver.cpp	Wed Apr 19 09:51:15 2017 +0000
@@ -0,0 +1,23 @@
+/**
+    Receiver.cpp
+    Purpose:
+
+    @author Pieter Berteloot
+*/
+
+#include "mbed.h"
+#include "Receiver.h"
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+Receiver::Receiver() {};
+
+
+float Receiver::convertBitsToFloat(char *dataIn)
+{
+    float temp = (dataIn[0]*1 + dataIn[1]*2 + dataIn[2]*4 + dataIn[3]*8);
+    return temp/16;
+}
+
+
+
diff -r d0689e8f23bf -r a6afbbc052e2 main.cpp
--- a/main.cpp	Fri May 13 10:51:57 2011 +0000
+++ b/main.cpp	Wed Apr 19 09:51:15 2017 +0000
@@ -1,23 +1,15 @@
 #include "mbed.h"
 #include "m3pi.h"
-
-m3pi m3pi;
+#include "Controller.h"
+#include "Receiver.h"
+Controller ctrl;
+Receiver recv;
 
 int main() {
-
-    m3pi.locate(0,1);
-    m3pi.printf("LO World");
-
-    wait (2.0);
-
-    m3pi.forward(0.5); // Forward half speed
-    wait (0.5);        // wait half a second
-    m3pi.left(0.5);    // Turn left at half speed
-    wait (0.5);        // wait half a second
-    m3pi.backward(0.5);// Backward at half speed 
-    wait (0.5);        // wait half a second
-    m3pi.right(0.5);   // Turn right at half speed
-    wait (0.5);        // wait half a second
-
-    m3pi.stop();       
+while(true){
+  char test[4] = {1,0,0,1}; 
+    float test2 = recv.convertBitsToFloat(test);
+    printf("%.2f, test", test2);
+    wait_ms(1000);
+    }
 }
\ No newline at end of file