A demo program for STTS751 (I2C temperature sensor library)

Dependencies:   STTS751 mbed

Revision:
3:a2d2563ae3ef
Parent:
2:9850512c9113
--- 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);
+    }
+}
+*/