test MAX31850

Dependencies:   OneWireFB mbed

Revision:
3:b4277f7c538e
Parent:
2:8e35ddc26023
Child:
4:031e71e61e80
--- a/main.cpp	Wed May 28 11:12:20 2014 +0000
+++ b/main.cpp	Mon Jun 02 13:17:18 2014 +0000
@@ -6,11 +6,12 @@
 #include "onewire.h"
 #include "shtlib.h"
 
-#define VERSION "TK_2014_05_27"
+#define VERSION "TK_2014_06_02"
 //OW
 uint8_t gSensorIDs[MAXBUS][MAXSENSORS][OW_ROMCODE_SIZE];
 uint8_t nSensors[MAXBUS];
-
+//file
+LocalFileSystem local("local");
 
 //console
 Serial pc(USBTX, USBRX); // tx, rx
@@ -100,60 +101,22 @@
     char c;
 
     c=pc.getc();
-    switch (c) {
-
-        case 'T':
-        case 't':
-            if (owpresent) {
-
-                // read sensor
-
-                int n=0;
-                int num_sensor=0;
-                uint64_t uint64_owID;
+    if (owpresent) {
+        int n;
+        int num_sensor;
+        uint64_t uint64_owID;
+        uint8_t sp[MAX31850_SP_SIZE];
+        float temp;
+        int err;
+        switch (c) {
+            case '1':
+                n=0;
+                num_sensor=0;
                 uint64_owID = uint64_id(&gSensorIDs[n][num_sensor][0]);
-
-
-                uint8_t sp[MAX31850_SP_SIZE];
                 for (uint8_t i=0 ; i< MAX31850_SP_SIZE; i++ )
                     sp[i]=0;
                 MAX31850_Read_Scratch(gSensorIDs[n][num_sensor],sp,n) ;
-                float temp;
-                int err = MAX31850_Temp_TC(sp,&temp);
-                if(err) {
-                    pc.printf( "-1.0\r ");
-                } else {
-                    float temp_CJ;
-                    double temp_true;
-                    MAX31850_Temp_CJ(sp,&temp_CJ);
-                    MAX31850_Temp_TRUE(sp,&temp_true);
-                    temp_true=temp_true-mMax31850[uint64_owID]->Get_offset();
-                    pc.printf( "%f\r",temp_true);
-
-                }
-
-                MAX31850_Start_meas(gSensorIDs[n][num_sensor],n);
-            }
-
-            break;
-        case 'A':
-        case 'a':
-            if (owpresent) {
-
-                // read sensor
-
-                int n=0;
-                int num_sensor=1;
-                uint64_t uint64_owID;
-                uint64_owID = uint64_id(&gSensorIDs[n][num_sensor][0]);
-
-
-                uint8_t sp[MAX31850_SP_SIZE];
-                for (uint8_t i=0 ; i< MAX31850_SP_SIZE; i++ )
-                    sp[i]=0;
-                MAX31850_Read_Scratch(gSensorIDs[n][num_sensor],sp,n) ;
-                float temp;
-                int err = MAX31850_Temp_TC(sp,&temp);
+                err = MAX31850_Temp_TC(sp,&temp);
                 if(err) {
                     pc.printf( "-1.0\r ");
                 } else {
@@ -166,16 +129,54 @@
 
                 }
                 MAX31850_Start_meas(gSensorIDs[n][num_sensor],n);
-
-            }
-            break;
-        case '*':
+                break;
+            case '2':
+                n=0;
+                num_sensor=1;
+                uint64_owID = uint64_id(&gSensorIDs[n][num_sensor][0]);
+                for (uint8_t i=0 ; i< MAX31850_SP_SIZE; i++ )
+                    sp[i]=0;
+                MAX31850_Read_Scratch(gSensorIDs[n][num_sensor],sp,n) ;
+                err = MAX31850_Temp_TC(sp,&temp);
+                if(err) {
+                    pc.printf( "-1.0\r ");
+                } else {
+                    float temp_CJ;
+                    double temp_true;
+                    MAX31850_Temp_CJ(sp,&temp_CJ);
+                    MAX31850_Temp_TRUE(sp,&temp_true);
+                    temp_true=temp_true-mMax31850[uint64_owID]->Get_offset();
+                    pc.printf( "%f\r",temp_true);
 
-
-            pc.printf("Mbed Temp SHT\r");
+                }
+                MAX31850_Start_meas(gSensorIDs[n][num_sensor],n);
+                break;
+            case '3':
+                n=0;
+                num_sensor=2;
+                uint64_owID = uint64_id(&gSensorIDs[n][num_sensor][0]);
+                for (uint8_t i=0 ; i< MAX31850_SP_SIZE; i++ )
+                    sp[i]=0;
+                MAX31850_Read_Scratch(gSensorIDs[n][num_sensor],sp,n) ;
+                err = MAX31850_Temp_TC(sp,&temp);
+                if(err) {
+                    pc.printf( "-1.0\r ");
+                } else {
+                    float temp_CJ;
+                    double temp_true;
+                    MAX31850_Temp_CJ(sp,&temp_CJ);
+                    MAX31850_Temp_TRUE(sp,&temp_true);
+                    temp_true=temp_true-mMax31850[uint64_owID]->Get_offset();
+                    pc.printf( "%f\r",temp_true);
 
-            break;
+                }
+                MAX31850_Start_meas(gSensorIDs[n][num_sensor],n);
+                break;
+        }
+    }
 
+    if(c=='*') {
+        pc.printf("Mbed Temp tk\r");
     }
 
 }