RP

Dependencies:   mbed SX1272Lib

Committer:
limchy
Date:
Thu Jul 26 07:25:15 2018 +0000
Revision:
13:4429cb012011
Parent:
0:45496a70a8a5
RP

Who changed what in which revision?

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