Further refactored printing code to be more readable

This commit is contained in:
BlackMark 2016-05-21 20:47:18 +02:00
parent 8ccddc483e
commit 02d5d34e72

View File

@ -21,67 +21,51 @@ int main()
cUSART << "\r\nSizes: \r\n"; cUSART << "\r\nSizes: \r\n";
sprintf( arrBuffer.data(), "%d\r\n", sizeof( char ) ); sprintf( arrBuffer.data(), "%d\r\n", sizeof( char ) );
cUSART << "sizeof( char ) = "; cUSART << "sizeof( char ) = " << arrBuffer.data();
cUSART << arrBuffer.data();
sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned char ) ); sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned char ) );
cUSART << "sizeof( unsigned char ) = "; cUSART << "sizeof( unsigned char ) = " << arrBuffer.data();
cUSART << arrBuffer.data();
sprintf( arrBuffer.data(), "%d\r\n", sizeof( short int ) ); sprintf( arrBuffer.data(), "%d\r\n", sizeof( short int ) );
cUSART << "sizeof( short int ) = "; cUSART << "sizeof( short int ) = " << arrBuffer.data();
cUSART << arrBuffer.data();
sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned short int ) ); sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned short int ) );
cUSART << "sizeof( unsigned short int ) = "; cUSART << "sizeof( unsigned short int ) = " << arrBuffer.data();
cUSART << arrBuffer.data();
sprintf( arrBuffer.data(), "%d\r\n", sizeof( int ) ); sprintf( arrBuffer.data(), "%d\r\n", sizeof( int ) );
cUSART << "sizeof( int ) = "; cUSART << "sizeof( int ) = " << arrBuffer.data();
cUSART << arrBuffer.data();
sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned int ) ); sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned int ) );
cUSART << "sizeof( unsigned int ) = "; cUSART << "sizeof( unsigned int ) = " << arrBuffer.data();
cUSART << arrBuffer.data();
sprintf( arrBuffer.data(), "%d\r\n", sizeof( long int ) ); sprintf( arrBuffer.data(), "%d\r\n", sizeof( long int ) );
cUSART << "sizeof( long int ) = "; cUSART << "sizeof( long int ) = " << arrBuffer.data();
cUSART << arrBuffer.data();
sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned long int ) ); sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned long int ) );
cUSART << "sizeof( unsigned long int ) = "; cUSART << "sizeof( unsigned long int ) = " << arrBuffer.data();
cUSART << arrBuffer.data();
sprintf( arrBuffer.data(), "%d\r\n", sizeof( long long int ) ); sprintf( arrBuffer.data(), "%d\r\n", sizeof( long long int ) );
cUSART << "sizeof( long long int ) = "; cUSART << "sizeof( long long int ) = " << arrBuffer.data();
cUSART << arrBuffer.data();
sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned long long int ) ); sprintf( arrBuffer.data(), "%d\r\n", sizeof( unsigned long long int ) );
cUSART << "sizeof( unsigned long long int ) = "; cUSART << "sizeof( unsigned long long int ) = " << arrBuffer.data();
cUSART << arrBuffer.data();
sprintf( arrBuffer.data(), "%d\r\n", sizeof( float ) ); sprintf( arrBuffer.data(), "%d\r\n", sizeof( float ) );
cUSART << "sizeof( float ) = "; cUSART << "sizeof( float ) = " << arrBuffer.data();
cUSART << arrBuffer.data();
sprintf( arrBuffer.data(), "%d\r\n", sizeof( double ) ); sprintf( arrBuffer.data(), "%d\r\n", sizeof( double ) );
cUSART << "sizeof( double ) = "; cUSART << "sizeof( double ) = " << arrBuffer.data();
cUSART << arrBuffer.data();
sprintf( arrBuffer.data(), "%d\r\n", sizeof( long double ) ); sprintf( arrBuffer.data(), "%d\r\n", sizeof( long double ) );
cUSART << "sizeof( long double ) = "; cUSART << "sizeof( long double ) = " << arrBuffer.data();
cUSART << arrBuffer.data();
sprintf( arrBuffer.data(), "%d\r\n\r\n", sizeof( void* ) ); sprintf( arrBuffer.data(), "%d\r\n\r\n", sizeof( void* ) );
cUSART << "sizeof( void* ) = "; cUSART << "sizeof( void* ) = " << arrBuffer.data();
cUSART << arrBuffer.data();
while( true ) while( true )
{ {
sprintf( arrBuffer.data(), "%lu", ui32Counter++ ); sprintf( arrBuffer.data(), "%lu", ui32Counter++ );
cUSART << "This has been running for \""; cUSART << "This has been running for \"" << arrBuffer.data() << "\" seconds!\r\n";
cUSART << arrBuffer.data();
cUSART << "\" seconds!\r\n";
if( !cUSART.receiveLine( arrBuffer.data(), arrBuffer.size(), "\r" ) ) if( !cUSART.receiveLine( arrBuffer.data(), arrBuffer.size(), "\r" ) )
{ {
@ -92,8 +76,7 @@ int main()
cUSART << "Echo: "; cUSART << "Echo: ";
} }
cUSART << arrBuffer.data(); cUSART << arrBuffer.data() << "\r\n";
cUSART << "\r\n";
uint8_t ui8Byte; uint8_t ui8Byte;