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

Dependents:   FinalProject

Committer:
groletter
Date:
Sun Sep 01 23:35:18 2013 +0000
Revision:
0:3f846fc933a2
My library for temperature and motion monitoring and communication over a USB Serial device.  Requires host-side code.

Who changed what in which revision?

UserRevisionLine numberNew 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 }