Colin Stearns
/
qcControl
QC Control software
Fork of dgps by
Revision 44:2ae602b89961, committed 2014-04-23
- 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
--- 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);