Scott Hoppe / Mbed OS 4_Ecolab_RSSI_Checker

Dependencies:   DOGS102 GpsParser ISL29011 MMA845x MPL3115A2 MTS-Serial NCP5623B libmDot-dev-mbed5-deprecated

Fork of MTDOT-BOX-EVB-Factory-Firmware by MultiTech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LayoutSurveySuccess.cpp Source File

LayoutSurveySuccess.cpp

00001 /* Copyright (c) <2016> <MultiTech Systems>, MIT License
00002  *
00003  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
00004  * and associated documentation files (the "Software"), to deal in the Software without restriction, 
00005  * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
00006  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
00007  * furnished to do so, subject to the following conditions:
00008  *
00009  * The above copyright notice and this permission notice shall be included in all copies or 
00010  * substantial portions of the Software.
00011  *
00012  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
00013  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
00014  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
00015  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
00016  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017  */
00018 
00019 #include "LayoutSurveySuccess.h"
00020 #include "MTSLog.h"
00021 
00022 LayoutSurveySuccess::LayoutSurveySuccess(DOGS102* lcd)
00023   : Layout(lcd),
00024     _lId(0, 0, "ID"),
00025     _lDr(8, 0, "DR"),
00026     _lPwr(13, 0, "P"),
00027     _lUp(0, 1, "UP Margin"),
00028     _lDown(0, 2, "DWN"),
00029     _fId(2, 0, 5),
00030     _fDr(10, 0, 2),
00031     _fPwr(14, 0, 2),
00032     _fUpMargin(10, 1, 5),
00033     _fDownRssi(4, 2, 7),
00034     _fDownSnr(12, 2, 5),
00035     _fGpsLat(0, 4, 17),
00036     _fGpsLon(0, 3, 17),
00037     _fGpsTime(0, 5, 17),
00038     _fInfo(0, 6, 17),
00039     _fSw1(9, 7, 8),
00040     _fSw2(0, 7, 8)
00041 {}
00042 
00043 LayoutSurveySuccess::~LayoutSurveySuccess() {}
00044 
00045 
00046 
00047 void LayoutSurveySuccess::display() {
00048     clear();
00049     startUpdate();
00050 
00051     //writeLabel(_lId);
00052    // writeLabel(_lDr);
00053    // writeLabel(_lPwr);
00054     writeLabel(_lUp);
00055     writeLabel(_lDown);
00056 
00057     endUpdate();
00058 }
00059 
00060 void LayoutSurveySuccess::updateId(uint32_t id) {
00061     char buf[16];
00062     size_t size;
00063 
00064     size = snprintf(buf, sizeof(buf), "%lu", id);
00065     //writeField(_fId, buf, size, true);
00066 }
00067 
00068 void LayoutSurveySuccess::updateRate(std::string rate) {
00069     writeField(_fDr, rate, true);
00070 }
00071 
00072 void LayoutSurveySuccess::updatePower(uint32_t power) {
00073     char buf[16];
00074     size_t size;
00075 
00076     size = snprintf(buf, sizeof(buf), "%lu", power);
00077     //writeField(_fPwr, buf, size, true);
00078 }
00079 
00080 void LayoutSurveySuccess::updateStats(LoRaHandler::LoRaLink link) {
00081     char buf[16];
00082     size_t size;
00083 
00084     startUpdate();
00085 //__________________________________________________RSSI HERER!!!!_______________________________________________________
00086     size = snprintf(buf, sizeof(buf), "%d", link.up.dBm);
00087     writeField(_fUpMargin, buf, size);
00088 
00089     memset(buf, 0, sizeof(buf));
00090     size = snprintf(buf, sizeof(buf), "%3d dbm", link.down.rssi);
00091     writeField(_fDownRssi, buf, size);
00092 
00093     memset(buf, 0, sizeof(buf));
00094     size = snprintf(buf, sizeof(buf), "%2.1f", (float)link.down.snr / 10.0);
00095     writeField(_fDownSnr, buf, size);
00096 
00097     endUpdate();
00098 }
00099 
00100 void LayoutSurveySuccess::updateGpsLatitude(GPSPARSER::latitude lat) {
00101     char buf[32];
00102     size_t size;
00103 
00104     size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c",
00105         abs(lat.degrees),
00106         lat.minutes,
00107         (lat.seconds * 6) / 1000,
00108         (lat.seconds * 6) % 1000,
00109         (lat.degrees > 0) ? 'N' : 'S');
00110     writeField(_fGpsLat, buf, size, true);
00111 }
00112 
00113 void LayoutSurveySuccess::updateGpsLatitude(std::string msg) {
00114     writeField(_fGpsLat, msg, true);
00115 }
00116 
00117 void LayoutSurveySuccess::updateGpsLongitude(GPSPARSER::longitude lon) {
00118     char buf[32];
00119     size_t size;
00120 
00121     size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c",
00122         abs(lon.degrees),
00123         lon.minutes,
00124         (lon.seconds * 6) / 1000,
00125         (lon.seconds * 6) % 1000,
00126         (lon.degrees > 0) ? 'E' : 'W');
00127     writeField(_fGpsLon, buf, size, true);
00128 }
00129 
00130 void LayoutSurveySuccess::updateGpsTime(struct tm time) {
00131     char buf[32];
00132     size_t size;
00133 
00134     size = snprintf(buf, sizeof(buf), "%02d:%02d %02d/%02d/%04d",
00135         time.tm_hour,
00136         time.tm_min,
00137         time.tm_mon + 1,
00138         time.tm_mday,
00139         time.tm_year + 1900);
00140     writeField(_fGpsTime, buf, size, true);
00141 }
00142 
00143 void LayoutSurveySuccess::updateInfo(std::string info) {
00144     writeField(_fInfo, info, true);
00145 }
00146 
00147 void LayoutSurveySuccess::updateSw1(std::string sw1) {
00148     writeField(_fSw1, sw1, true);
00149 }
00150 
00151 void LayoutSurveySuccess::updateSw2(std::string sw2) {
00152     writeField(_fSw2, sw2, true);
00153 }
00154 
00155 void LayoutSurveySuccess::updateCountdown(uint32_t seconds) {
00156     char buf[32];
00157     size_t size;
00158 
00159     // make sure the string version is used
00160     writeField(_fInfo, string("No Free Channel"), true);
00161     size = snprintf(buf, sizeof(buf), "%lu s", seconds);
00162     writeField(_fSw2, buf, size, true);
00163 }
00164 
00165 void LayoutSurveySuccess::updatePassFail(uint8_t pass, uint8_t fail) {
00166     char buf[32];
00167     size_t size;
00168 
00169     size = snprintf(buf, sizeof(buf), "Pass %u Fail %u", pass, fail);
00170     writeField(_fGpsTime, buf, size, true);
00171 }
00172