Custom Channel Plan version of MTDOT Box firmware
Dependencies: DOGS102 GpsParser ISL29011 MMA845x MPL3115A2 MTS-Serial NCP5623B libmDot-Custom mDot_Channel_Plans
Fork of MTDOT-BOX-EVB-Factory-Firmware by
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 void LayoutSurveySuccess::display() { 00046 clear(); 00047 startUpdate(); 00048 00049 writeLabel(_lId); 00050 writeLabel(_lDr); 00051 writeLabel(_lPwr); 00052 writeLabel(_lUp); 00053 writeLabel(_lDown); 00054 00055 endUpdate(); 00056 } 00057 00058 void LayoutSurveySuccess::updateId(uint32_t id) { 00059 char buf[16]; 00060 size_t size; 00061 00062 size = snprintf(buf, sizeof(buf), "%lu", id); 00063 writeField(_fId, buf, size, true); 00064 } 00065 00066 void LayoutSurveySuccess::updateRate(std::string rate) { 00067 writeField(_fDr, rate, true); 00068 } 00069 00070 void LayoutSurveySuccess::updatePower(uint32_t power) { 00071 char buf[16]; 00072 size_t size; 00073 00074 size = snprintf(buf, sizeof(buf), "%lu", power); 00075 writeField(_fPwr, buf, size, true); 00076 } 00077 00078 void LayoutSurveySuccess::updateStats(LoRaHandler::LoRaLink link) { 00079 char buf[16]; 00080 size_t size; 00081 00082 startUpdate(); 00083 00084 size = snprintf(buf, sizeof(buf), "%d", link.up.dBm); 00085 writeField(_fUpMargin, buf, size); 00086 00087 memset(buf, 0, sizeof(buf)); 00088 size = snprintf(buf, sizeof(buf), "%3d dbm", link.down.rssi); 00089 writeField(_fDownRssi, buf, size); 00090 00091 memset(buf, 0, sizeof(buf)); 00092 size = snprintf(buf, sizeof(buf), "%2.1f", (float)link.down.snr / 10.0); 00093 writeField(_fDownSnr, buf, size); 00094 00095 endUpdate(); 00096 } 00097 00098 void LayoutSurveySuccess::updateGpsLatitude(GPSPARSER::latitude lat) { 00099 char buf[32]; 00100 size_t size; 00101 00102 size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c", 00103 abs(lat.degrees), 00104 lat.minutes, 00105 (lat.seconds * 6) / 1000, 00106 (lat.seconds * 6) % 1000, 00107 (lat.degrees > 0) ? 'N' : 'S'); 00108 writeField(_fGpsLat, buf, size, true); 00109 } 00110 00111 void LayoutSurveySuccess::updateGpsLatitude(std::string msg) { 00112 writeField(_fGpsLat, msg, true); 00113 } 00114 00115 void LayoutSurveySuccess::updateGpsLongitude(GPSPARSER::longitude lon) { 00116 char buf[32]; 00117 size_t size; 00118 00119 size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c", 00120 abs(lon.degrees), 00121 lon.minutes, 00122 (lon.seconds * 6) / 1000, 00123 (lon.seconds * 6) % 1000, 00124 (lon.degrees > 0) ? 'E' : 'W'); 00125 writeField(_fGpsLon, buf, size, true); 00126 } 00127 00128 void LayoutSurveySuccess::updateGpsTime(struct tm time) { 00129 char buf[32]; 00130 size_t size; 00131 00132 size = snprintf(buf, sizeof(buf), "%02d:%02d %02d/%02d/%04d", 00133 time.tm_hour, 00134 time.tm_min, 00135 time.tm_mon + 1, 00136 time.tm_mday, 00137 time.tm_year + 1900); 00138 writeField(_fGpsTime, buf, size, true); 00139 } 00140 00141 void LayoutSurveySuccess::updateInfo(std::string info) { 00142 writeField(_fInfo, info, true); 00143 } 00144 00145 void LayoutSurveySuccess::updateSw1(std::string sw1) { 00146 writeField(_fSw1, sw1, true); 00147 } 00148 00149 void LayoutSurveySuccess::updateSw2(std::string sw2) { 00150 writeField(_fSw2, sw2, true); 00151 } 00152 00153 void LayoutSurveySuccess::updateCountdown(uint32_t seconds) { 00154 char buf[32]; 00155 size_t size; 00156 00157 // make sure the string version is used 00158 writeField(_fInfo, string("No Free Channel"), true); 00159 size = snprintf(buf, sizeof(buf), "%lu s", seconds); 00160 writeField(_fSw2, buf, size, true); 00161 } 00162 00163 void LayoutSurveySuccess::updatePassFail(uint8_t pass, uint8_t fail) { 00164 char buf[32]; 00165 size_t size; 00166 00167 size = snprintf(buf, sizeof(buf), "Pass %u Fail %u", pass, fail); 00168 writeField(_fGpsTime, buf, size, true); 00169 } 00170
Generated on Tue Jul 12 2022 13:07:49 by 1.7.2