Hiroshi Yamaguchi / SCP1000

Dependents:   SCP1000Example 0sample_SCP1000_USB SCP1000_Fastsensing

Revision:
0:23fab9b42ad4
Child:
1:0bc094c5d1b9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Feb 02 08:00:23 2011 +0000
@@ -0,0 +1,53 @@
+#include "mbed.h"
+#include "SCP1000.h"
+
+DigitalIn sw(p9);
+DigitalOut leds[4] = {LED1, LED2, LED3, LED4};
+SCP1000 scp1000(p11, p12, p13, p10);
+LocalFileSystem local("local");
+
+void printMeasurements(char *title, int n = 10) {
+    FILE *fp = fopen("/local/scp1000.txt", "a");
+    fprintf(fp, "%s\n", title);
+    
+    for (int i = 0; !sw && i < n; i++) {
+        while (!scp1000.isReady())
+            ;
+        time_t seconds = time(NULL);
+        char buf[16];
+        strftime(buf, sizeof(buf), "%X", localtime(&seconds));
+        fprintf(fp, "%s %3.2f, %3.3f\n", buf, scp1000.readTemperature(), scp1000.readPressure());
+        leds[i % 4] = (i % 8) < 4;
+        if (i % 100 == 99)
+            freopen(NULL, "a", fp);
+    }
+    
+    fclose(fp);
+    wait(1.0);
+}
+
+int main() {
+    char buf[32];
+    
+    FILE *fp = fopen("/local/scp1000.txt", "a");
+    if (fp == NULL) exit(-1);
+    
+    time_t seconds = time(NULL);
+    strftime(buf, sizeof(buf), "%x %X", localtime(&seconds));
+    fprintf(fp, "Time: %s\n", buf);
+    fprintf(fp, "SCP1000 ASIC revision number = %d\n", scp1000.revision());
+    bool result = scp1000.performSelfTest();
+    fprintf(fp, "SCP1000 self test: %s\n", result ? "PASSED" : "FAILED");
+    fprintf(fp, "SCP1000 reset\n");
+    scp1000.reset();
+    fclose(fp);
+    
+    scp1000.setOperationMode(HIGH_SPEED_MODE);
+    printMeasurements("SCP1000 High Speed Mode - 9Hz", 1000);
+    
+    scp1000.setOperationMode(HIGH_RESOLUTION_MODE);
+    printMeasurements("SCP1000 High Resolution Mode - 1.8Hz",  1000);
+    
+    scp1000.setOperationMode(ULTRA_LOW_POWER_MODE);
+    printMeasurements("SCP1000 Ultra Low Power Mode - 1Hz", 1000);
+}
\ No newline at end of file