Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed BLE_API X_NUCLEO_IDB0XA1 MODSERIAL
COM/LOGGER.cpp
- Committer:
- Essenceia
- Date:
- 2016-08-11
- Revision:
- 1:8bab9152933e
- Child:
- 2:ca6d8d1f77d4
File content as of revision 1:8bab9152933e:
#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);
}