diff options
Diffstat (limited to 'Layout')
-rw-r--r-- | Layout/LayoutData.cpp | 104 | ||||
-rw-r--r-- | Layout/LayoutData.h | 77 | ||||
-rw-r--r-- | Layout/LayoutJoin.cpp | 38 | ||||
-rw-r--r-- | Layout/LayoutJoin.h | 5 | ||||
-rw-r--r-- | Layout/LayoutSurveyGps.cpp | 166 | ||||
-rw-r--r-- | Layout/LayoutSurveyGps.h | 65 |
6 files changed, 450 insertions, 5 deletions
diff --git a/Layout/LayoutData.cpp b/Layout/LayoutData.cpp new file mode 100644 index 0000000..02e29fd --- /dev/null +++ b/Layout/LayoutData.cpp @@ -0,0 +1,104 @@ +/* Copyright (c) <2016> <MultiTech Systems>, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "LayoutData.h" + +LayoutData::LayoutData(DOGS102* lcd) + : Layout(lcd), + _lDr(8, 0, "DR"), + _lPwr(13, 0, "P"), + _lUp(0, 1, "UP Mgn"), + _lGw(10, 1, "Gw"), + _lDown(0, 2, "DWN -"), + _lSurveyFailed(0, 1, "Survey Failed"), + _lDbm(9, 2, "dbm"), + _lAlt(0, 6, "Alt"), + _fId(0, 0, 5), + _fDr(10, 0, 2), + _fPwr(14, 0, 2), + _fUpMargin(7, 1, 2), + _fGw(13, 1, 2), + _fRssiDown(5, 2, 3), + _fSnrDown(13, 2, 4), + _fGpsLat(0, 4, 17), + _fGpsLong(0, 3, 17), + _fGpsTime(0, 5, 17), + _fAlt(4,6,13), + _fSw1(12, 7, 4), + _fSw2(0, 7, 4) +{} + +LayoutData::~LayoutData() {} + +void LayoutData::display(){ + clear(); + startUpdate(); + writeLabel(_lDr); + writeLabel(_lPwr); + endUpdate(); +} + +void LayoutData::noData(){ + clear(); + writeField(_fGpsLong, string(" No Survey Data"), true); +} + +void LayoutData::errorData(){ + clear(); + writeField(_fGpsLong, string(" Error opening,"), true); + writeField(_fGpsLat, string("survey data file."), true); +} + +void LayoutData::updateSw1(string str){ + writeField(_fSw1, str, true); +} + +void LayoutData::updateSw2(string str){ + writeField(_fSw2, str, true); +} + +bool LayoutData::updateAll(singleLine& line){ + clear(); + startUpdate(); + //this data should always exist + writeLabel(_lDr); + writeLabel(_lPwr); + writeField(_fId, line.id, true); + writeField(_fDr, line.dataRate, true); + writeField(_fPwr, line.power, true); + //check if survey pass/fail + if(line.status=="S") { + writeLabel(_lUp); + writeLabel(_lDown); + writeLabel(_lGw); + writeLabel(_lDbm); + writeField(_fGw, line.gateways, true); + writeField(_fUpMargin, line.margin, true); + writeField(_fRssiDown, line.rssiD, true); + writeField(_fSnrDown, line.snrD, true); + } else writeLabel(_lSurveyFailed); + //check if gps data exists + if(line.lock!="0") { + writeLabel(_lAlt); + writeField(_fGpsLat, line.lat, true); + writeField(_fGpsLong, line.lng, true); + writeField(_fGpsTime, line.time, true); + writeField(_fAlt, line.alt + " m", true); + } else writeField(_fGpsLong, string("No GPS Data"), true); + endUpdate(); +} diff --git a/Layout/LayoutData.h b/Layout/LayoutData.h new file mode 100644 index 0000000..ec91583 --- /dev/null +++ b/Layout/LayoutData.h @@ -0,0 +1,77 @@ +/* Copyright (c) <2016> <MultiTech Systems>, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __LAYOUTDATA_H__ +#define __LAYOUTDATA_H__ + +#include "Layout.h" + +class LayoutData : public Layout{ +public: + LayoutData(DOGS102* lcd); + ~LayoutData(); + + struct singleLine { + string id, + status, + lock, + lat, + lng, + alt, + time, + gateways, + margin, + rssiD, + snrD, + dataRate, + power; + } ; + + void display(); + void noData(); + void noGps(); + void errorData(); + void updateSw1(string str); + void updateSw2(string str); + bool updateAll(singleLine& line); + +private: + Label _lDr; + Label _lPwr; + Label _lUp; + Label _lGw; + Label _lDown; + Label _lDbm; + Label _lSurveyFailed; + Label _lAlt; + + Field _fId; + Field _fDr; + Field _fPwr; + Field _fUpMargin; + Field _fRssiDown; + Field _fSnrDown; + Field _fGpsLat; + Field _fGpsLong; + Field _fGpsTime; + Field _fGw; + Field _fAlt; + Field _fSw1; + Field _fSw2; +}; +#endif diff --git a/Layout/LayoutJoin.cpp b/Layout/LayoutJoin.cpp index e115773..a0ec1ee 100644 --- a/Layout/LayoutJoin.cpp +++ b/Layout/LayoutJoin.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) <2016> <MultiTech Systems>, MIT License +/* /* Copyright (c) <2016> <MultiTech Systems>, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, @@ -75,8 +75,12 @@ void LayoutJoin::updateFsb(uint8_t band) { writeField(_fFsb, buf, size, true); } -void LayoutJoin::updateRate(std::string rate) { - writeField(_fRate, rate, true); +void LayoutJoin::updateRate(uint8_t rate) { + char buf[8]; + size_t size; + + size = snprintf(buf, sizeof(buf), "%u", rate); + writeField(_fRate, buf, size, true); } void LayoutJoin::updatePower(uint32_t power) { @@ -119,3 +123,31 @@ void LayoutJoin::displayCancel(bool display) { writeField(_fCancel, str, true); } +void LayoutJoin::updateJoinFsb(uint8_t band) { + char buf[8]; + size_t size; + + size = snprintf(buf, sizeof(buf), "%u", band); + writeField(_fFsb, buf, size, true); + size = snprintf(buf, sizeof(buf), " %u", band); + writeField(_fCancel, buf, size, true); +} + +void LayoutJoin::displayEditFsb(uint8_t rate, uint32_t power, uint8_t band, string key, string id){ + clear(); + startUpdate(); + + writeLabel(_lId); + writeLabel(_lKey); + writeLabel(_lFsb); + writeLabel(_lRate); + writeLabel(_lPower); + writeField(_fCountdown, string("Join"), true); + updateId(id); + updateKey(key); + updateJoinFsb(band); + updateRate(rate); + updatePower(power); + + endUpdate(); +} diff --git a/Layout/LayoutJoin.h b/Layout/LayoutJoin.h index 56cea3f..c493ce2 100644 --- a/Layout/LayoutJoin.h +++ b/Layout/LayoutJoin.h @@ -28,11 +28,13 @@ class LayoutJoin : public Layout { ~LayoutJoin(); void display(); + void displayEditFsb(uint8_t rate, uint32_t power, uint8_t band, string key, string id); void updateId(std::string id); void updateKey(std::string key); void updateFsb(uint8_t band); - void updateRate(std::string rate); + void updateJoinFsb(uint8_t band); + void updateRate(uint8_t rate); void updatePower(uint32_t power); void updateAttempt(uint32_t attempt); void updateStatus(std::string status); @@ -59,5 +61,4 @@ class LayoutJoin : public Layout { Field _fCancel; uint8_t _band; }; - #endif diff --git a/Layout/LayoutSurveyGps.cpp b/Layout/LayoutSurveyGps.cpp new file mode 100644 index 0000000..2630566 --- /dev/null +++ b/Layout/LayoutSurveyGps.cpp @@ -0,0 +1,166 @@ +/* Copyright (c) <2016> <MultiTech Systems>, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "LayoutSurveyGps.h" +LayoutSurveyGps::LayoutSurveyGps(DOGS102* lcd, uint8_t band) + : Layout(lcd), + _band(band), + _lDR(8,0,"DR"), + _lFSB(0,0,"FSB"), + _lTemp(8,6,"Temp "), + _lPower(13,0,"P"), + _lPadding(0,6,"Pad"), + _fDr(10,0,2), + _fSw1(13,7,4), + _fSw2(0,7,9), + _fFSB(3,0,1), + _fTemp(13,6,4), + _fPower(14,0,2), + _fNoLink(0,1,17), + _fGpsLat(0,3,17), + _fGpsLon(0,4,17), + _fGpsTime(0,5,17), + _fDownSnr(12,2,5), + _fPadding(4,6,3), + _fDownRssi(0,2,12) +{} + +LayoutSurveyGps::~LayoutSurveyGps() {} + +void LayoutSurveyGps::display() {} + +void LayoutSurveyGps::initial(){ + writeField(_fNoLink, string(" "), true); +} + +void LayoutSurveyGps::display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi, int power, int fsb, int padding, int dr){ + char buf[17]; + size_t size; + clear(); + startUpdate(); + writeLabel(_lDR); + writeLabel(_lTemp); + writeLabel(_lPower); + writeLabel(_lPadding); + + if (_band == mDot::FB_915) { + writeLabel(_lFSB); + } + if(success) { + size = snprintf(buf, sizeof(buf), "DWN %3d dbm", rssi.last); + writeField(_fDownRssi, buf, size); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), " %2.1f", snr.last / 10.0); + writeField(_fDownSnr, buf, size); + } else { + writeField(_fNoLink,string("Send Failed"),true); + } + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d", dr); + writeField(_fDr, buf, size, true); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d", power); + writeField(_fPower, buf, size, true); + + if (_band == mDot::FB_915) { + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d", fsb); + writeField(_fFSB, buf, size, true); + } + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d", padding); + writeField(_fPadding, buf, size, true); + endUpdate(); +} + +void LayoutSurveyGps::updateSw1(string Sw1, string Sw2){ + string temp; + for(int i = Sw1.size(); i<4; i++){ + temp+=" "; + } + temp+=Sw1; + writeField(_fSw1, temp, true); +} + +void LayoutSurveyGps::updateSw2(string Sw2){ + writeField(_fSw2, Sw2, true); +} + +void LayoutSurveyGps::sending(){ + clear(); + writeField(_fGpsLat,string(" Sending..."),true); +} + +void LayoutSurveyGps::sendResult(string str){ + clear(); + writeField(_fGpsLat,str,true); +} + +void LayoutSurveyGps::updateNextCh(int count_down){ + clear(); + size_t size; + char buf[17]; + size = snprintf(buf, sizeof(buf), "Countdown:%d", count_down); + writeField(_fGpsTime, buf, size, true); + writeField(_fGpsLon, string("No Free Channel"), true); +} + +void LayoutSurveyGps::updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp){ + char buf[17]; + size_t size; + startUpdate(); + + if(GPS) { + size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c", + abs(lon.degrees), + lon.minutes, + (lon.seconds * 6) / 1000, + (lon.seconds * 6) % 1000, + (lon.degrees > 0) ? 'E' : 'W'); + writeField(_fGpsLon, buf, size, true); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c", + abs(lat.degrees), + lat.minutes, + (lat.seconds * 6) / 1000, + (lat.seconds * 6) % 1000, + (lat.degrees > 0) ? 'N' : 'S'); + writeField(_fGpsLat, buf, size, true); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%02d:%02d %02d/%02d/%04d", + time.tm_hour, + time.tm_min, + time.tm_mon + 1, + time.tm_mday, + time.tm_year + 1900); + writeField(_fGpsTime, buf, size, true); + + } else { + writeField(_fGpsLon, string("No Gps Lock"), true); + } + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%.1f", temp); + writeField(_fTemp, buf, size, true); + endUpdate(); +} diff --git a/Layout/LayoutSurveyGps.h b/Layout/LayoutSurveyGps.h new file mode 100644 index 0000000..9e3194f --- /dev/null +++ b/Layout/LayoutSurveyGps.h @@ -0,0 +1,65 @@ +/* Copyright (c) <2016> <MultiTech Systems>, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __LAYOUTSURVEYGPS_H__ +#define __LAYOUTSURVEYGPS_H__ + +#include "Layout.h" +#include "GPSPARSER.h" +#include "mDot.h" + +class LayoutSurveyGps : public Layout{ +public: + LayoutSurveyGps(DOGS102* lcd, uint8_t band); + ~LayoutSurveyGps(); + + void display(); + void display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi,int power, int fsb, int padding, int dr); + + void sending(); + void initial(); + void updateSw2(string str); + void sendResult(string str); + void updateNextCh(int count_down); + void updateSw1(string Sw1, string Sw2); + void updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp); + +private: + uint8_t _band; + + Label _lDR; + Label _lFSB; + Label _lTemp; + Label _lPower; + Label _lPadding; + + Field _fDr; + Field _fSw1; + Field _fSw2; + Field _fFSB; + Field _fTemp; + Field _fPower; + Field _fNoLink; + Field _fGpsLat; + Field _fGpsLon; + Field _fGpsTime; + Field _fDownSnr; + Field _fPadding; + Field _fDownRssi; +}; +#endif |