Factory firmware for the MultiTech Dotbox (MTDOT-BOX) and EVB (MTDOT-EVB) products.
Dependencies: NCP5623B GpsParser ISL29011 libmDot-mbed5 MTS-Serial MMA845x DOGS102 MPL3115A2
LayoutSurveyGps.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 "LayoutSurveyGps.h" 00020 LayoutSurveyGps::LayoutSurveyGps(DOGS102* lcd, uint8_t band) 00021 : Layout(lcd), 00022 _band(band), 00023 _lDR(8,0,"DR"), 00024 _lFSB(0,0,"FSB"), 00025 _lTemp(8,6,"Temp "), 00026 _lPower(13,0,"P"), 00027 _lPadding(0,6,"Pad"), 00028 _fDr(10,0,2), 00029 _fSw1(13,7,4), 00030 _fSw2(0,7,9), 00031 _fFSB(3,0,1), 00032 _fTemp(13,6,4), 00033 _fPower(14,0,2), 00034 _fNoLink(0,1,17), 00035 _fGpsLat(0,3,17), 00036 _fGpsLon(0,4,17), 00037 _fGpsTime(0,5,17), 00038 _fDownSnr(12,2,5), 00039 _fPadding(4,6,3), 00040 _fDownRssi(0,2,12) 00041 {} 00042 00043 LayoutSurveyGps::~LayoutSurveyGps() {} 00044 00045 void LayoutSurveyGps::display() {} 00046 00047 void LayoutSurveyGps::initial(){ 00048 writeField(_fNoLink, string(" "), true); 00049 } 00050 00051 void LayoutSurveyGps::display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi, int power, int fsb, int padding, int dr){ 00052 char buf[17]; 00053 size_t size; 00054 clear(); 00055 startUpdate(); 00056 writeLabel(_lDR); 00057 writeLabel(_lTemp); 00058 writeLabel(_lPower); 00059 writeLabel(_lPadding); 00060 00061 if (lora::ChannelPlan::IsPlanFixed(_band)) { 00062 writeLabel(_lFSB); 00063 } 00064 if(success) { 00065 size = snprintf(buf, sizeof(buf), "DWN %3d dbm", rssi.last); 00066 writeField(_fDownRssi, buf, size); 00067 00068 memset(buf, 0, sizeof(buf)); 00069 size = snprintf(buf, sizeof(buf), " %2.1f", snr.last / 10.0); 00070 writeField(_fDownSnr, buf, size); 00071 } else { 00072 writeField(_fNoLink,string("Send Failed"),true); 00073 } 00074 00075 memset(buf, 0, sizeof(buf)); 00076 size = snprintf(buf, sizeof(buf), "%d", dr); 00077 writeField(_fDr, buf, size, true); 00078 00079 memset(buf, 0, sizeof(buf)); 00080 size = snprintf(buf, sizeof(buf), "%d", power); 00081 writeField(_fPower, buf, size, true); 00082 00083 if (lora::ChannelPlan::IsPlanFixed(_band)) { 00084 memset(buf, 0, sizeof(buf)); 00085 size = snprintf(buf, sizeof(buf), "%d", fsb); 00086 writeField(_fFSB, buf, size, true); 00087 } 00088 00089 memset(buf, 0, sizeof(buf)); 00090 size = snprintf(buf, sizeof(buf), "%d", padding); 00091 writeField(_fPadding, buf, size, true); 00092 endUpdate(); 00093 } 00094 00095 void LayoutSurveyGps::updateSw1(string Sw1, string Sw2){ 00096 string temp; 00097 for(int i = Sw1.size(); i<4; i++){ 00098 temp+=" "; 00099 } 00100 temp+=Sw1; 00101 writeField(_fSw1, temp, true); 00102 } 00103 00104 void LayoutSurveyGps::updateSw2(string Sw2){ 00105 writeField(_fSw2, Sw2, true); 00106 } 00107 00108 void LayoutSurveyGps::sending(){ 00109 clear(); 00110 writeField(_fGpsLat,string(" Sending..."),true); 00111 } 00112 00113 void LayoutSurveyGps::sendResult(string str){ 00114 clear(); 00115 writeField(_fGpsLat,str,true); 00116 } 00117 00118 void LayoutSurveyGps::updateNextCh(int count_down){ 00119 clear(); 00120 size_t size; 00121 char buf[17]; 00122 size = snprintf(buf, sizeof(buf), "Countdown:%d", count_down); 00123 writeField(_fGpsTime, buf, size, true); 00124 writeField(_fGpsLon, string("No Free Channel"), true); 00125 } 00126 00127 void LayoutSurveyGps::updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp){ 00128 char buf[17]; 00129 size_t size; 00130 startUpdate(); 00131 00132 if(GPS) { 00133 size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c", 00134 (int) abs(lon.degrees), 00135 (int)lon.minutes, 00136 (int)(lon.seconds * 6) / 1000, 00137 (int)(lon.seconds * 6) % 1000, 00138 (lon.degrees > 0) ? 'E' : 'W'); 00139 writeField(_fGpsLon, buf, size, true); 00140 00141 memset(buf, 0, sizeof(buf)); 00142 size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c", 00143 (int)abs(lat.degrees), 00144 (int)lat.minutes, 00145 (int)(lat.seconds * 6) / 1000, 00146 (int)(lat.seconds * 6) % 1000, 00147 (lat.degrees > 0) ? 'N' : 'S'); 00148 writeField(_fGpsLat, buf, size, true); 00149 00150 memset(buf, 0, sizeof(buf)); 00151 size = snprintf(buf, sizeof(buf), "%02d:%02d %02d/%02d/%04d", 00152 time.tm_hour, 00153 time.tm_min, 00154 time.tm_mon + 1, 00155 time.tm_mday, 00156 time.tm_year + 1900); 00157 writeField(_fGpsTime, buf, size, true); 00158 00159 } else { 00160 writeField(_fGpsLon, string("No Gps Lock"), true); 00161 } 00162 memset(buf, 0, sizeof(buf)); 00163 size = snprintf(buf, sizeof(buf), "%.1f", temp); 00164 writeField(_fTemp, buf, size, true); 00165 endUpdate(); 00166 }
Generated on Tue Jul 12 2022 17:02:18 by 1.7.2