Custom "Installer Assistant" software. Modified Single Sweep Mode. Goes right into single sweep mode upon power-up and displays signal strength. Works with mbed-os 5.1.2 and mdot lib 5.1.5

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

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

Committer:
Mike Fiore
Date:
Fri Nov 04 17:27:05 2016 -0500
Revision:
7:a31236c2e75c
update from git revision 2.1.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 7:a31236c2e75c 1 /* Copyright (c) <2016> <MultiTech Systems>, MIT License
Mike Fiore 7:a31236c2e75c 2 *
Mike Fiore 7:a31236c2e75c 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
Mike Fiore 7:a31236c2e75c 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
Mike Fiore 7:a31236c2e75c 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
Mike Fiore 7:a31236c2e75c 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Mike Fiore 7:a31236c2e75c 7 * furnished to do so, subject to the following conditions:
Mike Fiore 7:a31236c2e75c 8 *
Mike Fiore 7:a31236c2e75c 9 * The above copyright notice and this permission notice shall be included in all copies or
Mike Fiore 7:a31236c2e75c 10 * substantial portions of the Software.
Mike Fiore 7:a31236c2e75c 11 *
Mike Fiore 7:a31236c2e75c 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
Mike Fiore 7:a31236c2e75c 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Mike Fiore 7:a31236c2e75c 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
Mike Fiore 7:a31236c2e75c 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Mike Fiore 7:a31236c2e75c 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Mike Fiore 7:a31236c2e75c 17 */
Mike Fiore 7:a31236c2e75c 18
Mike Fiore 7:a31236c2e75c 19 #include "LayoutSemtech.h"
Mike Fiore 7:a31236c2e75c 20
Mike Fiore 7:a31236c2e75c 21
Mike Fiore 7:a31236c2e75c 22 LayoutSemtech::LayoutSemtech(DOGS102* lcd, uint8_t band)
Mike Fiore 7:a31236c2e75c 23 : Layout(lcd),
Mike Fiore 7:a31236c2e75c 24 _band(band),
Mike Fiore 7:a31236c2e75c 25 _lDr(8,0,"DR"),
Mike Fiore 7:a31236c2e75c 26 _lFSB(0,0,"FSB"),
Mike Fiore 7:a31236c2e75c 27 _lSend(3,3,"Sending..."),
Mike Fiore 7:a31236c2e75c 28 _lTemp(8,6,"Temp "),
Mike Fiore 7:a31236c2e75c 29 _lNoGps(0,4,"No Gps Lock"),
Mike Fiore 7:a31236c2e75c 30 _lPower(13,0,"P"),
Mike Fiore 7:a31236c2e75c 31 _lBlank(0,1," "),
Mike Fiore 7:a31236c2e75c 32 _lNoLink(0,1,"Send Failed"),
Mike Fiore 7:a31236c2e75c 33 _lPadding(0,6,"Pad"),
Mike Fiore 7:a31236c2e75c 34 _lNoChannel(0,3,"No Free Channel"),
Mike Fiore 7:a31236c2e75c 35 _fDr(10,0,2),
Mike Fiore 7:a31236c2e75c 36 _fSw1(13,7,4),
Mike Fiore 7:a31236c2e75c 37 _fSw2(0,7,9),
Mike Fiore 7:a31236c2e75c 38 _fFSB(3,0,1),
Mike Fiore 7:a31236c2e75c 39 _fTemp(13,6,4),
Mike Fiore 7:a31236c2e75c 40 _fPower(14,0,2),
Mike Fiore 7:a31236c2e75c 41 _fNextCh(0,5,17),
Mike Fiore 7:a31236c2e75c 42 _fGpsLat(0,3,17),
Mike Fiore 7:a31236c2e75c 43 _fGpsLon(0,4,17),
Mike Fiore 7:a31236c2e75c 44 _fResult(3,3,16),
Mike Fiore 7:a31236c2e75c 45 _fGpsTime(0,5,16),
Mike Fiore 7:a31236c2e75c 46 _fDownSnr(12,2,5),
Mike Fiore 7:a31236c2e75c 47 _fPadding(4,6,3),
Mike Fiore 7:a31236c2e75c 48 _fDownRssi(0,2,11)
Mike Fiore 7:a31236c2e75c 49 {}
Mike Fiore 7:a31236c2e75c 50
Mike Fiore 7:a31236c2e75c 51 LayoutSemtech::~LayoutSemtech() {}
Mike Fiore 7:a31236c2e75c 52
Mike Fiore 7:a31236c2e75c 53 void LayoutSemtech::display() {}
Mike Fiore 7:a31236c2e75c 54
Mike Fiore 7:a31236c2e75c 55 void LayoutSemtech::initial()
Mike Fiore 7:a31236c2e75c 56 {
Mike Fiore 7:a31236c2e75c 57 writeLabel(_lBlank);
Mike Fiore 7:a31236c2e75c 58 }
Mike Fiore 7:a31236c2e75c 59
Mike Fiore 7:a31236c2e75c 60 void LayoutSemtech::display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi, int power, int fsb, int padding, int dr)
Mike Fiore 7:a31236c2e75c 61 {
Mike Fiore 7:a31236c2e75c 62 char buf[17];
Mike Fiore 7:a31236c2e75c 63 size_t size;
Mike Fiore 7:a31236c2e75c 64
Mike Fiore 7:a31236c2e75c 65 clear();
Mike Fiore 7:a31236c2e75c 66 startUpdate();
Mike Fiore 7:a31236c2e75c 67
Mike Fiore 7:a31236c2e75c 68 writeLabel(_lDr);
Mike Fiore 7:a31236c2e75c 69 writeLabel(_lTemp);
Mike Fiore 7:a31236c2e75c 70 writeLabel(_lPower);
Mike Fiore 7:a31236c2e75c 71 writeLabel(_lPadding);
Mike Fiore 7:a31236c2e75c 72
Mike Fiore 7:a31236c2e75c 73 if (_band == mDot::FB_US915 || _band == mDot::FB_AU915) {
Mike Fiore 7:a31236c2e75c 74 writeLabel(_lFSB);
Mike Fiore 7:a31236c2e75c 75 }
Mike Fiore 7:a31236c2e75c 76
Mike Fiore 7:a31236c2e75c 77 if(success) {
Mike Fiore 7:a31236c2e75c 78 size = snprintf(buf, sizeof(buf), "DWN %3d dbm", rssi.last);
Mike Fiore 7:a31236c2e75c 79 writeField(_fDownRssi, buf, size);
Mike Fiore 7:a31236c2e75c 80
Mike Fiore 7:a31236c2e75c 81 memset(buf, 0, sizeof(buf));
Mike Fiore 7:a31236c2e75c 82 size = snprintf(buf, sizeof(buf), " %2.1f", (float)snr.last / 10.0);
Mike Fiore 7:a31236c2e75c 83 writeField(_fDownSnr, buf, size);
Mike Fiore 7:a31236c2e75c 84 } else {
Mike Fiore 7:a31236c2e75c 85 writeLabel(_lNoLink);
Mike Fiore 7:a31236c2e75c 86 }
Mike Fiore 7:a31236c2e75c 87
Mike Fiore 7:a31236c2e75c 88 memset(buf, 0, sizeof(buf));
Mike Fiore 7:a31236c2e75c 89 size = snprintf(buf, sizeof(buf), "%d",dr);
Mike Fiore 7:a31236c2e75c 90 writeField(_fDr, buf, size, true);
Mike Fiore 7:a31236c2e75c 91
Mike Fiore 7:a31236c2e75c 92 memset(buf, 0, sizeof(buf));
Mike Fiore 7:a31236c2e75c 93 size = snprintf(buf, sizeof(buf), "%d",power);
Mike Fiore 7:a31236c2e75c 94 writeField(_fPower, buf, size, true);
Mike Fiore 7:a31236c2e75c 95
Mike Fiore 7:a31236c2e75c 96 if (_band == mDot::FB_US915 || _band == mDot::FB_AU915) {
Mike Fiore 7:a31236c2e75c 97 memset(buf, 0, sizeof(buf));
Mike Fiore 7:a31236c2e75c 98 size = snprintf(buf, sizeof(buf), "%d",fsb);
Mike Fiore 7:a31236c2e75c 99 writeField(_fFSB, buf, size, true);
Mike Fiore 7:a31236c2e75c 100 }
Mike Fiore 7:a31236c2e75c 101
Mike Fiore 7:a31236c2e75c 102 memset(buf, 0, sizeof(buf));
Mike Fiore 7:a31236c2e75c 103 size = snprintf(buf, sizeof(buf), "%d",padding);
Mike Fiore 7:a31236c2e75c 104 writeField(_fPadding, buf, size, true);
Mike Fiore 7:a31236c2e75c 105
Mike Fiore 7:a31236c2e75c 106 endUpdate();
Mike Fiore 7:a31236c2e75c 107 }
Mike Fiore 7:a31236c2e75c 108
Mike Fiore 7:a31236c2e75c 109 void LayoutSemtech::updateSw1(string Sw1, string Sw2, int dr, int power, int padding)
Mike Fiore 7:a31236c2e75c 110 {
Mike Fiore 7:a31236c2e75c 111 size_t size;
Mike Fiore 7:a31236c2e75c 112 char buf[17];
Mike Fiore 7:a31236c2e75c 113 string temp;
Mike Fiore 7:a31236c2e75c 114 for(int i = Sw1.size(); i<4; i++) temp+=" ";
Mike Fiore 7:a31236c2e75c 115 temp+=Sw1;
Mike Fiore 7:a31236c2e75c 116 writeField(_fSw1, temp, true);
Mike Fiore 7:a31236c2e75c 117 startUpdate();
Mike Fiore 7:a31236c2e75c 118 if(Sw2=="Data Rate") {
Mike Fiore 7:a31236c2e75c 119 memset(buf, 0, sizeof(buf));
Mike Fiore 7:a31236c2e75c 120 size = snprintf(buf, sizeof(buf), "%d",dr);
Mike Fiore 7:a31236c2e75c 121 writeField(_fDr, buf, size, true);
Mike Fiore 7:a31236c2e75c 122 } else if(Sw2=="Power") {
Mike Fiore 7:a31236c2e75c 123 memset(buf, 0, sizeof(buf));
Mike Fiore 7:a31236c2e75c 124 size = snprintf(buf, sizeof(buf), "%d",power);
Mike Fiore 7:a31236c2e75c 125 writeField(_fPower, buf, size, true);
Mike Fiore 7:a31236c2e75c 126 } else if(Sw2=="Padding") {
Mike Fiore 7:a31236c2e75c 127 memset(buf, 0, sizeof(buf));
Mike Fiore 7:a31236c2e75c 128 size = snprintf(buf, sizeof(buf), "%d",padding);
Mike Fiore 7:a31236c2e75c 129 writeField(_fPadding, buf, size, true);
Mike Fiore 7:a31236c2e75c 130 }
Mike Fiore 7:a31236c2e75c 131 endUpdate();
Mike Fiore 7:a31236c2e75c 132 }
Mike Fiore 7:a31236c2e75c 133
Mike Fiore 7:a31236c2e75c 134 void LayoutSemtech::updateSw2(string Sw2)
Mike Fiore 7:a31236c2e75c 135 {
Mike Fiore 7:a31236c2e75c 136 writeField(_fSw2, Sw2, true);
Mike Fiore 7:a31236c2e75c 137 }
Mike Fiore 7:a31236c2e75c 138
Mike Fiore 7:a31236c2e75c 139 void LayoutSemtech::sending()
Mike Fiore 7:a31236c2e75c 140 {
Mike Fiore 7:a31236c2e75c 141 clear();
Mike Fiore 7:a31236c2e75c 142 writeLabel(_lSend);
Mike Fiore 7:a31236c2e75c 143 }
Mike Fiore 7:a31236c2e75c 144
Mike Fiore 7:a31236c2e75c 145 void LayoutSemtech::sendResult(string str)
Mike Fiore 7:a31236c2e75c 146 {
Mike Fiore 7:a31236c2e75c 147 clear();
Mike Fiore 7:a31236c2e75c 148 writeField(_fResult,str,true);
Mike Fiore 7:a31236c2e75c 149 }
Mike Fiore 7:a31236c2e75c 150
Mike Fiore 7:a31236c2e75c 151
Mike Fiore 7:a31236c2e75c 152 void LayoutSemtech::updateNextCh(int count_down)
Mike Fiore 7:a31236c2e75c 153 {
Mike Fiore 7:a31236c2e75c 154 clear();
Mike Fiore 7:a31236c2e75c 155 size_t size;
Mike Fiore 7:a31236c2e75c 156 char buf[17];
Mike Fiore 7:a31236c2e75c 157 size = snprintf(buf, sizeof(buf), "Countdown:%d",count_down);
Mike Fiore 7:a31236c2e75c 158 writeField(_fNextCh, buf, size, true);
Mike Fiore 7:a31236c2e75c 159 writeLabel(_lNoChannel);
Mike Fiore 7:a31236c2e75c 160 }
Mike Fiore 7:a31236c2e75c 161
Mike Fiore 7:a31236c2e75c 162 void LayoutSemtech::updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp)
Mike Fiore 7:a31236c2e75c 163 {
Mike Fiore 7:a31236c2e75c 164 char buf[17];
Mike Fiore 7:a31236c2e75c 165 size_t size;
Mike Fiore 7:a31236c2e75c 166
Mike Fiore 7:a31236c2e75c 167 startUpdate();
Mike Fiore 7:a31236c2e75c 168
Mike Fiore 7:a31236c2e75c 169 if(GPS) {
Mike Fiore 7:a31236c2e75c 170 size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c",
Mike Fiore 7:a31236c2e75c 171 abs(lon.degrees),
Mike Fiore 7:a31236c2e75c 172 lon.minutes,
Mike Fiore 7:a31236c2e75c 173 (lon.seconds * 6) / 1000,
Mike Fiore 7:a31236c2e75c 174 (lon.seconds * 6) % 1000,
Mike Fiore 7:a31236c2e75c 175 (lon.degrees > 0) ? 'E' : 'W');
Mike Fiore 7:a31236c2e75c 176 writeField(_fGpsLon, buf, size, true);
Mike Fiore 7:a31236c2e75c 177
Mike Fiore 7:a31236c2e75c 178 memset(buf, 0, sizeof(buf));
Mike Fiore 7:a31236c2e75c 179 size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c",
Mike Fiore 7:a31236c2e75c 180 abs(lat.degrees),
Mike Fiore 7:a31236c2e75c 181 lat.minutes,
Mike Fiore 7:a31236c2e75c 182 (lat.seconds * 6) / 1000,
Mike Fiore 7:a31236c2e75c 183 (lat.seconds * 6) % 1000,
Mike Fiore 7:a31236c2e75c 184 (lat.degrees > 0) ? 'N' : 'S');
Mike Fiore 7:a31236c2e75c 185 writeField(_fGpsLat, buf, size, true);
Mike Fiore 7:a31236c2e75c 186
Mike Fiore 7:a31236c2e75c 187 memset(buf, 0, sizeof(buf));
Mike Fiore 7:a31236c2e75c 188 size = snprintf(buf, sizeof(buf), "%02d:%02d %02d/%02d/%04d",
Mike Fiore 7:a31236c2e75c 189 time.tm_hour,
Mike Fiore 7:a31236c2e75c 190 time.tm_min,
Mike Fiore 7:a31236c2e75c 191 time.tm_mon + 1,
Mike Fiore 7:a31236c2e75c 192 time.tm_mday,
Mike Fiore 7:a31236c2e75c 193 time.tm_year + 1900);
Mike Fiore 7:a31236c2e75c 194 writeField(_fGpsTime, buf, size, true);
Mike Fiore 7:a31236c2e75c 195
Mike Fiore 7:a31236c2e75c 196 } else writeLabel(_lNoGps);
Mike Fiore 7:a31236c2e75c 197
Mike Fiore 7:a31236c2e75c 198 memset(buf, 0, sizeof(buf));
Mike Fiore 7:a31236c2e75c 199 size = snprintf(buf, sizeof(buf), "%.1f",temp);
Mike Fiore 7:a31236c2e75c 200 writeField(_fTemp, buf, size, true);
Mike Fiore 7:a31236c2e75c 201
Mike Fiore 7:a31236c2e75c 202 endUpdate();
Mike Fiore 7:a31236c2e75c 203 }
Mike Fiore 7:a31236c2e75c 204