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/main.cpp
- Revision:
- 76:53a25f1dc2b6
- Parent:
- 71:3d0a4dbff536
- Parent:
- 74:a4dacab0d3dd
- Child:
- 79:c825bd2dea81
--- a/source/main.cpp Fri Apr 06 11:59:29 2018 +0000 +++ b/source/main.cpp Fri Apr 06 16:41:39 2018 +0000 @@ -19,13 +19,35 @@ int dutyCycle; int day; int moment; -s_user user[2]; +s_user prescription[2]; /* Demo Tool */ uint32_t color = 0; int colorTime = 0; int r,b,g; +/* SD write Test*/ + +s_time medicationTime; +s_time outputTime; +s_medContainer medication; +s_medContainer medInventory; +s_time currentTime; + +int success = 1; + +char user = 0; + +char med1[] = "A"; +char med2[] = "B"; +char med3[] = "C"; +char med4[] = "D"; +char med5[] = "E"; +char med6[] = "F"; + +char fail[] = "shit happens"; +/*********/ + void summ(void) { if(summer.read()>0) { @@ -38,6 +60,40 @@ int main() { + /* SD write Test*/ + medicationTime.hour = 15; + medicationTime.minute = 30; + + outputTime.day = getTime().day; + outputTime.month = getTime().month; + outputTime.year = getTime().year; + outputTime.hour = getTime().hour; + outputTime.minute = getTime().minute; + + + medication.container[0] = 1; + medication.container[1] = 2; + medication.container[2] = 2; + medication.container[3] = 1; + medication.container[4] = 1; + medication.container[5] = 2; + + + medInventory.container[0] = 5; + medInventory.container[1] = 10; + medInventory.container[2] = 15; + medInventory.container[3] = 20; + medInventory.container[4] = 25; + medInventory.container[5] = 30; + + + currentTime.day = getTime().day; + currentTime.month = getTime().month; + currentTime.year = getTime().year; + currentTime.hour = getTime().hour; + currentTime.minute = getTime().minute; + /************/ + pc.baud(460800); printf("start...\r\n"); @@ -60,8 +116,6 @@ case 10: break; - - case 11: break; @@ -91,6 +145,7 @@ case 38: break; + /**************************************************************/ /* Test Zone */ @@ -130,8 +185,13 @@ /* Console State Switch */ case 47: printf("\n\rState Switch: Enter next State: \n\r"); - printf("45\tset Time\n\r46\tread Time\n\r47\tState Switch\n\r48\tServo Board Test Tool\n\r49\tenable servo output\n\r50\tdisable servo output\n\r51\ttest SD Card\n\r52\tread medication\n\r53\tMedication display test tool\n\r"); + printf("45\tset Time\n\r46\tread Time\n\r47\tState Switch\n\r48\tServo Board Test Tool\n\r"); + printf("49\tenable servo output\n\r50\tdisable servo output\n\r"); + printf("51\ttest SD Card\n\r52\tread medication\n\r53\tMedication display test tool\n\r"); printf("54\tWrite Medication\n\r55\tDemo Tool for Summer and RGB LED\n\r"); + printf("60\t \n\r"); + printf("61\t \n\r"); + printf("62\t \n\r"); pc.scanf("%d", &state); printf("Switch to State %d\n\r",state); fflush(stdin); @@ -175,8 +235,8 @@ case 52: - user[1] = readMedication(1); - if(user[1].valid) { + prescription[1] = readMedication(1); + if(prescription[1].valid) { printf("\rread successful\r\n\n"); } else { printf("\rread failed\r\n\n"); @@ -185,7 +245,7 @@ break; case 53: - if(user[1].valid == false) { + if(prescription[1].valid == false) { printf("\r\nNo valid data in struct, try to run case 52\r\n\n"); } else { printf("\r\nMedication display test tool:\r\n"); @@ -199,9 +259,9 @@ pc.scanf("%d", &moment); printf("\r\nMedication for weekday %d Moment %d is ",day,moment); for(int i=0; i<6; i++) { - printf("%d", user[1].medication.day[day].moment[moment].medContainer.container[i]); + printf("%d", prescription[1].medication.day[day].moment[moment].medContainer.container[i]); } - printf("\r\nThe alarm clock is set for %02d:%02d",user[1].medication.day[day].moment[moment].time.hour,user[1].medication.day[day].moment[moment].time.minute); + printf("\r\nThe alarm clock is set for %02d:%02d",prescription[1].medication.day[day].moment[moment].time.hour,prescription[1].medication.day[day].moment[moment].time.minute); } printf("\r\n"); fflush(stdin); @@ -211,7 +271,7 @@ state = 47; break; case 54: - writeMedication(0,user[1]); + writeMedication(0,prescription[1]); state = 47; break; case 55: @@ -282,6 +342,31 @@ printf("exit demo tool\n\r"); break; + + case 60: + printf("write_medProtocol\n\r"); + write_medProtocol(medicationTime, outputTime, medication, success, user); + printf("done\n\r"); + state = 47; + + break; + + case 61: + printf("write_medInventory\n\r"); + write_medInventory(medInventory,currentTime,med1,med2,med3,med4,med5,med6); + printf("done\n\r"); + state = 47; + + break; + + case 62: + printf("write_medError\n\r"); + write_medError(fail, time); + printf("done\n\r"); + state = 47; + + break; + default: state = 47; /* Go to State Switch */ break;