3rd Repo, trying to figure this out.

Dependencies:   LPS25H hts221

Fork of SOFT253_Template_Weather_OS_54 by Stage-1 Students SoCEM

Revision:
69:72f237750d85
Parent:
68:d3765f93c16a
Child:
70:ee19a73ed215
diff -r d3765f93c16a -r 72f237750d85 main.cpp
--- a/main.cpp	Thu Apr 13 11:07:14 2017 +0000
+++ b/main.cpp	Fri Apr 21 17:34:29 2017 +0000
@@ -130,6 +130,7 @@
         
     }
 }
+int i;
 //
 //  Compares two char arrays and returns result
 //  Param1: First char Array / pointer
@@ -139,7 +140,7 @@
 //          "1 " IF EQUAL
 int CompareCommands(char command[],char targetcommand[], int size)
 {
-       int i;
+       i;
        for(i = 0; i < size; i ++)
        {
             if(command[i] != targetcommand[i])
@@ -200,15 +201,16 @@
                     //Check if it's a "LIST X" command
                     else if(strtol(charPos,NULL,10) != 0)
                     {
-                        printf("\r\n Printing %i measures: \r\n",atoi(charPos));
+                        int num = atoi(charPos);
+                        printf("\r\n Printing %i measures: \r\n",num);
                         
                         // Changed to use circular buffer rather than list buffer
-                        buffer.readX(atoi(charPos));
+                        buffer.readX(num);
                         printf("\r\nD O N E ! \r\n");
                     }
                     else
                     {
-                        printf("Expected parameters: \"all\" | \"n\", where n is a number.");   
+                        printf("\n\rExpected parameters: \"all\" | \"n\", where n is a number.");   
                     }
                 }
                 //Check if it's a "DELETE" command
@@ -233,7 +235,7 @@
                     }
                     else
                     {
-                        printf("Expected parameters: \"all\" | \"n\", where n is a number.");     
+                        printf("\n\rExpected parameters: \"all\" | \"n\", where n is a number.");     
                     }
                        
                 }
@@ -244,9 +246,9 @@
                     
                     // Changed to use circular buffer rather than list buffer
                     if(logging == true)
-                        printf("\r\nSTATUS: \r\n   # of measures: %i \r\n   SAMPLING: ON \r\n   Current Date: %s \r\n   Sample Rate(s): %2.2f \r\n", buffer.getSize(),ptr,sampleRate);   
+                        printf("\r\nSTATUS: \r\n   # of measures: %i \r\n   SAMPLING: ON \r\n   Current Date: %s \r\n   Sample Rate(s): %2.2f \r\n", buffer.getSize(), ptr,sampleRate);   
                     else
-                        printf("\r\nSTATUS: \r\n   # of measures: %i \r\n   SAMPLING: OFF \r\n   Current Date: %s \r\n   Sample Rate(s): %2.2f \r\n", buffer.getSize(),ptr,sampleRate);  
+                        printf("\r\nSTATUS: \r\n   # of measures: %i \r\n   SAMPLING: OFF \r\n   Current Date: %s \r\n   Sample Rate(s): %2.2f \r\n", buffer.getSize(), ptr,sampleRate);  
                 }
                 //Check if it's a "SETTIME" command
                 else if (CompareCommands(charPos,"settime",7) == 1)
@@ -339,7 +341,7 @@
                     }
                     else
                     {
-                        printf("Expected parameters: \"on\" | \"off\"");   
+                        printf("\n\rExpected parameters: \"on\" | \"off\"");   
                     }
                 }
                 // Check if it's a "SETT" command
@@ -348,7 +350,8 @@
                     charPos = strtok(NULL," ,");
                     float auxRate = atof(charPos);
                     // Validate rate
-                    if(auxRate != 0 && auxRate > 0.01 && auxRate <= 60 )
+                    if(auxRate >= 0.01 && 
+                       auxRate <= 60 )
                     {
                         sampleRate = auxRate;
                         timer.detach();
@@ -358,7 +361,7 @@
                     // if rate is not valid, prompt:
                     else
                     {
-                        printf("\r\n Sample rate must be between greater than 0.1 or less equal than 60. \r\n");    
+                        printf("\r\n Sample rate must be between 0.1 and 60. \r\n");    
                     }
                 }
                 // Check if it's a "HELP" command