trabalho

Dependencies:   X_NUCLEO_IKS01A1 mbed-rtos mbed

Fork of HelloWorld_IKS01A1 by ST

Revision:
29:f96590e6058d
Child:
31:eb7320bd1d37
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/userInteractions.cpp	Mon May 09 01:42:41 2016 +0000
@@ -0,0 +1,124 @@
+#include "buffer.cpp"
+
+struct tm t;
+
+ class UserMethods {
+    Buffer buffer;
+  
+  public: 
+         
+    int readAll() {
+        //Check if there are samples
+        int32_t Nsamples = samplesInBuffer->wait();
+        
+        Buffer::log_data log;
+        int count = buffer.newestIndex;
+        int nOfRecords = 0;
+        
+        while(count >= buffer.oldestIndex){
+            log = buffer[count];
+            
+            printf("Record %i \nDate: %s, Temp Celcius: %s, Temp Farenheit: %s, Humidity: %s, 
+            "Pressure: , Accelerometer: %s, Gyroscope: %s, Magnetometer: %s\n\n", log->id, 
+            log->date, log->tempCelcius, log->tempFarenheit, log->humidity, 
+            log->pressure, log->accelerometer, log->gyroscope, log->magnetometer);
+
+            count--;
+            nOfRecords++;
+        }
+        
+        return nOfRecords;
+    }
+
+    int deleteAll() {
+        int n = mail.count;
+        mail.recv_thread(n);
+        //int numRecords;
+        return n;
+    }
+
+    int readN(int n) {
+        //Check if there are samples
+        int32_t Nsamples = samplesInBuffer->wait();
+        
+        Buffer::log_data log;
+        int count = buffer.newestIndex;
+        int nOfRecords = 0;
+        
+        while(count >= n){
+            log = buffer[count];
+            
+            printf("Record %i \nDate: %s, Temp Celcius: %s, Temp Farenheit: %s, Humidity: %s, 
+            "Pressure: , Accelerometer: %s, Gyroscope: %s, Magnetometer: %s\n\n", log->id, 
+            log->date, log->tempCelcius, log->tempFarenheit, log->humidity, 
+            log->pressure, log->accelerometer, log->gyroscope, log->magnetometer);
+
+            count--;
+            nOfRecords++;
+        }
+        
+        return nOfRecords;
+    }
+
+    int deleteN(int n) {
+        mail.recv_thread(n);       
+        //int numRecords;
+        return n;
+    }
+
+    bool setDate() {
+        bool success;
+        printf("Enter current date : \n");
+        printf( "YYYY MM DD [enter] \n");
+        scanf ("%d %d %d", &t.tm_year, &t.tm_mon, &t.tm_mday);
+
+        // adjust for tm structure required values
+        t.tm_year = t.tm_year - 1900;
+        t.tm_mon = t.tm_mon - 1;
+        // set the time
+        set_time(mktime(&t));
+        success= true;
+
+        return success;
+    }
+
+    bool setTime () {
+        bool success = false;
+
+        // get the current time from the terminal
+        printf("Enter current time:\n");
+        printf("HH MM SS[enter]\n");
+        scanf("%d %d %d", &t.tm_hour, &t.tm_min, &t.tm_sec);
+
+        printf("TIME UPDATED TO %d:%d:%d\n", t.tm_hour, t.tm_min, t.tm_sec);
+
+        // set the time
+        set_time(mktime(&t));
+        success = true;
+
+        return success;
+    }
+
+    void setT(int timePeriod) {
+        scanf("Enter sampling period: %d\n", &timePeriod);
+    }
+    /*
+    void state(char x){
+        printf("Sampling is %s\n", x);
+        printf("Enter state:\n");
+        scanf("%s", x);
+    }*/
+
+    bool logTime (int time, bool state) {
+        return state;
+    }
+
+    bool debugMessages (bool state) {
+        return state;
+    }
+
+    bool  logging(bool state) {
+        return state;
+    }
+       
+ };
\ No newline at end of file