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

Dependents:   FinalProject

HomeMonUtils.cpp

Committer:
groletter
Date:
2013-09-01
Revision:
0:3f846fc933a2

File content as of revision 0:3f846fc933a2:

#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;
}