Library for my home monitoring classes and serial communication protocol. It monitors temperature and movement on the mbed application board.
HomeMonUtils.cpp@2:84432add9142, 2013-09-03 (annotated)
- Committer:
- groletter
- Date:
- Tue Sep 03 20:24:12 2013 +0000
- Revision:
- 2:84432add9142
- Parent:
- 0:3f846fc933a2
Added class documentation. Not sure how to do this for pure C code.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
groletter | 0:3f846fc933a2 | 1 | #include <string> |
groletter | 0:3f846fc933a2 | 2 | #include <sstream> |
groletter | 0:3f846fc933a2 | 3 | |
groletter | 0:3f846fc933a2 | 4 | bool convert_sample(double sample, std::string &toString) { |
groletter | 0:3f846fc933a2 | 5 | std::ostringstream ss; |
groletter | 0:3f846fc933a2 | 6 | |
groletter | 0:3f846fc933a2 | 7 | ss.precision(5); |
groletter | 0:3f846fc933a2 | 8 | ss.width(7); ss << sample; |
groletter | 0:3f846fc933a2 | 9 | toString = ss.str(); |
groletter | 0:3f846fc933a2 | 10 | // Can't send strings bigger than 7 characters. If that happens |
groletter | 0:3f846fc933a2 | 11 | // it was user error! |
groletter | 0:3f846fc933a2 | 12 | if (toString.size() > 7) { |
groletter | 0:3f846fc933a2 | 13 | return false; |
groletter | 0:3f846fc933a2 | 14 | } |
groletter | 0:3f846fc933a2 | 15 | return true; |
groletter | 0:3f846fc933a2 | 16 | } |