diff options
author | Mike Fiore <mfiore@multitech.com> | 2015-12-02 12:01:38 -0600 |
---|---|---|
committer | Mike Fiore <mfiore@multitech.com> | 2015-12-02 12:01:38 -0600 |
commit | 10a50c37dfa08f0355ceb5664b92f50b4aba9fd2 (patch) | |
tree | d21c0cf2397dec35378c9adae0e91c534e0ebf7b /Mode | |
parent | ab6c90739bc2efb5eaf94474be8916fe0f990707 (diff) | |
download | mtdot-box-evb-factory-firmware-10a50c37dfa08f0355ceb5664b92f50b4aba9fd2.tar.gz mtdot-box-evb-factory-firmware-10a50c37dfa08f0355ceb5664b92f50b4aba9fd2.tar.bz2 mtdot-box-evb-factory-firmware-10a50c37dfa08f0355ceb5664b92f50b4aba9fd2.zip |
use a global GPS object like we do for buttons, LoRa, etc
Diffstat (limited to 'Mode')
-rw-r--r-- | Mode/Mode.cpp | 19 | ||||
-rw-r--r-- | Mode/Mode.h | 5 | ||||
-rw-r--r-- | Mode/ModeConfig.cpp | 4 | ||||
-rw-r--r-- | Mode/ModeConfig.h | 2 | ||||
-rw-r--r-- | Mode/ModeJoin.cpp | 4 | ||||
-rw-r--r-- | Mode/ModeJoin.h | 2 | ||||
-rw-r--r-- | Mode/ModeSingle.cpp | 4 | ||||
-rw-r--r-- | Mode/ModeSingle.h | 2 | ||||
-rw-r--r-- | Mode/ModeSweep.cpp | 4 | ||||
-rw-r--r-- | Mode/ModeSweep.h | 2 |
10 files changed, 23 insertions, 25 deletions
diff --git a/Mode/Mode.cpp b/Mode/Mode.cpp index f049e33..c44b3bd 100644 --- a/Mode/Mode.cpp +++ b/Mode/Mode.cpp @@ -13,11 +13,12 @@ union convert16 { } convertS; -Mode::Mode(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora) +Mode::Mode(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps) : _lcd(lcd), _buttons(buttons), _dot(dot), _lora(lora), + _gps(gps), _main_id(Thread::gettid()), _index(0), _band(_dot->getFrequencyBand()), @@ -25,9 +26,7 @@ Mode::Mode(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora) _data_rate(mDot::SF_7), _power(2), _next_tx(0), - _send_data(false), - _gpsUART(PA_2, PA_3), - _mdot_gps(&_gpsUART) + _send_data(false) {} Mode::~Mode() {} @@ -135,9 +134,9 @@ void Mode::updateData(DataItem& data, DataType type, bool status) { data.index = _index; data.status = status; data.lock = 0; - data.gps_longitude = _mdot_gps.getLongitude(); - data.gps_latitude = _mdot_gps.getLatitude(); - data.gps_altitude = _mdot_gps.getAltitude(); + data.gps_longitude = _gps->getLongitude(); + data.gps_latitude = _gps->getLatitude(); + data.gps_altitude = _gps->getAltitude(); data.ping = _ping_result; data.data_rate = _data_rate; data.power = _power; @@ -238,12 +237,12 @@ std::vector<uint8_t> Mode::formatSurveyData(DataItem& data) { send_data.push_back(data.ping.down.snr); // collect GPS data if GPS device detected - if (_mdot_gps.gpsDetected() && ((_data_rate != mDot::SF_10) || (_band == mDot::FB_868))){ + if (_gps->gpsDetected() && ((_data_rate != mDot::SF_10) || (_band == mDot::FB_868))){ send_data.push_back(0x19); // key for GPS Lock Status - satfix = (_mdot_gps.getNumSatellites() << 4 ) | (_mdot_gps.getFixStatus() & 0x0F ); + satfix = (_gps->getNumSatellites() << 4 ) | (_gps->getFixStatus() & 0x0F ); send_data.push_back(satfix); - if (_mdot_gps.getLockStatus()){ // if gps has a lock + if (_gps->getLockStatus()){ // if gps has a lock // Send GPS data if GPS device locked send_data.push_back(0x15); // key for GPS Latitude send_data.push_back(data.gps_latitude.degrees); diff --git a/Mode/Mode.h b/Mode/Mode.h index 5d41ed1..f427eea 100644 --- a/Mode/Mode.h +++ b/Mode/Mode.h @@ -38,7 +38,7 @@ class Mode { uint32_t pressure; } SensorItem; - Mode(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora); + Mode(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps); ~Mode(); virtual bool start() = 0; @@ -56,6 +56,7 @@ class Mode { ButtonHandler* _buttons; mDot* _dot; LoRaHandler* _lora; + GPSPARSER* _gps; osThreadId _main_id; static const char* _file_name; uint32_t _index; @@ -69,8 +70,6 @@ class Mode { LoRaHandler::LoRaPing _ping_result; uint8_t _state; bool _send_data; - mts::MTSSerial _gpsUART; - GPSPARSER _mdot_gps; }; #endif diff --git a/Mode/ModeConfig.cpp b/Mode/ModeConfig.cpp index 35a81bd..babd898 100644 --- a/Mode/ModeConfig.cpp +++ b/Mode/ModeConfig.cpp @@ -19,8 +19,8 @@ void ModeConfig::addCommand(Command* cmd) { _commands.push_back(cmd); } -ModeConfig::ModeConfig(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora) -: Mode(lcd, buttons, dot, lora), +ModeConfig::ModeConfig(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps) +: Mode(lcd, buttons, dot, lora, gps), _lc(lcd), _serial(USBTX, USBRX, 512, 512) { diff --git a/Mode/ModeConfig.h b/Mode/ModeConfig.h index 1192a8c..6c0ac73 100644 --- a/Mode/ModeConfig.h +++ b/Mode/ModeConfig.h @@ -13,7 +13,7 @@ class ModeConfig : public Mode { public: - ModeConfig(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora); + ModeConfig(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps); // Command error text... static const char command_error[]; diff --git a/Mode/ModeJoin.cpp b/Mode/ModeJoin.cpp index d1e69ea..c992eff 100644 --- a/Mode/ModeJoin.cpp +++ b/Mode/ModeJoin.cpp @@ -2,8 +2,8 @@ #include "MTSLog.h" #include "MTSText.h" -ModeJoin::ModeJoin(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora) - : Mode(lcd, buttons, dot, lora), +ModeJoin::ModeJoin(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps) + : Mode(lcd, buttons, dot, lora, gps), _join(lcd, _band), _joined(false) {} diff --git a/Mode/ModeJoin.h b/Mode/ModeJoin.h index af48d94..cad3f61 100644 --- a/Mode/ModeJoin.h +++ b/Mode/ModeJoin.h @@ -6,7 +6,7 @@ class ModeJoin : public Mode { public: - ModeJoin(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora); + ModeJoin(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps); ~ModeJoin(); bool start(); diff --git a/Mode/ModeSingle.cpp b/Mode/ModeSingle.cpp index 083b72d..49119a0 100644 --- a/Mode/ModeSingle.cpp +++ b/Mode/ModeSingle.cpp @@ -1,8 +1,8 @@ #include "ModeSingle.h" #include "MTSLog.h" -ModeSingle::ModeSingle(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora) - : Mode(lcd, buttons, dot, lora), +ModeSingle::ModeSingle(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps) + : Mode(lcd, buttons, dot, lora, gps), _help(lcd), _file(lcd), _confirm(lcd), diff --git a/Mode/ModeSingle.h b/Mode/ModeSingle.h index df656ba..4f7cdf3 100644 --- a/Mode/ModeSingle.h +++ b/Mode/ModeSingle.h @@ -11,7 +11,7 @@ class ModeSingle : public Mode { public: - ModeSingle(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora); + ModeSingle(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps); ~ModeSingle(); bool start(); diff --git a/Mode/ModeSweep.cpp b/Mode/ModeSweep.cpp index 938ec83..8d22622 100644 --- a/Mode/ModeSweep.cpp +++ b/Mode/ModeSweep.cpp @@ -1,8 +1,8 @@ #include "ModeSweep.h" #include "MTSLog.h" -ModeSweep::ModeSweep(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora) - : Mode(lcd, buttons, dot, lora), +ModeSweep::ModeSweep(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps) + : Mode(lcd, buttons, dot, lora, gps), _help(lcd), _file(lcd), _confirm(lcd), diff --git a/Mode/ModeSweep.h b/Mode/ModeSweep.h index 5eebda1..f7522aa 100644 --- a/Mode/ModeSweep.h +++ b/Mode/ModeSweep.h @@ -14,7 +14,7 @@ typedef std::pair<uint8_t, uint32_t> point; class ModeSweep : public Mode { public: - ModeSweep(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora); + ModeSweep(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps); ~ModeSweep(); bool start(); |