![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
add all sensors used
Dependencies: mbed QEI-1 nRF24L01P xiugai
Diff: converters.h
- Revision:
- 6:7db9b13ece76
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/converters.h Sun Nov 03 08:26:46 2019 +0000 @@ -0,0 +1,45 @@ +#pragma once + +#include <cstdlib> +#include <string> + +namespace std{ +static inline int stoi(const string &s) { + return atoi(s.c_str()); +} +static inline long stol(const string &s) { + return atol(s.c_str()); +} +static inline float stof(const string &s) { + return float(atof(s.c_str())); +} +#define _c_to_string(fmt,val) { \ + char buf[16];\ + snprintf(buf, sizeof(buf), fmt, val);\ + return string(buf);\ +} +static inline string to_string(bool v) { + _c_to_string("%d", (int)v); +} +static inline string to_string(char v) { + _c_to_string("%c", v); +} +static inline string to_string(int v) { + _c_to_string("%d", v); +} +static inline string to_string(long v) { + _c_to_string("%ld", v); +} +static inline string to_string(float v) { + _c_to_string("%f", v); +} +} + +inline bool _p(bool x) { return x; } +inline char _p(char x) { return x; } +inline int _p(int x) { return x; } +inline long _p(long x) { return x; } +inline float _p(float x) { return x; } +inline void* _p(void* x) { return x; } +inline const char* _p(const std::string &x) { return x.c_str(); } +