Julia DESMAZES / Mbed 2 deprecated Hexapode

Dependencies:   mbed BLE_API X_NUCLEO_IDB0XA1 MODSERIAL

Revision:
1:8bab9152933e
Child:
2:ca6d8d1f77d4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/COM/LOGGER.cpp	Thu Aug 11 12:18:13 2016 +0000
@@ -0,0 +1,61 @@
+#include "LOGGER.h"
+#include <stdio.h>
+#include <cmath>
+#include <cstdlib>
+
+Logger* Logger::_instance = NULL;
+
+Logger::Logger() {
+    serial = new Serial(SERIAL_TX, SERIAL_RX);
+}
+
+Logger* Logger::Instance() {
+    if (_instance == NULL) _instance = new Logger();
+    return _instance;
+}
+    
+void Logger::log(std::string s) {
+    this->serial->printf((s).c_str());
+    this->serial->printf(" ");
+}
+    
+void Logger::logn(std::string s){
+    this->log((s+"\n\r").c_str());
+}
+
+void Logger::log(double f) {
+    this->serial->printf("%f",f);
+    this->log("");
+}
+    
+void Logger::logn(double f){
+    this->log(f);
+    this->logn("");
+}
+
+void Logger::log(int i) {
+    this->serial->printf("%d",i);
+    this->log("");
+}
+    
+void Logger::logn(int i){
+    this->log(i);
+    this->logn("");
+}
+
+void Logger::log(long i) {
+    this->serial->printf("%ld",i);
+    this->log("");
+}
+    
+void Logger::logn(long i){
+    this->log(i);
+    this->logn("");
+}
+string Logger::log_itos(int i)
+{
+   float v= (float) i;
+   char *c =(char*) malloc(sizeof(char)*((int)log10(v)+1));
+   sprintf(c,"%d",i);
+    return string(c);
+}