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:
- 55:bdab541f434d
- Parent:
- 53:1c61cadbcb35
- Child:
- 56:218601547d13
diff -r 0b435781fa52 -r bdab541f434d source/main.cpp --- a/source/main.cpp Fri Mar 30 11:59:29 2018 +0000 +++ b/source/main.cpp Fri Mar 30 13:05:13 2018 +0000 @@ -9,6 +9,9 @@ /* PWM Test Tool */ int channel; int dutyCycle; +int day; +int moment; +s_user user[2]; int main() { @@ -68,7 +71,7 @@ /* init PWM board */ case 44: - pc.printf("Init PWM\r\n"); + printf("Init PWM\r\n"); initPWM(50); enableOutput(); state = 47; @@ -84,76 +87,104 @@ time.weekday = 2; time.month = 3; time.year = 18; - pc.printf("set now time\r\n"); + printf("set now time\r\n"); setTime(&time); - pc.printf("read time: %02d:%02d:%02d, %02d.%02d.20%02d, weekday: %d\r\n",time.hour, time.minute, time.second, time.day, time.month, time.year, time.weekday); + printf("read time: %02d:%02d:%02d, %02d.%02d.20%02d, weekday: %d\r\n",time.hour, time.minute, time.second, time.day, time.month, time.year, time.weekday); state = 47; - pc.printf("change state to: %d\r\n",state); + printf("change state to: %d\r\n",state); break; /* Time test tool: get Time */ case 46: wait(5); time = getTime(); - pc.printf("read time: %02d:%02d:%02d, %02d.%02d.20%02d, weekday: %d\r\n",time.hour, time.minute, time.second, time.day, time.month, time.year, time.weekday); + printf("read time: %02d:%02d:%02d, %02d.%02d.20%02d, weekday: %d\r\n",time.hour, time.minute, time.second, time.day, time.month, time.year, time.weekday); state = 47; break; /* Console State Switch */ case 47: - pc.printf("\n\rState Switch: Enter next State: \n\r"); - pc.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\r"); + 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"); pc.scanf("%d", &state); - pc.printf("Switch to State %d\n\r",state); + printf("Switch to State %d\n\r",state); fflush(stdin); break; /* Servo-Board Test Tool */ case 48: - pc.printf("\n\r\n\rServo-Board Test Tool\n\rEnter Channel Number and then Duty Cycle\n\r"); - pc.printf("for exit, enter Channel > 15\n\r"); + printf("\n\r\n\rServo-Board Test Tool\n\rEnter Channel Number and then Duty Cycle\n\r"); + printf("for exit, enter Channel > 15\n\r"); channel = 0; while (channel < 16) { - pc.printf("Channel Number: "); + printf("Channel Number: "); pc.scanf("%d", &channel); - pc.printf("\r\nchannel: %d\n\rDuty Cycle 0..4095: ",channel); + printf("\r\nchannel: %d\n\rDuty Cycle 0..4095: ",channel); pc.scanf("%d", &dutyCycle); - pc.printf("\n\r%d\n\r",dutyCycle); + printf("\n\r%d\n\r",dutyCycle); setPWM((char)channel, (int)dutyCycle); fflush(stdin); } - pc.printf("leave Servo-Board Test Tool\n\r"); + printf("leave Servo-Board Test Tool\n\r"); state = 47; break; case 49: enableOutput(); - pc.printf("Servo output enabled\r\n\n"); + printf("Servo output enabled\r\n\n"); state = 47; break; case 50: disableOutput(); - pc.printf("Servo output disabled\r\n\n"); + printf("Servo output disabled\r\n\n"); state = 47; break; case 51: testSd(); - pc.printf("\rSD Card test finished\r\n\n"); + printf("\rSD Card test finished\r\n\n"); + state = 47; + break; + + case 52: + user[0] = readMedication(0); + if(user[0].valid) { + printf("\rtest read successful\r\n\n"); + } else { + printf("\rread failed\r\n\n"); + } state = 47; break; - - case 52: - readMedication(0); - pc.printf("\rMedication testread finished\r\n\n"); - state = 47; - break; + + case 53: + if(user[0].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"); + printf("Enter Day (0..6) and Moment (0..4)\r\nTo exit enter Day > 6:\r\n"); + day = 0; + while (day < 7) { + printf("\r\nDay Number: "); + pc.scanf("%d", &day); + if(day < 7) { + printf("\r\nDay: %d\n\rMoment 0..3: ",day); + 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[0].medication.day[day].moment[moment].medContainer.container[i]); + } + } + printf("\r\n"); + fflush(stdin); + } + printf("exit Tool\n\r"); + } default: state = 47; /* Go to State Switch */ break; } } - pc.printf("exit while 1 loop"); + printf("exit while 1 loop"); } \ No newline at end of file