Bmag incl gps rettelse
Dependencies: mbed WDT MODSERIAL BME280
Diff: BMAG/BMAG.cpp
- Revision:
- 8:d6287c33b54a
- Child:
- 14:400ecb93c6a2
diff -r 872984a67d5b -r d6287c33b54a BMAG/BMAG.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BMAG/BMAG.cpp Thu Mar 23 10:11:26 2017 +0000 @@ -0,0 +1,89 @@ +#include "BMAG.h" + +BMAG::BMAG(){ + lastMagTime.resize(25); + lastMagNT.resize(25); + lastMagSq.resize(25); + +}; + +void BMAG::parseBMAGString(string str){ + string tmpmagStr = ""; + + //get first mag string column + tmpmagStr.assign(getColumn(str, 0)); + + + setMagTimeStr(tmpmagStr); + tmpmagStr = ""; + + //get second mag string column + tmpmagStr.assign(getColumn(str, 1)); + setMagNTStr(tmpmagStr); + + tmpmagStr = ""; + + //get third mag string column + tmpmagStr.assign(getColumn(str, 2)); + + setMagSqStr(tmpmagStr); + + +}; + +void BMAG::setMagTimeStr(string magT){ + lastMagTime.assign(magT); +}; + + +void BMAG::setMagNTStr(string magNT){ + lastMagNT.assign(magNT); +}; + + +void BMAG::setMagSqStr(string magSq){ + lastMagSq.assign(magSq); +}; + + +string BMAG::getMagTimeStr(void){ + return lastMagTime; +}; + +string BMAG::getMagNTStr(void){ + return lastMagNT; +}; + +string BMAG::getMagSq(void){ + return lastMagSq; +}; + +string BMAG::getColumn(string str, char n){ + + char count = 0; + string tmpStr = ""; + tmpStr.resize(40); + char indexcnt = 0; + + + for(int i = 0; i < str.size(); i++){ + if(count == n && (str[i] != '\r') || count == n && (str[i] != '\n')){ + tmpStr[indexcnt] = str[i]; + indexcnt += 1; + } + + if(str[i] == '\r' || str[i] == ' '){ + count += 1; + } + + if(count > n){ + break; + } + } + + return tmpStr; + +}; + + +