Anish updated the code to work with L152. RTC seems to causing issue. Will have to disable LSE.
Dependencies: mbed LoRaWAN-lib SX1276Lib
app/SerialDisplay.cpp@0:92bca02df485, 2015-10-20 (annotated)
- Committer:
- mluis
- Date:
- Tue Oct 20 13:23:35 2015 +0000
- Revision:
- 0:92bca02df485
- Child:
- 1:352f608c3337
LoRaWAN-demo project creation using LoRaWAN-lib library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mluis | 0:92bca02df485 | 1 | /* |
mluis | 0:92bca02df485 | 2 | / _____) _ | | |
mluis | 0:92bca02df485 | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ |
mluis | 0:92bca02df485 | 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ |
mluis | 0:92bca02df485 | 5 | _____) ) ____| | | || |_| ____( (___| | | | |
mluis | 0:92bca02df485 | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| |
mluis | 0:92bca02df485 | 7 | (C)2015 Semtech |
mluis | 0:92bca02df485 | 8 | |
mluis | 0:92bca02df485 | 9 | Description: VT100 serial display management |
mluis | 0:92bca02df485 | 10 | |
mluis | 0:92bca02df485 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project |
mluis | 0:92bca02df485 | 12 | |
mluis | 0:92bca02df485 | 13 | Maintainer: Miguel Luis and Gregory Cristian |
mluis | 0:92bca02df485 | 14 | */ |
mluis | 0:92bca02df485 | 15 | #include "board.h" |
mluis | 0:92bca02df485 | 16 | #include "vt100.h" |
mluis | 0:92bca02df485 | 17 | #include "SerialDisplay.h" |
mluis | 0:92bca02df485 | 18 | |
mluis | 0:92bca02df485 | 19 | //extern struct sLoRaMacUplinkStatus |
mluis | 0:92bca02df485 | 20 | //{ |
mluis | 0:92bca02df485 | 21 | // uint8_t Acked; |
mluis | 0:92bca02df485 | 22 | // int8_t Datarate; |
mluis | 0:92bca02df485 | 23 | // uint16_t UplinkCounter; |
mluis | 0:92bca02df485 | 24 | // uint8_t Port; |
mluis | 0:92bca02df485 | 25 | // uint8_t *Buffer; |
mluis | 0:92bca02df485 | 26 | // uint8_t BufferSize; |
mluis | 0:92bca02df485 | 27 | //}LoRaMacUplinkStatus; |
mluis | 0:92bca02df485 | 28 | // |
mluis | 0:92bca02df485 | 29 | //extern struct sLoRaMacDownlinkStatus |
mluis | 0:92bca02df485 | 30 | //{ |
mluis | 0:92bca02df485 | 31 | // int16_t Rssi; |
mluis | 0:92bca02df485 | 32 | // int8_t Snr; |
mluis | 0:92bca02df485 | 33 | // uint16_t DownlinkCounter; |
mluis | 0:92bca02df485 | 34 | // bool RxData; |
mluis | 0:92bca02df485 | 35 | // uint8_t Port; |
mluis | 0:92bca02df485 | 36 | // uint8_t *Buffer; |
mluis | 0:92bca02df485 | 37 | // uint8_t BufferSize; |
mluis | 0:92bca02df485 | 38 | //}LoRaMacDownlinkStatus; |
mluis | 0:92bca02df485 | 39 | |
mluis | 0:92bca02df485 | 40 | VT100 vt( USBTX, USBRX ); |
mluis | 0:92bca02df485 | 41 | |
mluis | 0:92bca02df485 | 42 | void SerialPrintCheckBox( bool activated, uint8_t color ) |
mluis | 0:92bca02df485 | 43 | { |
mluis | 0:92bca02df485 | 44 | if( activated == true ) |
mluis | 0:92bca02df485 | 45 | { |
mluis | 0:92bca02df485 | 46 | vt.SetAttribute( VT100::ATTR_OFF, color, color ); |
mluis | 0:92bca02df485 | 47 | } |
mluis | 0:92bca02df485 | 48 | else |
mluis | 0:92bca02df485 | 49 | { |
mluis | 0:92bca02df485 | 50 | vt.SetAttribute( VT100::ATTR_OFF ); |
mluis | 0:92bca02df485 | 51 | } |
mluis | 0:92bca02df485 | 52 | vt.printf( " " ); |
mluis | 0:92bca02df485 | 53 | vt.SetAttribute( VT100::ATTR_OFF ); |
mluis | 0:92bca02df485 | 54 | } |
mluis | 0:92bca02df485 | 55 | |
mluis | 0:92bca02df485 | 56 | void SerialDisplayUpdateActivationMode( bool otaa ) |
mluis | 0:92bca02df485 | 57 | { |
mluis | 0:92bca02df485 | 58 | vt.SetCursorPos( 4, 17 ); |
mluis | 0:92bca02df485 | 59 | SerialPrintCheckBox( otaa, VT100::WHITE ); |
mluis | 0:92bca02df485 | 60 | vt.SetCursorPos( 9, 17 ); |
mluis | 0:92bca02df485 | 61 | SerialPrintCheckBox( !otaa, VT100::WHITE ); |
mluis | 0:92bca02df485 | 62 | } |
mluis | 0:92bca02df485 | 63 | |
mluis | 0:92bca02df485 | 64 | void SerialDisplayUpdateEui( uint8_t line, uint8_t *eui ) |
mluis | 0:92bca02df485 | 65 | { // |
mluis | 0:92bca02df485 | 66 | // REMARK |
mluis | 0:92bca02df485 | 67 | // |
mluis | 0:92bca02df485 | 68 | // EUIs must be displayed in reverse order |
mluis | 0:92bca02df485 | 69 | // |
mluis | 0:92bca02df485 | 70 | vt.SetCursorPos( line, 27 ); |
mluis | 0:92bca02df485 | 71 | for( uint8_t i = 0; i < 8; i++ ) |
mluis | 0:92bca02df485 | 72 | { |
mluis | 0:92bca02df485 | 73 | vt.printf( "%02X ", eui[7 - i] ); |
mluis | 0:92bca02df485 | 74 | } |
mluis | 0:92bca02df485 | 75 | vt.SetCursorPos( line, 50 ); |
mluis | 0:92bca02df485 | 76 | vt.printf( "]" ); |
mluis | 0:92bca02df485 | 77 | } |
mluis | 0:92bca02df485 | 78 | |
mluis | 0:92bca02df485 | 79 | void SerialDisplayUpdateKey( uint8_t line, uint8_t *key ) |
mluis | 0:92bca02df485 | 80 | { |
mluis | 0:92bca02df485 | 81 | vt.SetCursorPos( line, 27 ); |
mluis | 0:92bca02df485 | 82 | for( uint8_t i = 0; i < 16; i++ ) |
mluis | 0:92bca02df485 | 83 | { |
mluis | 0:92bca02df485 | 84 | vt.printf( "%02X ", key[i] ); |
mluis | 0:92bca02df485 | 85 | } |
mluis | 0:92bca02df485 | 86 | vt.SetCursorPos( line, 74 ); |
mluis | 0:92bca02df485 | 87 | vt.printf( "]" ); |
mluis | 0:92bca02df485 | 88 | } |
mluis | 0:92bca02df485 | 89 | |
mluis | 0:92bca02df485 | 90 | void SerialDisplayUpdateNwkId( uint8_t id ) |
mluis | 0:92bca02df485 | 91 | { |
mluis | 0:92bca02df485 | 92 | vt.SetCursorPos( 10, 27 ); |
mluis | 0:92bca02df485 | 93 | vt.printf( "%03d", id ); |
mluis | 0:92bca02df485 | 94 | } |
mluis | 0:92bca02df485 | 95 | |
mluis | 0:92bca02df485 | 96 | void SerialDisplayUpdateDevAddr( uint32_t addr ) |
mluis | 0:92bca02df485 | 97 | { |
mluis | 0:92bca02df485 | 98 | vt.SetCursorPos( 11, 27 ); |
mluis | 0:92bca02df485 | 99 | vt.printf( "%02X %02X %02X %02X", ( addr >> 24 ) & 0xFF, ( addr >> 16 ) & 0xFF, ( addr >> 8 ) & 0xFF, addr & 0xFF ); |
mluis | 0:92bca02df485 | 100 | } |
mluis | 0:92bca02df485 | 101 | |
mluis | 0:92bca02df485 | 102 | void SerialDisplayUpdateFrameType( bool confirmed ) |
mluis | 0:92bca02df485 | 103 | { |
mluis | 0:92bca02df485 | 104 | vt.SetCursorPos( 15, 17 ); |
mluis | 0:92bca02df485 | 105 | SerialPrintCheckBox( confirmed, VT100::WHITE ); |
mluis | 0:92bca02df485 | 106 | vt.SetCursorPos( 15, 32 ); |
mluis | 0:92bca02df485 | 107 | SerialPrintCheckBox( !confirmed, VT100::WHITE ); |
mluis | 0:92bca02df485 | 108 | } |
mluis | 0:92bca02df485 | 109 | |
mluis | 0:92bca02df485 | 110 | void SerialDisplayUpdateAdr( bool adr ) |
mluis | 0:92bca02df485 | 111 | { |
mluis | 0:92bca02df485 | 112 | vt.SetCursorPos( 16, 27 ); |
mluis | 0:92bca02df485 | 113 | if( adr == true ) |
mluis | 0:92bca02df485 | 114 | { |
mluis | 0:92bca02df485 | 115 | vt.printf( " ON" ); |
mluis | 0:92bca02df485 | 116 | } |
mluis | 0:92bca02df485 | 117 | else |
mluis | 0:92bca02df485 | 118 | { |
mluis | 0:92bca02df485 | 119 | vt.printf( "OFF" ); |
mluis | 0:92bca02df485 | 120 | } |
mluis | 0:92bca02df485 | 121 | } |
mluis | 0:92bca02df485 | 122 | |
mluis | 0:92bca02df485 | 123 | void SerialDisplayUpdateDutyCycle( bool dutyCycle ) |
mluis | 0:92bca02df485 | 124 | { |
mluis | 0:92bca02df485 | 125 | vt.SetCursorPos( 17, 27 ); |
mluis | 0:92bca02df485 | 126 | if( dutyCycle == true ) |
mluis | 0:92bca02df485 | 127 | { |
mluis | 0:92bca02df485 | 128 | vt.printf( " ON" ); |
mluis | 0:92bca02df485 | 129 | } |
mluis | 0:92bca02df485 | 130 | else |
mluis | 0:92bca02df485 | 131 | { |
mluis | 0:92bca02df485 | 132 | vt.printf( "OFF" ); |
mluis | 0:92bca02df485 | 133 | } |
mluis | 0:92bca02df485 | 134 | } |
mluis | 0:92bca02df485 | 135 | |
mluis | 0:92bca02df485 | 136 | void SerialDisplayUpdatePublicNetwork( bool network ) |
mluis | 0:92bca02df485 | 137 | { |
mluis | 0:92bca02df485 | 138 | vt.SetCursorPos( 19, 17 ); |
mluis | 0:92bca02df485 | 139 | SerialPrintCheckBox( network, VT100::WHITE ); |
mluis | 0:92bca02df485 | 140 | vt.SetCursorPos( 19, 30 ); |
mluis | 0:92bca02df485 | 141 | SerialPrintCheckBox( !network, VT100::WHITE ); |
mluis | 0:92bca02df485 | 142 | } |
mluis | 0:92bca02df485 | 143 | |
mluis | 0:92bca02df485 | 144 | void SerialDisplayUpdateNetworkIsJoined( bool state ) |
mluis | 0:92bca02df485 | 145 | { |
mluis | 0:92bca02df485 | 146 | vt.SetCursorPos( 20, 17 ); |
mluis | 0:92bca02df485 | 147 | SerialPrintCheckBox( !state, VT100::RED ); |
mluis | 0:92bca02df485 | 148 | vt.SetCursorPos( 20, 30 ); |
mluis | 0:92bca02df485 | 149 | SerialPrintCheckBox( state, VT100::GREEN ); |
mluis | 0:92bca02df485 | 150 | } |
mluis | 0:92bca02df485 | 151 | |
mluis | 0:92bca02df485 | 152 | void SerialDisplayUpdateLedState( uint8_t id, uint8_t state ) |
mluis | 0:92bca02df485 | 153 | { |
mluis | 0:92bca02df485 | 154 | switch( id ) |
mluis | 0:92bca02df485 | 155 | { |
mluis | 0:92bca02df485 | 156 | case 1: |
mluis | 0:92bca02df485 | 157 | vt.SetCursorPos( 22, 17 ); |
mluis | 0:92bca02df485 | 158 | SerialPrintCheckBox( state, VT100::RED ); |
mluis | 0:92bca02df485 | 159 | break; |
mluis | 0:92bca02df485 | 160 | case 2: |
mluis | 0:92bca02df485 | 161 | vt.SetCursorPos( 22, 31 ); |
mluis | 0:92bca02df485 | 162 | SerialPrintCheckBox( state, VT100::GREEN ); |
mluis | 0:92bca02df485 | 163 | break; |
mluis | 0:92bca02df485 | 164 | case 3: |
mluis | 0:92bca02df485 | 165 | vt.SetCursorPos( 22, 45 ); |
mluis | 0:92bca02df485 | 166 | SerialPrintCheckBox( state, VT100::BLUE ); |
mluis | 0:92bca02df485 | 167 | break; |
mluis | 0:92bca02df485 | 168 | } |
mluis | 0:92bca02df485 | 169 | } |
mluis | 0:92bca02df485 | 170 | |
mluis | 0:92bca02df485 | 171 | void SerialDisplayUpdateData( uint8_t line, uint8_t *buffer, uint8_t size ) |
mluis | 0:92bca02df485 | 172 | { |
mluis | 0:92bca02df485 | 173 | if( size != 0 ) |
mluis | 0:92bca02df485 | 174 | { |
mluis | 0:92bca02df485 | 175 | vt.SetCursorPos( line, 27 ); |
mluis | 0:92bca02df485 | 176 | for( uint8_t i = 0; i < size; i++ ) |
mluis | 0:92bca02df485 | 177 | { |
mluis | 0:92bca02df485 | 178 | vt.printf( "%02X ", buffer[i] ); |
mluis | 0:92bca02df485 | 179 | if( ( ( i + 1 ) % 16 ) == 0 ) |
mluis | 0:92bca02df485 | 180 | { |
mluis | 0:92bca02df485 | 181 | line++; |
mluis | 0:92bca02df485 | 182 | vt.SetCursorPos( line, 27 ); |
mluis | 0:92bca02df485 | 183 | } |
mluis | 0:92bca02df485 | 184 | } |
mluis | 0:92bca02df485 | 185 | for( uint8_t i = size; i < 64; i++ ) |
mluis | 0:92bca02df485 | 186 | { |
mluis | 0:92bca02df485 | 187 | vt.printf( "__ " ); |
mluis | 0:92bca02df485 | 188 | if( ( ( i + 1 ) % 16 ) == 0 ) |
mluis | 0:92bca02df485 | 189 | { |
mluis | 0:92bca02df485 | 190 | line++; |
mluis | 0:92bca02df485 | 191 | vt.SetCursorPos( line, 27 ); |
mluis | 0:92bca02df485 | 192 | } |
mluis | 0:92bca02df485 | 193 | } |
mluis | 0:92bca02df485 | 194 | vt.SetCursorPos( line - 1, 74 ); |
mluis | 0:92bca02df485 | 195 | vt.printf( "]" ); |
mluis | 0:92bca02df485 | 196 | } |
mluis | 0:92bca02df485 | 197 | else |
mluis | 0:92bca02df485 | 198 | { |
mluis | 0:92bca02df485 | 199 | vt.SetCursorPos( line, 27 ); |
mluis | 0:92bca02df485 | 200 | for( uint8_t i = 0; i < 64; i++ ) |
mluis | 0:92bca02df485 | 201 | { |
mluis | 0:92bca02df485 | 202 | vt.printf( "__ " ); |
mluis | 0:92bca02df485 | 203 | if( ( ( i + 1 ) % 16 ) == 0 ) |
mluis | 0:92bca02df485 | 204 | { |
mluis | 0:92bca02df485 | 205 | line++; |
mluis | 0:92bca02df485 | 206 | vt.SetCursorPos( line, 27 ); |
mluis | 0:92bca02df485 | 207 | } |
mluis | 0:92bca02df485 | 208 | } |
mluis | 0:92bca02df485 | 209 | vt.SetCursorPos( line - 1, 74 ); |
mluis | 0:92bca02df485 | 210 | vt.printf( "]" ); |
mluis | 0:92bca02df485 | 211 | } |
mluis | 0:92bca02df485 | 212 | } |
mluis | 0:92bca02df485 | 213 | |
mluis | 0:92bca02df485 | 214 | void SerialDisplayUpdateUplinkAcked( bool state ) |
mluis | 0:92bca02df485 | 215 | { |
mluis | 0:92bca02df485 | 216 | vt.SetCursorPos( 24, 36 ); |
mluis | 0:92bca02df485 | 217 | SerialPrintCheckBox( state, VT100::GREEN ); |
mluis | 0:92bca02df485 | 218 | } |
mluis | 0:92bca02df485 | 219 | |
mluis | 0:92bca02df485 | 220 | void SerialDisplayUpdateUplink( bool acked, uint8_t datarate, uint16_t counter, uint8_t port, uint8_t *buffer, uint8_t bufferSize ) |
mluis | 0:92bca02df485 | 221 | { |
mluis | 0:92bca02df485 | 222 | // Acked |
mluis | 0:92bca02df485 | 223 | SerialDisplayUpdateUplinkAcked( acked ); |
mluis | 0:92bca02df485 | 224 | // Datarate |
mluis | 0:92bca02df485 | 225 | vt.SetCursorPos( 25, 33 ); |
mluis | 0:92bca02df485 | 226 | vt.printf( "DR%d", datarate ); |
mluis | 0:92bca02df485 | 227 | // Counter |
mluis | 0:92bca02df485 | 228 | vt.SetCursorPos( 26, 27 ); |
mluis | 0:92bca02df485 | 229 | vt.printf( "%10d", counter ); |
mluis | 0:92bca02df485 | 230 | // Port |
mluis | 0:92bca02df485 | 231 | vt.SetCursorPos( 27, 34 ); |
mluis | 0:92bca02df485 | 232 | vt.printf( "%3d", port ); |
mluis | 0:92bca02df485 | 233 | // Data |
mluis | 0:92bca02df485 | 234 | SerialDisplayUpdateData( 28, buffer, bufferSize ); |
mluis | 0:92bca02df485 | 235 | // Help message |
mluis | 0:92bca02df485 | 236 | vt.SetCursorPos( 42, 1 ); |
mluis | 0:92bca02df485 | 237 | vt.printf( "To refresh screen please hit 'r' key.\r\n" ); |
mluis | 0:92bca02df485 | 238 | } |
mluis | 0:92bca02df485 | 239 | |
mluis | 0:92bca02df485 | 240 | void SerialDisplayUpdateDonwlinkRxData( bool state ) |
mluis | 0:92bca02df485 | 241 | { |
mluis | 0:92bca02df485 | 242 | vt.SetCursorPos( 34, 4 ); |
mluis | 0:92bca02df485 | 243 | SerialPrintCheckBox( state, VT100::GREEN ); |
mluis | 0:92bca02df485 | 244 | } |
mluis | 0:92bca02df485 | 245 | |
mluis | 0:92bca02df485 | 246 | void SerialDisplayUpdateDownlink( bool rxData, int16_t rssi, int8_t snr, uint16_t counter, uint8_t port, uint8_t *buffer, uint8_t bufferSize ) |
mluis | 0:92bca02df485 | 247 | { |
mluis | 0:92bca02df485 | 248 | // Rx data |
mluis | 0:92bca02df485 | 249 | SerialDisplayUpdateDonwlinkRxData( rxData ); |
mluis | 0:92bca02df485 | 250 | // RSSI |
mluis | 0:92bca02df485 | 251 | vt.SetCursorPos( 33, 32 ); |
mluis | 0:92bca02df485 | 252 | vt.printf( "%5d", rssi ); |
mluis | 0:92bca02df485 | 253 | // SNR |
mluis | 0:92bca02df485 | 254 | vt.SetCursorPos( 34, 32 ); |
mluis | 0:92bca02df485 | 255 | vt.printf( "%5d", snr ); |
mluis | 0:92bca02df485 | 256 | // Counter |
mluis | 0:92bca02df485 | 257 | vt.SetCursorPos( 35, 27 ); |
mluis | 0:92bca02df485 | 258 | vt.printf( "%10d", counter ); |
mluis | 0:92bca02df485 | 259 | if( rxData == true ) |
mluis | 0:92bca02df485 | 260 | { |
mluis | 0:92bca02df485 | 261 | // Port |
mluis | 0:92bca02df485 | 262 | vt.SetCursorPos( 36, 34 ); |
mluis | 0:92bca02df485 | 263 | vt.printf( "%3d", port ); |
mluis | 0:92bca02df485 | 264 | // Data |
mluis | 0:92bca02df485 | 265 | SerialDisplayUpdateData( 37, buffer, bufferSize ); |
mluis | 0:92bca02df485 | 266 | } |
mluis | 0:92bca02df485 | 267 | else |
mluis | 0:92bca02df485 | 268 | { |
mluis | 0:92bca02df485 | 269 | // Port |
mluis | 0:92bca02df485 | 270 | vt.SetCursorPos( 36, 34 ); |
mluis | 0:92bca02df485 | 271 | vt.printf( " " ); |
mluis | 0:92bca02df485 | 272 | // Data |
mluis | 0:92bca02df485 | 273 | SerialDisplayUpdateData( 37, NULL, 0 ); |
mluis | 0:92bca02df485 | 274 | } |
mluis | 0:92bca02df485 | 275 | } |
mluis | 0:92bca02df485 | 276 | |
mluis | 0:92bca02df485 | 277 | void SerialDisplayDrawFirstLine( void ) |
mluis | 0:92bca02df485 | 278 | { |
mluis | 0:92bca02df485 | 279 | vt.PutBoxDrawingChar( 'l' ); |
mluis | 0:92bca02df485 | 280 | for( int8_t i = 0; i <= 77; i++ ) |
mluis | 0:92bca02df485 | 281 | { |
mluis | 0:92bca02df485 | 282 | vt.PutBoxDrawingChar( 'q' ); |
mluis | 0:92bca02df485 | 283 | } |
mluis | 0:92bca02df485 | 284 | vt.PutBoxDrawingChar( 'k' ); |
mluis | 0:92bca02df485 | 285 | vt.printf( "\r\n" ); |
mluis | 0:92bca02df485 | 286 | } |
mluis | 0:92bca02df485 | 287 | |
mluis | 0:92bca02df485 | 288 | void SerialDisplayDrawTitle( const char* title ) |
mluis | 0:92bca02df485 | 289 | { |
mluis | 0:92bca02df485 | 290 | vt.PutBoxDrawingChar( 'x' ); |
mluis | 0:92bca02df485 | 291 | vt.printf( "%s", title ); |
mluis | 0:92bca02df485 | 292 | vt.PutBoxDrawingChar( 'x' ); |
mluis | 0:92bca02df485 | 293 | vt.printf( "\r\n" ); |
mluis | 0:92bca02df485 | 294 | } |
mluis | 0:92bca02df485 | 295 | void SerialDisplayDrawTopSeparator( void ) |
mluis | 0:92bca02df485 | 296 | { |
mluis | 0:92bca02df485 | 297 | vt.PutBoxDrawingChar( 't' ); |
mluis | 0:92bca02df485 | 298 | for( int8_t i = 0; i <= 11; i++ ) |
mluis | 0:92bca02df485 | 299 | { |
mluis | 0:92bca02df485 | 300 | vt.PutBoxDrawingChar( 'q' ); |
mluis | 0:92bca02df485 | 301 | } |
mluis | 0:92bca02df485 | 302 | vt.PutBoxDrawingChar( 'w' ); |
mluis | 0:92bca02df485 | 303 | for( int8_t i = 0; i <= 64; i++ ) |
mluis | 0:92bca02df485 | 304 | { |
mluis | 0:92bca02df485 | 305 | vt.PutBoxDrawingChar( 'q' ); |
mluis | 0:92bca02df485 | 306 | } |
mluis | 0:92bca02df485 | 307 | vt.PutBoxDrawingChar( 'u' ); |
mluis | 0:92bca02df485 | 308 | vt.printf( "\r\n" ); |
mluis | 0:92bca02df485 | 309 | } |
mluis | 0:92bca02df485 | 310 | |
mluis | 0:92bca02df485 | 311 | void SerialDisplayDrawColSeparator( void ) |
mluis | 0:92bca02df485 | 312 | { |
mluis | 0:92bca02df485 | 313 | vt.PutBoxDrawingChar( 'x' ); |
mluis | 0:92bca02df485 | 314 | for( int8_t i = 0; i <= 11; i++ ) |
mluis | 0:92bca02df485 | 315 | { |
mluis | 0:92bca02df485 | 316 | vt.PutBoxDrawingChar( ' ' ); |
mluis | 0:92bca02df485 | 317 | } |
mluis | 0:92bca02df485 | 318 | vt.PutBoxDrawingChar( 't' ); |
mluis | 0:92bca02df485 | 319 | for( int8_t i = 0; i <= 64; i++ ) |
mluis | 0:92bca02df485 | 320 | { |
mluis | 0:92bca02df485 | 321 | vt.PutBoxDrawingChar( 'q' ); |
mluis | 0:92bca02df485 | 322 | } |
mluis | 0:92bca02df485 | 323 | vt.PutBoxDrawingChar( 'u' ); |
mluis | 0:92bca02df485 | 324 | vt.printf( "\r\n" ); |
mluis | 0:92bca02df485 | 325 | } |
mluis | 0:92bca02df485 | 326 | |
mluis | 0:92bca02df485 | 327 | void SerialDisplayDrawSeparator( void ) |
mluis | 0:92bca02df485 | 328 | { |
mluis | 0:92bca02df485 | 329 | vt.PutBoxDrawingChar( 't' ); |
mluis | 0:92bca02df485 | 330 | for( int8_t i = 0; i <= 11; i++ ) |
mluis | 0:92bca02df485 | 331 | { |
mluis | 0:92bca02df485 | 332 | vt.PutBoxDrawingChar( 'q' ); |
mluis | 0:92bca02df485 | 333 | } |
mluis | 0:92bca02df485 | 334 | vt.PutBoxDrawingChar( 'n' ); |
mluis | 0:92bca02df485 | 335 | for( int8_t i = 0; i <= 64; i++ ) |
mluis | 0:92bca02df485 | 336 | { |
mluis | 0:92bca02df485 | 337 | vt.PutBoxDrawingChar( 'q' ); |
mluis | 0:92bca02df485 | 338 | } |
mluis | 0:92bca02df485 | 339 | vt.PutBoxDrawingChar( 'u' ); |
mluis | 0:92bca02df485 | 340 | vt.printf( "\r\n" ); |
mluis | 0:92bca02df485 | 341 | } |
mluis | 0:92bca02df485 | 342 | |
mluis | 0:92bca02df485 | 343 | void SerialDisplayDrawLine( const char* firstCol, const char* secondCol ) |
mluis | 0:92bca02df485 | 344 | { |
mluis | 0:92bca02df485 | 345 | vt.PutBoxDrawingChar( 'x' ); |
mluis | 0:92bca02df485 | 346 | vt.printf( "%s", firstCol ); |
mluis | 0:92bca02df485 | 347 | vt.PutBoxDrawingChar( 'x' ); |
mluis | 0:92bca02df485 | 348 | vt.printf( "%s", secondCol ); |
mluis | 0:92bca02df485 | 349 | vt.PutBoxDrawingChar( 'x' ); |
mluis | 0:92bca02df485 | 350 | vt.printf( "\r\n" ); |
mluis | 0:92bca02df485 | 351 | } |
mluis | 0:92bca02df485 | 352 | |
mluis | 0:92bca02df485 | 353 | void SerialDisplayDrawBottomLine( void ) |
mluis | 0:92bca02df485 | 354 | { |
mluis | 0:92bca02df485 | 355 | vt.PutBoxDrawingChar( 'm' ); |
mluis | 0:92bca02df485 | 356 | for( int8_t i = 0; i <= 11; i++ ) |
mluis | 0:92bca02df485 | 357 | { |
mluis | 0:92bca02df485 | 358 | vt.PutBoxDrawingChar( 'q' ); |
mluis | 0:92bca02df485 | 359 | } |
mluis | 0:92bca02df485 | 360 | vt.PutBoxDrawingChar( 'v' ); |
mluis | 0:92bca02df485 | 361 | for( int8_t i = 0; i <= 64; i++ ) |
mluis | 0:92bca02df485 | 362 | { |
mluis | 0:92bca02df485 | 363 | vt.PutBoxDrawingChar( 'q' ); |
mluis | 0:92bca02df485 | 364 | } |
mluis | 0:92bca02df485 | 365 | vt.PutBoxDrawingChar( 'j' ); |
mluis | 0:92bca02df485 | 366 | vt.printf( "\r\n" ); |
mluis | 0:92bca02df485 | 367 | } |
mluis | 0:92bca02df485 | 368 | |
mluis | 0:92bca02df485 | 369 | void SerialDisplayInit( void ) |
mluis | 0:92bca02df485 | 370 | { |
mluis | 0:92bca02df485 | 371 | vt.ClearScreen( 2 ); |
mluis | 0:92bca02df485 | 372 | vt.SetCursorMode( false ); |
mluis | 0:92bca02df485 | 373 | vt.SetCursorPos( 0, 0 ); |
mluis | 0:92bca02df485 | 374 | |
mluis | 0:92bca02df485 | 375 | // "+-----------------------------------------------------------------------------+" ); |
mluis | 0:92bca02df485 | 376 | SerialDisplayDrawFirstLine( ); |
mluis | 0:92bca02df485 | 377 | // "¦ LoRaWAN Demonstration Application ¦" ); |
mluis | 0:92bca02df485 | 378 | SerialDisplayDrawTitle( " LoRaWAN Demonstration Application " ); |
mluis | 0:92bca02df485 | 379 | // "+------------+----------------------------------------------------------------¦" ); |
mluis | 0:92bca02df485 | 380 | SerialDisplayDrawTopSeparator( ); |
mluis | 0:92bca02df485 | 381 | // "¦ Activation ¦ [ ]Over The Air ¦" ); |
mluis | 0:92bca02df485 | 382 | SerialDisplayDrawLine( " Activation ", " [ ]Over The Air " ); |
mluis | 0:92bca02df485 | 383 | // "¦ ¦ DevEui [__ __ __ __ __ __ __ __] ¦" ); |
mluis | 0:92bca02df485 | 384 | SerialDisplayDrawLine( " ", " DevEui [__ __ __ __ __ __ __ __] " ); |
mluis | 0:92bca02df485 | 385 | // "¦ ¦ AppEui [__ __ __ __ __ __ __ __] ¦" ); |
mluis | 0:92bca02df485 | 386 | SerialDisplayDrawLine( " ", " AppEui [__ __ __ __ __ __ __ __] " ); |
mluis | 0:92bca02df485 | 387 | // "¦ ¦ AppKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] ¦" ); |
mluis | 0:92bca02df485 | 388 | SerialDisplayDrawLine( " ", " AppKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] " ); |
mluis | 0:92bca02df485 | 389 | // "¦ +----------------------------------------------------------------¦" ); |
mluis | 0:92bca02df485 | 390 | SerialDisplayDrawColSeparator( ); |
mluis | 0:92bca02df485 | 391 | // "¦ ¦ [x]Personalisation ¦" ); |
mluis | 0:92bca02df485 | 392 | SerialDisplayDrawLine( " ", " [ ]Personalisation " ); |
mluis | 0:92bca02df485 | 393 | // "¦ ¦ NwkId [___] ¦" ); |
mluis | 0:92bca02df485 | 394 | SerialDisplayDrawLine( " ", " NwkId [___] " ); |
mluis | 0:92bca02df485 | 395 | // "¦ ¦ DevAddr [__ __ __ __] ¦" ); |
mluis | 0:92bca02df485 | 396 | SerialDisplayDrawLine( " ", " DevAddr [__ __ __ __] " ); |
mluis | 0:92bca02df485 | 397 | // "¦ ¦ NwkSKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] ¦" ); |
mluis | 0:92bca02df485 | 398 | SerialDisplayDrawLine( " ", " NwkSKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] " ); |
mluis | 0:92bca02df485 | 399 | // "¦ ¦ AppSKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] ¦" ); |
mluis | 0:92bca02df485 | 400 | SerialDisplayDrawLine( " ", " AppSKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] " ); |
mluis | 0:92bca02df485 | 401 | // "+------------+----------------------------------------------------------------¦" ); |
mluis | 0:92bca02df485 | 402 | SerialDisplayDrawSeparator( ); |
mluis | 0:92bca02df485 | 403 | // "¦ MAC params ¦ [ ]Confirmed / [ ]Unconfirmed ¦" ); |
mluis | 0:92bca02df485 | 404 | SerialDisplayDrawLine( " MAC params ", " [ ]Confirmed / [ ]Unconfirmed " ); |
mluis | 0:92bca02df485 | 405 | // "¦ ¦ ADR [ ] ¦" ); |
mluis | 0:92bca02df485 | 406 | SerialDisplayDrawLine( " ", " ADR [ ] " ); |
mluis | 0:92bca02df485 | 407 | // "¦ ¦ Duty cycle[ ] ¦" ); |
mluis | 0:92bca02df485 | 408 | SerialDisplayDrawLine( " ", " Duty cycle[ ] " ); |
mluis | 0:92bca02df485 | 409 | // "+------------+----------------------------------------------------------------¦" ); |
mluis | 0:92bca02df485 | 410 | SerialDisplayDrawSeparator( ); |
mluis | 0:92bca02df485 | 411 | // "¦ Network ¦ [ ]Public / [ ]Private ¦" ); |
mluis | 0:92bca02df485 | 412 | SerialDisplayDrawLine( " Network ", " [ ]Public / [ ]Private " ); |
mluis | 0:92bca02df485 | 413 | // "¦ ¦ [ ]Joining / [ ]Joined ¦" ); |
mluis | 0:92bca02df485 | 414 | SerialDisplayDrawLine( " ", " [ ]Joining / [ ]Joined " ); |
mluis | 0:92bca02df485 | 415 | // "+------------+----------------------------------------------------------------¦" ); |
mluis | 0:92bca02df485 | 416 | SerialDisplayDrawSeparator( ); |
mluis | 0:92bca02df485 | 417 | // "¦ LED status ¦ [ ]LED1(Tx) / [ ]LED2(Rx) / [ ]LED3(App) ¦" ); |
mluis | 0:92bca02df485 | 418 | SerialDisplayDrawLine( " LED status ", " [ ]LED1(Tx) / [ ]LED2(Rx) / [ ]LED3(App) " ); |
mluis | 0:92bca02df485 | 419 | // "+------------+----------------------------------------------------------------¦" ); |
mluis | 0:92bca02df485 | 420 | SerialDisplayDrawSeparator( ); |
mluis | 0:92bca02df485 | 421 | // "¦ Uplink ¦ Acked [ ] ¦" ); |
mluis | 0:92bca02df485 | 422 | SerialDisplayDrawLine( " Uplink ", " Acked [ ] " ); |
mluis | 0:92bca02df485 | 423 | // "¦ ¦ Datarate [ ] ¦" ); |
mluis | 0:92bca02df485 | 424 | SerialDisplayDrawLine( " ", " Datarate [ ] " ); |
mluis | 0:92bca02df485 | 425 | // "¦ ¦ Counter [ ] ¦" ); |
mluis | 0:92bca02df485 | 426 | SerialDisplayDrawLine( " ", " Counter [ ] " ); |
mluis | 0:92bca02df485 | 427 | // "¦ ¦ Port [ ] ¦" ); |
mluis | 0:92bca02df485 | 428 | SerialDisplayDrawLine( " ", " Port [ ] " ); |
mluis | 0:92bca02df485 | 429 | // "¦ ¦ Data [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" ); |
mluis | 0:92bca02df485 | 430 | SerialDisplayDrawLine( " ", " Data [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " ); |
mluis | 0:92bca02df485 | 431 | // "¦ ¦ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" ); |
mluis | 0:92bca02df485 | 432 | SerialDisplayDrawLine( " ", " __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " ); |
mluis | 0:92bca02df485 | 433 | // "¦ ¦ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" ); |
mluis | 0:92bca02df485 | 434 | SerialDisplayDrawLine( " ", " __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " ); |
mluis | 0:92bca02df485 | 435 | // "¦ ¦ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" ); |
mluis | 0:92bca02df485 | 436 | SerialDisplayDrawLine( " ", " __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " ); |
mluis | 0:92bca02df485 | 437 | // "+------------+----------------------------------------------------------------¦" ); |
mluis | 0:92bca02df485 | 438 | SerialDisplayDrawSeparator( ); |
mluis | 0:92bca02df485 | 439 | // "¦ Downlink ¦ RSSI [ ] dBm ¦" ); |
mluis | 0:92bca02df485 | 440 | SerialDisplayDrawLine( " Downlink ", " RSSI [ ] dBm " ); |
mluis | 0:92bca02df485 | 441 | // "¦ [ ]Data ¦ SNR [ ] dB ¦" ); |
mluis | 0:92bca02df485 | 442 | SerialDisplayDrawLine( " [ ]Data ", " SNR [ ] dB " ); |
mluis | 0:92bca02df485 | 443 | // "¦ ¦ Counter [ ] ¦" ); |
mluis | 0:92bca02df485 | 444 | // "¦ ¦ Counter [ ] ¦" ); |
mluis | 0:92bca02df485 | 445 | SerialDisplayDrawLine( " ", " Counter [ ] " ); |
mluis | 0:92bca02df485 | 446 | // "¦ ¦ Port [ ] ¦" ); |
mluis | 0:92bca02df485 | 447 | SerialDisplayDrawLine( " ", " Port [ ] " ); |
mluis | 0:92bca02df485 | 448 | // "¦ ¦ Data [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" ); |
mluis | 0:92bca02df485 | 449 | SerialDisplayDrawLine( " ", " Data [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " ); |
mluis | 0:92bca02df485 | 450 | // "¦ ¦ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" ); |
mluis | 0:92bca02df485 | 451 | SerialDisplayDrawLine( " ", " __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " ); |
mluis | 0:92bca02df485 | 452 | // "¦ ¦ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" ); |
mluis | 0:92bca02df485 | 453 | SerialDisplayDrawLine( " ", " __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " ); |
mluis | 0:92bca02df485 | 454 | // "¦ ¦ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" ); |
mluis | 0:92bca02df485 | 455 | SerialDisplayDrawLine( " ", " __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " ); |
mluis | 0:92bca02df485 | 456 | // "+------------+----------------------------------------------------------------+" ); |
mluis | 0:92bca02df485 | 457 | SerialDisplayDrawBottomLine( ); |
mluis | 0:92bca02df485 | 458 | vt.printf( "To refresh screen please hit 'r' key.\r\n" ); |
mluis | 0:92bca02df485 | 459 | } |
mluis | 0:92bca02df485 | 460 | |
mluis | 0:92bca02df485 | 461 | bool SerialDisplayReadable( void ) |
mluis | 0:92bca02df485 | 462 | { |
mluis | 0:92bca02df485 | 463 | return vt.Readable( ); |
mluis | 0:92bca02df485 | 464 | } |
mluis | 0:92bca02df485 | 465 | |
mluis | 0:92bca02df485 | 466 | uint8_t SerialDisplayGetChar( void ) |
mluis | 0:92bca02df485 | 467 | { |
mluis | 0:92bca02df485 | 468 | return vt.GetChar( ); |
mluis | 0:92bca02df485 | 469 | } |