Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DOGS102 GpsParser ISL29011 MMA845x MPL3115A2 MTS-Serial NCP5623B libmDot-dev-mbed5-deprecated
Fork of MTDOT-BOX-EVB-Factory-Firmware by
LayoutSemtech.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 "LayoutSemtech.h" 00020 00021 00022 LayoutSemtech::LayoutSemtech(DOGS102* lcd, uint8_t band) 00023 : Layout(lcd), 00024 _band(band), 00025 _lDr(8,0,"DR"), 00026 _lFSB(0,0,"FSB"), 00027 _lSend(3,3,"Sending..."), 00028 _lTemp(8,6,"Temp "), 00029 _lNoGps(0,4,"No Gps Lock"), 00030 _lPower(13,0,"P"), 00031 _lBlank(0,1," "), 00032 _lNoLink(0,1,"Send Failed"), 00033 _lPadding(0,6,"Pad"), 00034 _lNoChannel(0,3,"No Free Channel"), 00035 _fDr(10,0,2), 00036 _fSw1(13,7,4), 00037 _fSw2(0,7,9), 00038 _fFSB(3,0,1), 00039 _fTemp(13,6,4), 00040 _fPower(14,0,2), 00041 _fNextCh(0,5,17), 00042 _fGpsLat(0,3,17), 00043 _fGpsLon(0,4,17), 00044 _fResult(3,3,16), 00045 _fGpsTime(0,5,16), 00046 _fDownSnr(12,2,5), 00047 _fPadding(4,6,3), 00048 _fDownRssi(0,2,11) 00049 {} 00050 00051 LayoutSemtech::~LayoutSemtech() {} 00052 00053 void LayoutSemtech::display() {} 00054 00055 void LayoutSemtech::initial() 00056 { 00057 writeLabel(_lBlank); 00058 } 00059 00060 void LayoutSemtech::display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi, int power, int fsb, int padding, int dr) 00061 { 00062 char buf[17]; 00063 size_t size; 00064 00065 clear(); 00066 startUpdate(); 00067 00068 writeLabel(_lDr); 00069 writeLabel(_lTemp); 00070 writeLabel(_lPower); 00071 writeLabel(_lPadding); 00072 00073 if (_band == mDot::FB_US915 || _band == mDot::FB_AU915) { 00074 writeLabel(_lFSB); 00075 } 00076 00077 if(success) { 00078 size = snprintf(buf, sizeof(buf), "DWN %3d dbm", rssi.last); 00079 writeField(_fDownRssi, buf, size); 00080 00081 memset(buf, 0, sizeof(buf)); 00082 size = snprintf(buf, sizeof(buf), " %2.1f", (float)snr.last / 10.0); 00083 writeField(_fDownSnr, buf, size); 00084 } else { 00085 writeLabel(_lNoLink); 00086 } 00087 00088 memset(buf, 0, sizeof(buf)); 00089 size = snprintf(buf, sizeof(buf), "%d",dr); 00090 writeField(_fDr, buf, size, true); 00091 00092 memset(buf, 0, sizeof(buf)); 00093 size = snprintf(buf, sizeof(buf), "%d",power); 00094 writeField(_fPower, buf, size, true); 00095 00096 if (_band == mDot::FB_US915 || _band == mDot::FB_AU915) { 00097 memset(buf, 0, sizeof(buf)); 00098 size = snprintf(buf, sizeof(buf), "%d",fsb); 00099 writeField(_fFSB, buf, size, true); 00100 } 00101 00102 memset(buf, 0, sizeof(buf)); 00103 size = snprintf(buf, sizeof(buf), "%d",padding); 00104 writeField(_fPadding, buf, size, true); 00105 00106 endUpdate(); 00107 } 00108 00109 void LayoutSemtech::updateSw1(string Sw1, string Sw2, int dr, int power, int padding) 00110 { 00111 size_t size; 00112 char buf[17]; 00113 string temp; 00114 for(int i = Sw1.size(); i<4; i++) temp+=" "; 00115 temp+=Sw1; 00116 writeField(_fSw1, temp, true); 00117 startUpdate(); 00118 if(Sw2=="Data Rate") { 00119 memset(buf, 0, sizeof(buf)); 00120 size = snprintf(buf, sizeof(buf), "%d",dr); 00121 writeField(_fDr, buf, size, true); 00122 } else if(Sw2=="Power") { 00123 memset(buf, 0, sizeof(buf)); 00124 size = snprintf(buf, sizeof(buf), "%d",power); 00125 writeField(_fPower, buf, size, true); 00126 } else if(Sw2=="Padding") { 00127 memset(buf, 0, sizeof(buf)); 00128 size = snprintf(buf, sizeof(buf), "%d",padding); 00129 writeField(_fPadding, buf, size, true); 00130 } 00131 endUpdate(); 00132 } 00133 00134 void LayoutSemtech::updateSw2(string Sw2) 00135 { 00136 writeField(_fSw2, Sw2, true); 00137 } 00138 00139 void LayoutSemtech::sending() 00140 { 00141 clear(); 00142 writeLabel(_lSend); 00143 } 00144 00145 void LayoutSemtech::sendResult(string str) 00146 { 00147 clear(); 00148 writeField(_fResult,str,true); 00149 } 00150 00151 00152 void LayoutSemtech::updateNextCh(int count_down) 00153 { 00154 clear(); 00155 size_t size; 00156 char buf[17]; 00157 size = snprintf(buf, sizeof(buf), "Countdown:%d",count_down); 00158 writeField(_fNextCh, buf, size, true); 00159 writeLabel(_lNoChannel); 00160 } 00161 00162 void LayoutSemtech::updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp) 00163 { 00164 char buf[17]; 00165 size_t size; 00166 00167 startUpdate(); 00168 00169 if(GPS) { 00170 size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c", 00171 abs(lon.degrees), 00172 lon.minutes, 00173 (lon.seconds * 6) / 1000, 00174 (lon.seconds * 6) % 1000, 00175 (lon.degrees > 0) ? 'E' : 'W'); 00176 writeField(_fGpsLon, buf, size, true); 00177 00178 memset(buf, 0, sizeof(buf)); 00179 size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c", 00180 abs(lat.degrees), 00181 lat.minutes, 00182 (lat.seconds * 6) / 1000, 00183 (lat.seconds * 6) % 1000, 00184 (lat.degrees > 0) ? 'N' : 'S'); 00185 writeField(_fGpsLat, buf, size, true); 00186 00187 memset(buf, 0, sizeof(buf)); 00188 size = snprintf(buf, sizeof(buf), "%02d:%02d %02d/%02d/%04d", 00189 time.tm_hour, 00190 time.tm_min, 00191 time.tm_mon + 1, 00192 time.tm_mday, 00193 time.tm_year + 1900); 00194 writeField(_fGpsTime, buf, size, true); 00195 00196 } else writeLabel(_lNoGps); 00197 00198 memset(buf, 0, sizeof(buf)); 00199 size = snprintf(buf, sizeof(buf), "%.1f",temp); 00200 writeField(_fTemp, buf, size, true); 00201 00202 endUpdate(); 00203 } 00204
Generated on Wed Jul 13 2022 01:58:37 by
1.7.2
