# HG changeset patch # User Jacob Alexander # Date 1365898300 14400 # Node ID fcef1286ab60fdfb2c3266ac265be5b6ff8e8f21 # Parent 62069d39b09d1a0993c7bc99f8813ad27bd27230 Adding additional convenience functions to print. - Directly printing numbers rather than having to convert them into strings first diff -r 62069d39b09d -r fcef1286ab60 Debug/print/print.c --- a/Debug/print/print.c Wed Apr 10 14:06:10 2013 -0400 +++ b/Debug/print/print.c Sat Apr 13 20:11:40 2013 -0400 @@ -91,6 +91,46 @@ +// Number Printing Functions +void printInt8( uint8_t in ) +{ + // Max number of characters is 3 + 1 for null + char tmpStr[4]; + + // Convert number + int8ToStr( in, tmpStr ); + + // Print number + dPrintStr( tmpStr ); +} + +void printInt16( uint16_t in ) +{ + // Max number of characters is 5 + 1 for null + char tmpStr[6]; + + // Convert number + int16ToStr( in, tmpStr ); + + // Print number + dPrintStr( tmpStr ); +} + +void printHex_op( uint16_t in, uint8_t op ) +{ + // With an op of 1, the max number of characters is 6 + 1 for null + // e.g. "0xFFFF\0" + // op 2 and 4 require fewer characters (2+1 and 4+1 respectively) + char tmpStr[7]; + + // Convert number + hexToStr_op( in, tmpStr, op ); + + // Print number + dPrintStr( tmpStr ); +} + + // String Functions void int8ToStr( uint8_t in, char* out ) diff -r 62069d39b09d -r fcef1286ab60 Debug/print/print.h --- a/Debug/print/print.h Wed Apr 10 14:06:10 2013 -0400 +++ b/Debug/print/print.h Sat Apr 13 20:11:40 2013 -0400 @@ -86,6 +86,13 @@ void usb_debug_putstrs( char* first, ... ); +// Printing numbers +#define printHex(hex) printHex_op(hex, 1) + +void printInt8 ( uint8_t in ); +void printInt16 ( uint16_t in ); +void printHex_op( uint16_t in, uint8_t op ); + // String Functions #define hexToStr(hex, out) hexToStr_op(hex, out, 1)