Radu-Adrian Marcu / Mbed OS SOFT253_GroupA_AssignmentRepo

Dependencies:   LPS25H hts221

Fork of SOFT253_Template_Weather_OS_54 by Stage-1 Students SoCEM

Files at this revision

API Documentation at this revision

Comitter:
FairyMental
Date:
Thu Apr 06 11:07:40 2017 +0000
Parent:
43:3983059e0d91
Child:
45:9a33f2bc2b4e
Commit message:
Implemented Delete all / Delete X commands.

Changed in this revision

LinkedList.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/LinkedList.cpp	Thu Apr 06 10:48:12 2017 +0000
+++ b/LinkedList.cpp	Thu Apr 06 11:07:40 2017 +0000
@@ -93,7 +93,10 @@
         {
             Node *n = head;
             head = head->next;
+            
             delete n;
+            
+            i++;
         }   
         size -= x;
     }
\ No newline at end of file
--- a/main.cpp	Thu Apr 06 10:48:12 2017 +0000
+++ b/main.cpp	Thu Apr 06 11:07:40 2017 +0000
@@ -124,17 +124,17 @@
         charCmd = getchar();
         if(charCmd != NULL)
         {
-            if (charCmd == 127 && crtChar > 0 )
+            if (charCmd == 127 && crtChar > 0 ) // If Backspace is pressed
             {
                 printf("%c",charCmd);
                 command[--crtChar] = '\0';   
             }
-            else if(charCmd != 13 && charCmd != 127)
+            else if(charCmd != 13 && charCmd != 127) // If NOT enter AND NOT Backspace is pressed
             {
                 command[crtChar++] = charCmd;
                 printf("%c",charCmd);
             }
-            else if(charCmd == 13)
+            else if(charCmd == 13) // If Enter is pressed
             {
                 printf("\r\n\r\nCommand entered: %s\r\n", command);
                 
@@ -147,13 +147,32 @@
                     charPos = strtok(NULL," -,");
                     if(CompareCommands(charPos, "all",3) == 1)
                     {
+                        printf("\r\n Printing all measures performed so far: \r\n");
                         listBuffer->ListAll();   
+                        printf("\r\n D O N E ! \r\n");
                     }
                     else if(strtol(charPos,NULL,10) != 0)
                     {
                         listBuffer->ListX(atoi(charPos));   
+                        printf("\r\n D O N E ! \r\n");
                     }
                 }
+                else if (CompareCommands(charPos,"delete",6) == 1)
+                {
+                    charPos = strtok(NULL," -,");
+                    if(CompareCommands(charPos,"all",3) == 1)
+                    {
+                        printf("\r\n Deleting all measures performed so far: \r\n");
+                        listBuffer->DeleteAll();
+                        printf("\r\n D O N E ! \r\n");
+                    }
+                    else if (strtol(charPos,NULL,10) != 0)
+                    {
+                        listBuffer->DeleteX(atoi(charPos));
+                        printf("\r\n D O N E ! \r\n");
+                    }
+                       
+                }
               //  printf("%s \r\n", charPos);
               //  charPos = strtok(NULL," -,");
                 
@@ -188,7 +207,7 @@
    
     //Hook up timer interrupt   
     Ticker timer; 
-    timer.attach(&SendSignalDoMeasure, 5.0);
+    timer.attach(&SendSignalDoMeasure, 2.0);
                
     //Threads
     produceThread = new Thread();