Library for my home monitoring classes and serial communication protocol. It monitors temperature and movement on the mbed application board.

Dependents:   FinalProject

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HomeMonUtils.cpp Source File

HomeMonUtils.cpp

00001 #include <string>
00002 #include <sstream>
00003 
00004 bool convert_sample(double sample, std::string &toString) {
00005     std::ostringstream ss;
00006 
00007     ss.precision(5);
00008     ss.width(7); ss << sample;
00009     toString = ss.str();
00010     // Can't send strings bigger than 7 characters.  If that happens
00011     // it was user error!
00012     if (toString.size() > 7) {
00013         return false;
00014     }
00015     return true;
00016 }