]> git.donarmstrong.com Git - kiibohd-controller.git/commitdiff
Adding additional convenience functions to print.
authorJacob Alexander <triplehaata@gmail.com>
Sun, 14 Apr 2013 00:11:40 +0000 (20:11 -0400)
committerJacob Alexander <haata@users.sf.net>
Sun, 17 Nov 2013 00:37:16 +0000 (19:37 -0500)
- Directly printing numbers rather than having to convert them into strings first

Debug/print/print.c
Debug/print/print.h

index 04590adab2e8f58e8e83a3c8b4e84a83ec97c544..7c4f2ed846121b6fc2dabf5d0bdd9a609b2758c3 100644 (file)
@@ -91,6 +91,46 @@ void _print(const char *s)
 
 
 
+// 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 )
index 2383d87da129a677e561907a042d26d32553d908..ee36203cdacb3e84d7a6737eac1132a400074eb5 100644 (file)
@@ -86,6 +86,13 @@ void usb_debug_putstr( char* s );
 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)