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.
Dependencies: SDFileSystem mbed
Fork of PES4_Programme by
Diff: source/sdcard.cpp
- Revision:
- 55:bdab541f434d
- Parent:
- 53:1c61cadbcb35
- Child:
- 56:218601547d13
--- a/source/sdcard.cpp	Fri Mar 30 11:59:29 2018 +0000
+++ b/source/sdcard.cpp	Fri Mar 30 13:05:13 2018 +0000
@@ -185,20 +185,30 @@
                 printf("done!\r\n");
                 printf("\tside:\t\t%d \n\r\tFirst Name:\t%s \n\r\tLast Name:\t%s \n\r",userfile.side, userfile.firstName,userfile.secondName);
                 break;
-            case 2:
-                printf("Reading Line 2...");
-                int mo = atoi(strtok(string, TOKEN));
-                int lu = atoi(strtok(NULL, TOKEN));
-                int di = atoi(strtok(NULL, TOKEN));
-                int ev = atoi(strtok(NULL, TOKEN));
+            default:
+                printf("reading medication %d...",(linecounter-1));
+                int moment[4];
+
+                moment[0] = atoi(strtok(string, TOKEN));
+                moment[1] = atoi(strtok(NULL, TOKEN));
+                moment[2] = atoi(strtok(NULL, TOKEN));
+                moment[3] = atoi(strtok(NULL, TOKEN));
+
+                for(int i = 0; i<4; i++) {
+                    for( int ii = 0; ii<6; ii++) {
+                        userfile.medication.day[linecounter-2].moment[i].medContainer.container[ii] = moment[i] % 10;
+                        moment[i] = moment[i]/10;
+                    }
+                }
                 printf("done!\r\n");
-                printf("\tMedication for Monday:\r\n\tmorning:\t%06d\r\n\tlunch:\t\t%06d\r\n\tdinner:\t\t%06d\r\n\tevening:\t%06d\r\n",mo,lu,di,ev);
-                break;
-            default:
                 break;
         }
         linecounter++;
     }
+
+    //Unmount the SD card
+    sd.unmount();
+
     userfile.valid = true;
     return userfile;
 }
\ No newline at end of file
    