Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SOFT253_Template_Weather_OS_54 by
Revision 44:b523c9a9dd97, committed 2017-04-06
- 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();
