Log

Dependents:   oldheating gps motorhome heating

Revision:
17:7acb89d71f48
Parent:
16:5c41b457c7f3
Child:
18:617791ed3d8e
--- a/log.c	Mon Feb 04 15:26:50 2019 +0000
+++ b/log.c	Thu Jun 27 21:19:33 2019 +0000
@@ -201,3 +201,31 @@
     va_end(argptr);
     return size;
 }
+
+void LogNibbleAsHex(int nibble)
+{
+    nibble &= 0x0F;
+    char c;
+    if      (nibble < 0x0A) c = nibble + '0';
+    else if (nibble < 0x10) c = nibble - 0xA + 'A';
+    else                    c = '0';
+    LogChar(c);
+}
+
+void LogByteAsHex(int value)
+{
+    LogNibbleAsHex(value >> 4);
+    LogNibbleAsHex(value >> 0);
+}
+void LogBytesAsHex(char* value, int size)
+{
+    int i = 0;
+    while(true)
+    {
+        LogByteAsHex(value[size - 1 - i]); //Display big end first
+        i++;
+        if (i >= size) break;
+        if (i % 32 == 0) Log("\r\n");
+        else             LogChar(' ');
+    }
+}