From 02d5d34e72bb31d12c820d780cac20600a9f9d8a Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sat, 21 May 2016 20:47:18 +0200 Subject: [PATCH] Further refactored printing code to be more readable --- usart/main.cpp | 49 ++++++++++++++++--------------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/usart/main.cpp b/usart/main.cpp index d6ebcc0..520ef4b 100644 --- a/usart/main.cpp +++ b/usart/main.cpp @@ -21,67 +21,51 @@ int main() cUSART << "\r\nSizes: \r\n"; sprintf( arrBuffer.data(), "%d\r\n", sizeof( char ) ); - cUSART << "sizeof( char ) = "; - cUSART << arrBuffer.data(); + cUSART << "sizeof( char ) = " << arrBuffer.data(); sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned char ) ); - cUSART << "sizeof( unsigned char ) = "; - cUSART << arrBuffer.data(); + cUSART << "sizeof( unsigned char ) = " << arrBuffer.data(); sprintf( arrBuffer.data(), "%d\r\n", sizeof( short int ) ); - cUSART << "sizeof( short int ) = "; - cUSART << arrBuffer.data(); + cUSART << "sizeof( short int ) = " << arrBuffer.data(); sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned short int ) ); - cUSART << "sizeof( unsigned short int ) = "; - cUSART << arrBuffer.data(); + cUSART << "sizeof( unsigned short int ) = " << arrBuffer.data(); sprintf( arrBuffer.data(), "%d\r\n", sizeof( int ) ); - cUSART << "sizeof( int ) = "; - cUSART << arrBuffer.data(); + cUSART << "sizeof( int ) = " << arrBuffer.data(); sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned int ) ); - cUSART << "sizeof( unsigned int ) = "; - cUSART << arrBuffer.data(); + cUSART << "sizeof( unsigned int ) = " << arrBuffer.data(); sprintf( arrBuffer.data(), "%d\r\n", sizeof( long int ) ); - cUSART << "sizeof( long int ) = "; - cUSART << arrBuffer.data(); + cUSART << "sizeof( long int ) = " << arrBuffer.data(); sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned long int ) ); - cUSART << "sizeof( unsigned long int ) = "; - cUSART << arrBuffer.data(); + cUSART << "sizeof( unsigned long int ) = " << arrBuffer.data(); sprintf( arrBuffer.data(), "%d\r\n", sizeof( long long int ) ); - cUSART << "sizeof( long long int ) = "; - cUSART << arrBuffer.data(); + cUSART << "sizeof( long long int ) = " << arrBuffer.data(); sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned long long int ) ); - cUSART << "sizeof( unsigned long long int ) = "; - cUSART << arrBuffer.data(); + cUSART << "sizeof( unsigned long long int ) = " << arrBuffer.data(); sprintf( arrBuffer.data(), "%d\r\n", sizeof( float ) ); - cUSART << "sizeof( float ) = "; - cUSART << arrBuffer.data(); + cUSART << "sizeof( float ) = " << arrBuffer.data(); sprintf( arrBuffer.data(), "%d\r\n", sizeof( double ) ); - cUSART << "sizeof( double ) = "; - cUSART << arrBuffer.data(); + cUSART << "sizeof( double ) = " << arrBuffer.data(); sprintf( arrBuffer.data(), "%d\r\n", sizeof( long double ) ); - cUSART << "sizeof( long double ) = "; - cUSART << arrBuffer.data(); + cUSART << "sizeof( long double ) = " << arrBuffer.data(); sprintf( arrBuffer.data(), "%d\r\n\r\n", sizeof( void* ) ); - cUSART << "sizeof( void* ) = "; - cUSART << arrBuffer.data(); + cUSART << "sizeof( void* ) = " << arrBuffer.data(); while( true ) { sprintf( arrBuffer.data(), "%lu", ui32Counter++ ); - cUSART << "This has been running for \""; - cUSART << arrBuffer.data(); - cUSART << "\" seconds!\r\n"; + cUSART << "This has been running for \"" << arrBuffer.data() << "\" seconds!\r\n"; if( !cUSART.receiveLine( arrBuffer.data(), arrBuffer.size(), "\r" ) ) { @@ -92,8 +76,7 @@ int main() cUSART << "Echo: "; } - cUSART << arrBuffer.data(); - cUSART << "\r\n"; + cUSART << arrBuffer.data() << "\r\n"; uint8_t ui8Byte;