QC Control software

Dependencies:   mbed

Fork of dgps by Colin Stearns

Files at this revision

API Documentation at this revision

Comitter:
krobertson
Date:
Wed Apr 23 04:45:36 2014 +0000
Parent:
43:b8cbe6f0ec47
Child:
45:0d6ef4cbd4c7
Commit message:
its alive! Compass integrated in.

Changed in this revision

handle/handleCompass.cpp Show annotated file Show diff for this revision Revisions of this file
handle/handleCompass.h Show annotated file Show diff for this revision Revisions of this file
handle/handleGPS.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
--- a/handle/handleCompass.cpp	Wed Apr 23 04:20:40 2014 +0000
+++ b/handle/handleCompass.cpp	Wed Apr 23 04:45:36 2014 +0000
@@ -1,16 +1,23 @@
 #include "handleCompass.h"
 
+compassHandle* compassHandle::hand = NULL;
+
 compassHandle::compassHandle(){
     heading = 0;
-    setup();
+    initialized = false;
 }
 
 void compassHandle::setup(){
+    initialized = true;
     compass.init();
     compass.enableDefault();
 }
 
 void compassHandle::run(){
+    if(!initialized){
+        setup();
+    }
     compass.read();
     heading = compass.get_heading();
+    USB::getSerial().printf("Compass heading: %f\r\n",heading);
 }
\ No newline at end of file
--- a/handle/handleCompass.h	Wed Apr 23 04:20:40 2014 +0000
+++ b/handle/handleCompass.h	Wed Apr 23 04:45:36 2014 +0000
@@ -2,6 +2,7 @@
 #define _HANDLECOMPASS_H_
 
 #include "adapt/compass.h"
+#include "adapt/usb.h"
 
 class compassHandle {
 public:
@@ -24,11 +25,22 @@
     * \brief gets an updated heading
     **/
     void run();
+    
+    static compassHandle* hand;
+    static compassHandle& getCompassHand(){
+        if(hand == NULL){
+            hand = new compassHandle();
+        }
+        return *hand;
+    }
+    
 private:
     /**
     * \brief reference to the compass adaptor
     **/
     Compass compass;
+    
+    bool initialized;
 };
 
 #endif
\ No newline at end of file
--- a/handle/handleGPS.cpp	Wed Apr 23 04:20:40 2014 +0000
+++ b/handle/handleGPS.cpp	Wed Apr 23 04:45:36 2014 +0000
@@ -23,7 +23,7 @@
     if(rx_status != 1){
         return rx_status;
     }
-    DH::Locs().inc(LHType_targ,0,true);
+    DH::Locs().getI(LHType_targ,LHIType_size) = 0;//reset size to 0 (clear out old waypoints
     Point* points = (Point*)pack.data;
     unsigned int num_points = pack.size;
     for(int i=0;i<num_points;i++){
--- a/main.cpp	Wed Apr 23 04:20:40 2014 +0000
+++ b/main.cpp	Wed Apr 23 04:45:36 2014 +0000
@@ -7,6 +7,7 @@
 #include "handle/handleCommand.h"
 #include "handle/mavcommands.h"
 #include "handle/dataLocation.h"
+#include "handle/handleCompass.h"
 #define DELAYBOOT 1
 
 Serial pc(USBTX,USBRX);
@@ -138,6 +139,8 @@
         while(1){
             USB::getSerial().printf("Running GPS...\r\n");
             GPSHandle::getGPSHand().run();
+            USB::getSerial().printf("Running Compass...\r\n");
+            compassHandle::getCompassHand().run();
             USB::getSerial().printf("Requesting commands from egg...\r\n");
             if(count % 100 == 0){
                 wait_us(100000);