Takuo WATANABE
/
STTS751_Demo
A demo program for STTS751 (I2C temperature sensor library)
Revision 3:a2d2563ae3ef, committed 2014-02-05
- Comitter:
- takuo
- Date:
- Wed Feb 05 04:28:22 2014 +0000
- Parent:
- 2:9850512c9113
- Commit message:
- A usage example of standby mode is provided
Changed in this revision
STTS751.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9850512c9113 -r a2d2563ae3ef STTS751.lib --- a/STTS751.lib Sun Jan 19 03:16:15 2014 +0000 +++ b/STTS751.lib Wed Feb 05 04:28:22 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/takuo/code/STTS751/#3116fe4a0079 +http://mbed.org/users/takuo/code/STTS751/#f9d3008f7e8f
diff -r 9850512c9113 -r a2d2563ae3ef main.cpp --- a/main.cpp Sun Jan 19 03:16:15 2014 +0000 +++ b/main.cpp Wed Feb 05 04:28:22 2014 +0000 @@ -1,23 +1,44 @@ /** A demo program for STTS751 (I2C temperature sensor library) * Takuo WATANABE (wtakuo) - * http://mbed.org/users/takuo/code/ACM1602NI/ */ #include "mbed.h" #include "STTS751.h" // I2C pins: p9 = sda, p10 = scl -STTS751 temp(p9, p10); +STTS751 sensor(p9, p10); // You can specify an I2C object instead. // I2C i2c(p9, p10); -// STTS751 temp(i2c); +// STTS751 sensor(i2c); +// example using continuous conversion mode int main() { // set the temperature resolution to 12bits - temp.setResolution(STTS751::RES_12); + sensor.setResolution(STTS751::RES_12); + // set the conversion rate to 2/sec + sensor.setConversionRate(5); while (true) { - printf("temp: %.4f\n", (float)temp); + printf("temp: %.4f\n", (float)sensor); wait(1); } } + +/* +// example using standby mode +int main() { + // set the device to standby mode + sensor.setStandbyMode(true); + // set the temperature resolution to 12bits + sensor.setResolution(STTS751::RES_12); + while (true) { + // start a temperature measurement + sensor.start(); + // waiting for finishing the measurement + while (!sensor.ready()) + wait(0.01); + printf("temp: %.4f\n", sensor.temp(true)); + wait(1); + } +} +*/