This is used for sending Data to receiving mDot

Dependencies:   libmDot-dev-mbed5-deprecated sd-driver ISL29011

Fork of mdot-examples by 3mdeb

Revision:
5:c9ab5062cfc3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/itoa.cpp	Fri Dec 01 20:22:20 2017 +0000
@@ -0,0 +1,60 @@
+#include <string.h>
+#include "itoa.h"
+using namespace std;
+
+// Implementation of itoa()
+char* itoa(int num, char* str, int base)
+{
+    int i = 0;
+    bool isNegative = false;
+ 
+    /* Handle 0 explicitely, otherwise empty string is printed for 0 */
+    if (num == 0)
+    {
+        str[i++] = '0';
+        str[i] = '\0';
+        return str;
+    }
+ 
+    // In standard itoa(), negative numbers are handled only with 
+    // base 10. Otherwise numbers are considered unsigned.
+    if (num < 0 && base == 10)
+    {
+        isNegative = true;
+        num = -num;
+    }
+ 
+    // Process individual digits
+    while (num != 0)
+    {
+        int rem = num % base;
+        str[i++] = (rem > 9)? (rem-10) + 'a' : rem + '0';
+        num = num/base;
+    }
+ 
+    // If number is negative, append '-'
+    if (isNegative)
+        str[i++] = '-';
+ 
+    str[i] = '\0'; // Append string terminator
+ 
+    // Reverse the string
+    reverse(str);
+ 
+    return str;
+}
+
+/*
+** reverse string in place 
+*/
+void reverse(char *s){
+char *j;
+int c;
+ 
+  j = s + strlen(s) - 1;
+  while(s < j) {
+    c = *s;
+    *s++ = *j;
+    *j-- = c;
+  }
+}
\ No newline at end of file