Final MEMBITT Code
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed
Fork of reminder_main by
utils.h@1:29de429a7e15, 2016-12-05 (annotated)
- Committer:
- deronmai
- Date:
- Mon Dec 05 20:06:56 2016 +0000
- Revision:
- 1:29de429a7e15
- Parent:
- 0:fef6b4d65600
final code bar all issues
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
deronmai | 1:29de429a7e15 | 1 | const int REMINDER_SIZE = 17; |
deronmai | 1:29de429a7e15 | 2 | |
deronmai | 1:29de429a7e15 | 3 | |
deronmai | 1:29de429a7e15 | 4 | // speech synthesis |
deronmai | 1:29de429a7e15 | 5 | //1 2 3 4 5 6 7 8 9 10 11 12 15 50 40 30 20 |
deronmai | 1:29de429a7e15 | 6 | static const int synTime[] = {11, 19, 16, 7, 5, 21, 13, 1, 8, 14, 2, 17, 3, 4, 6, 15, 18}; |
deronmai | 1:29de429a7e15 | 7 | //o'clock, OH, reminder, appointment, AM, PM, Taken Meds?, Thank You |
deronmai | 1:29de429a7e15 | 8 | static const int synWords[] = {9, 10, 12, 20 ,22, 24, 23, 25}; |
deronmai | 1:29de429a7e15 | 9 | |
deronmai | 1:29de429a7e15 | 10 | enum Day {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}; |
deronmai | 1:29de429a7e15 | 11 | |
deronmai | 0:fef6b4d65600 | 12 | struct reminder { |
deronmai | 1:29de429a7e15 | 13 | //struct tm tm_time; |
deronmai | 1:29de429a7e15 | 14 | int hour; |
deronmai | 1:29de429a7e15 | 15 | int min; |
deronmai | 0:fef6b4d65600 | 16 | int reminder_days[7]; /* set all days to 0. If day is used, set to 1 |
deronmai | 0:fef6b4d65600 | 17 | If no day specified (ie every day), set all to 1 */ |
deronmai | 0:fef6b4d65600 | 18 | //time_t timet_time; // represents the number of seconds since the start of the Unix epoch: midnight UTC of January 1, 1970 |
deronmai | 1:29de429a7e15 | 19 | string notification; |
deronmai | 1:29de429a7e15 | 20 | int taken; |
deronmai | 1:29de429a7e15 | 21 | int nottaken; |
deronmai | 1:29de429a7e15 | 22 | }; |
deronmai | 1:29de429a7e15 | 23 | |
deronmai | 1:29de429a7e15 | 24 | struct dateTime { |
deronmai | 1:29de429a7e15 | 25 | int month; |
deronmai | 1:29de429a7e15 | 26 | int day; |
deronmai | 1:29de429a7e15 | 27 | int year; |
deronmai | 1:29de429a7e15 | 28 | }; |
deronmai | 1:29de429a7e15 | 29 | |
deronmai | 1:29de429a7e15 | 30 | struct record { |
deronmai | 1:29de429a7e15 | 31 | vector<struct dateTime> date; |
deronmai | 1:29de429a7e15 | 32 | vector<int> data; |
deronmai | 1:29de429a7e15 | 33 | int record_number; |
deronmai | 1:29de429a7e15 | 34 | }; |
deronmai | 1:29de429a7e15 | 35 | |
deronmai | 1:29de429a7e15 | 36 | |
deronmai | 1:29de429a7e15 | 37 | class schedule |
deronmai | 1:29de429a7e15 | 38 | { |
deronmai | 1:29de429a7e15 | 39 | // will be ordered by time - should do this processing on the desktop |
deronmai | 1:29de429a7e15 | 40 | vector<struct reminder> reminder_list; |
deronmai | 1:29de429a7e15 | 41 | int size; |
deronmai | 1:29de429a7e15 | 42 | int index; |
deronmai | 1:29de429a7e15 | 43 | vector<struct record> schedule_record; |
deronmai | 1:29de429a7e15 | 44 | public: |
deronmai | 1:29de429a7e15 | 45 | schedule(); |
deronmai | 1:29de429a7e15 | 46 | void addReminder(reminder); |
deronmai | 1:29de429a7e15 | 47 | reminder getCurrentReminder(); |
deronmai | 1:29de429a7e15 | 48 | reminder nextReminder(); |
deronmai | 1:29de429a7e15 | 49 | int getSize(); |
deronmai | 1:29de429a7e15 | 50 | void updateRecord(struct dateTime rDate, int dataIn); |
deronmai | 1:29de429a7e15 | 51 | int getNumRecords(int recordnum); |
deronmai | 1:29de429a7e15 | 52 | record getRecord(int recordnum); |
deronmai | 1:29de429a7e15 | 53 | }; |
deronmai | 1:29de429a7e15 | 54 | |
deronmai | 1:29de429a7e15 | 55 | schedule::schedule() |
deronmai | 1:29de429a7e15 | 56 | { |
deronmai | 1:29de429a7e15 | 57 | size = 0; |
deronmai | 1:29de429a7e15 | 58 | index = 0; |
deronmai | 1:29de429a7e15 | 59 | } |
deronmai | 1:29de429a7e15 | 60 | |
deronmai | 1:29de429a7e15 | 61 | void schedule::addReminder(reminder add) |
deronmai | 1:29de429a7e15 | 62 | { |
deronmai | 1:29de429a7e15 | 63 | reminder_list.push_back(add); |
deronmai | 1:29de429a7e15 | 64 | size++; |
deronmai | 1:29de429a7e15 | 65 | // create record for every new reminder |
deronmai | 1:29de429a7e15 | 66 | record tmp; |
deronmai | 1:29de429a7e15 | 67 | tmp.record_number = size - 1; // record numbers start at 0; |
deronmai | 1:29de429a7e15 | 68 | schedule_record.push_back(tmp); |
deronmai | 1:29de429a7e15 | 69 | } |
deronmai | 1:29de429a7e15 | 70 | |
deronmai | 1:29de429a7e15 | 71 | reminder schedule::getCurrentReminder() |
deronmai | 1:29de429a7e15 | 72 | { |
deronmai | 1:29de429a7e15 | 73 | /* |
deronmai | 1:29de429a7e15 | 74 | if (size > index) { |
deronmai | 1:29de429a7e15 | 75 | index++; |
deronmai | 1:29de429a7e15 | 76 | return reminder_list[index]; |
deronmai | 1:29de429a7e15 | 77 | } |
deronmai | 1:29de429a7e15 | 78 | else { |
deronmai | 1:29de429a7e15 | 79 | if (index != 0) { |
deronmai | 1:29de429a7e15 | 80 | index = 0; |
deronmai | 1:29de429a7e15 | 81 | return reminder_list[index]; |
deronmai | 1:29de429a7e15 | 82 | } |
deronmai | 1:29de429a7e15 | 83 | //return -1; |
deronmai | 1:29de429a7e15 | 84 | } |
deronmai | 1:29de429a7e15 | 85 | // should throw error here... |
deronmai | 1:29de429a7e15 | 86 | reminder emptyReminder; |
deronmai | 1:29de429a7e15 | 87 | return emptyReminder;*/ |
deronmai | 1:29de429a7e15 | 88 | return reminder_list[index]; |
deronmai | 1:29de429a7e15 | 89 | } |
deronmai | 1:29de429a7e15 | 90 | |
deronmai | 1:29de429a7e15 | 91 | int schedule::getSize() |
deronmai | 1:29de429a7e15 | 92 | { |
deronmai | 1:29de429a7e15 | 93 | return size; |
deronmai | 1:29de429a7e15 | 94 | } |
deronmai | 1:29de429a7e15 | 95 | |
deronmai | 1:29de429a7e15 | 96 | reminder schedule::nextReminder() |
deronmai | 1:29de429a7e15 | 97 | { |
deronmai | 1:29de429a7e15 | 98 | if (index < (size - 1)) |
deronmai | 1:29de429a7e15 | 99 | index++; |
deronmai | 1:29de429a7e15 | 100 | else index = 0; |
deronmai | 1:29de429a7e15 | 101 | return reminder_list[index]; |
deronmai | 1:29de429a7e15 | 102 | } |
deronmai | 1:29de429a7e15 | 103 | |
deronmai | 1:29de429a7e15 | 104 | void schedule::updateRecord(struct dateTime dateIn, int dataIn) |
deronmai | 1:29de429a7e15 | 105 | { |
deronmai | 1:29de429a7e15 | 106 | schedule_record[index].date.push_back(dateIn); |
deronmai | 1:29de429a7e15 | 107 | schedule_record[index].data.push_back(dataIn); |
deronmai | 1:29de429a7e15 | 108 | } |
deronmai | 1:29de429a7e15 | 109 | |
deronmai | 1:29de429a7e15 | 110 | int schedule::getNumRecords(int recordnum) |
deronmai | 1:29de429a7e15 | 111 | // returns how many data entries are in a record |
deronmai | 1:29de429a7e15 | 112 | { |
deronmai | 1:29de429a7e15 | 113 | return schedule_record[recordnum].data.size(); |
deronmai | 1:29de429a7e15 | 114 | } |
deronmai | 1:29de429a7e15 | 115 | |
deronmai | 1:29de429a7e15 | 116 | record schedule::getRecord(int recordnum) |
deronmai | 1:29de429a7e15 | 117 | { |
deronmai | 1:29de429a7e15 | 118 | return schedule_record[recordnum]; |
deronmai | 1:29de429a7e15 | 119 | } |