Library for my home monitoring classes and serial communication protocol. It monitors temperature and movement on the mbed application board.
Diff: HomeMonUtils.cpp
- Revision:
- 0:3f846fc933a2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HomeMonUtils.cpp Sun Sep 01 23:35:18 2013 +0000 @@ -0,0 +1,16 @@ +#include <string> +#include <sstream> + +bool convert_sample(double sample, std::string &toString) { + std::ostringstream ss; + + ss.precision(5); + ss.width(7); ss << sample; + toString = ss.str(); + // Can't send strings bigger than 7 characters. If that happens + // it was user error! + if (toString.size() > 7) { + return false; + } + return true; +}