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
source/main.cpp@81:a869abf56e85, 2018-04-08 (annotated)
- Committer:
- itslinear
- Date:
- Sun Apr 08 20:27:20 2018 +0000
- Revision:
- 81:a869abf56e85
- Parent:
- 80:6e3eb8246ced
- Child:
- 82:2fc026430ff2
erase and read file added
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cittecla | 3:94026b29e994 | 1 | #include "main.h" |
aeschsim | 59:1867088695f3 | 2 | #define FADESPEED 5 |
aeschsim | 59:1867088695f3 | 3 | #define DEMOTIME 5 |
itslinear | 17:bbafd216e059 | 4 | |
cittecla | 52:701d0c2f47d7 | 5 | int state = 44; |
cittecla | 41:f054a83f9556 | 6 | int oldState; |
cittecla | 2:72886e996098 | 7 | |
cittecla | 2:72886e996098 | 8 | Serial pc(USBTX, USBRX); // tx, rx |
aeschsim | 40:b5e533e1e033 | 9 | |
aeschsim | 60:7554e4272b3b | 10 | DigitalIn lichtschranke(PC_5); |
aeschsim | 60:7554e4272b3b | 11 | InterruptIn userButton1(PB_5); |
aeschsim | 60:7554e4272b3b | 12 | InterruptIn userButton2(PB_4); |
aeschsim | 60:7554e4272b3b | 13 | DigitalIn glasDetection(PA_10); |
aeschsim | 60:7554e4272b3b | 14 | PwmOut summer(PC_8); |
aeschsim | 59:1867088695f3 | 15 | |
aeschsim | 40:b5e533e1e033 | 16 | /* PWM Test Tool */ |
aeschsim | 40:b5e533e1e033 | 17 | int channel; |
aeschsim | 40:b5e533e1e033 | 18 | int dutyCycle; |
cittecla | 55:bdab541f434d | 19 | int day; |
cittecla | 55:bdab541f434d | 20 | int moment; |
itslinear | 73:7fd3701def5b | 21 | s_user prescription[2]; |
cittecla | 2:72886e996098 | 22 | |
aeschsim | 59:1867088695f3 | 23 | /* Demo Tool */ |
aeschsim | 59:1867088695f3 | 24 | uint32_t color = 0; |
aeschsim | 59:1867088695f3 | 25 | int colorTime = 0; |
aeschsim | 59:1867088695f3 | 26 | int r,b,g; |
aeschsim | 59:1867088695f3 | 27 | |
itslinear | 72:172b40dd16ee | 28 | /* SD write Test*/ |
itslinear | 72:172b40dd16ee | 29 | |
itslinear | 72:172b40dd16ee | 30 | s_time medicationTime; |
itslinear | 72:172b40dd16ee | 31 | s_time outputTime; |
itslinear | 81:a869abf56e85 | 32 | //s_time currentTime; |
itslinear | 72:172b40dd16ee | 33 | s_medContainer medication; |
itslinear | 80:6e3eb8246ced | 34 | //s_medContainer medInventory; |
itslinear | 80:6e3eb8246ced | 35 | s_medInventory medInventory; |
itslinear | 72:172b40dd16ee | 36 | |
itslinear | 72:172b40dd16ee | 37 | int success = 1; |
itslinear | 73:7fd3701def5b | 38 | |
itslinear | 80:6e3eb8246ced | 39 | char user = 1; |
itslinear | 80:6e3eb8246ced | 40 | /* |
itslinear | 73:7fd3701def5b | 41 | char med1[] = "A"; |
itslinear | 73:7fd3701def5b | 42 | char med2[] = "B"; |
itslinear | 73:7fd3701def5b | 43 | char med3[] = "C"; |
itslinear | 73:7fd3701def5b | 44 | char med4[] = "D"; |
itslinear | 73:7fd3701def5b | 45 | char med5[] = "E"; |
itslinear | 73:7fd3701def5b | 46 | char med6[] = "F"; |
itslinear | 80:6e3eb8246ced | 47 | */ |
itslinear | 80:6e3eb8246ced | 48 | char fail[] = "shit happens"; |
itslinear | 73:7fd3701def5b | 49 | |
itslinear | 80:6e3eb8246ced | 50 | char *send; |
itslinear | 80:6e3eb8246ced | 51 | |
itslinear | 73:7fd3701def5b | 52 | /*********/ |
itslinear | 73:7fd3701def5b | 53 | |
aeschsim | 60:7554e4272b3b | 54 | void summ(void) |
aeschsim | 60:7554e4272b3b | 55 | { |
aeschsim | 60:7554e4272b3b | 56 | if(summer.read()>0) { |
aeschsim | 60:7554e4272b3b | 57 | summer.write(0.0f); |
aeschsim | 60:7554e4272b3b | 58 | } else { |
aeschsim | 60:7554e4272b3b | 59 | summer.write(0.5f); |
aeschsim | 60:7554e4272b3b | 60 | } |
aeschsim | 60:7554e4272b3b | 61 | } |
aeschsim | 60:7554e4272b3b | 62 | |
aeschsim | 60:7554e4272b3b | 63 | |
cittecla | 2:72886e996098 | 64 | int main() |
cittecla | 2:72886e996098 | 65 | { |
itslinear | 73:7fd3701def5b | 66 | /* SD write Test*/ |
itslinear | 80:6e3eb8246ced | 67 | |
itslinear | 77:c2e22d1e5d44 | 68 | medicationTime = getTime(); |
itslinear | 73:7fd3701def5b | 69 | |
itslinear | 77:c2e22d1e5d44 | 70 | outputTime = getTime(); |
itslinear | 80:6e3eb8246ced | 71 | |
itslinear | 73:7fd3701def5b | 72 | medication.container[0] = 1; |
itslinear | 73:7fd3701def5b | 73 | medication.container[1] = 2; |
itslinear | 73:7fd3701def5b | 74 | medication.container[2] = 2; |
itslinear | 73:7fd3701def5b | 75 | medication.container[3] = 1; |
itslinear | 73:7fd3701def5b | 76 | medication.container[4] = 1; |
itslinear | 73:7fd3701def5b | 77 | medication.container[5] = 2; |
itslinear | 80:6e3eb8246ced | 78 | /* |
itslinear | 80:6e3eb8246ced | 79 | medInventory.container[0] = 5; |
itslinear | 80:6e3eb8246ced | 80 | medInventory.container[1] = 10; |
itslinear | 80:6e3eb8246ced | 81 | medInventory.container[2] = 15; |
itslinear | 80:6e3eb8246ced | 82 | medInventory.container[3] = 20; |
itslinear | 80:6e3eb8246ced | 83 | medInventory.container[4] = 25; |
itslinear | 80:6e3eb8246ced | 84 | medInventory.container[5] = 30; |
itslinear | 80:6e3eb8246ced | 85 | */ |
itslinear | 73:7fd3701def5b | 86 | /************/ |
itslinear | 73:7fd3701def5b | 87 | |
cittecla | 2:72886e996098 | 88 | pc.baud(460800); |
cittecla | 2:72886e996098 | 89 | printf("start...\r\n"); |
cittecla | 2:72886e996098 | 90 | |
aeschsim | 34:9d6dd3a12641 | 91 | while(1) { |
cittecla | 41:f054a83f9556 | 92 | if(state != oldState) { |
cittecla | 58:cda5298c9b7f | 93 | printf("\r\nstate: %d\r\n",state); |
cittecla | 41:f054a83f9556 | 94 | oldState = state; |
aeschsim | 34:9d6dd3a12641 | 95 | } |
aeschsim | 34:9d6dd3a12641 | 96 | switch (state) { |
aeschsim | 34:9d6dd3a12641 | 97 | case 0: |
aeschsim | 34:9d6dd3a12641 | 98 | printf("Hello World"); |
aeschsim | 40:b5e533e1e033 | 99 | state = 47; |
aeschsim | 34:9d6dd3a12641 | 100 | break; |
itslinear | 73:7fd3701def5b | 101 | /* case 1: |
itslinear | 73:7fd3701def5b | 102 | break; |
itslinear | 73:7fd3701def5b | 103 | case 2: |
itslinear | 73:7fd3701def5b | 104 | break; |
itslinear | 73:7fd3701def5b | 105 | case 3: |
itslinear | 73:7fd3701def5b | 106 | break; |
cittecla | 2:72886e996098 | 107 | |
itslinear | 73:7fd3701def5b | 108 | case 10: |
itslinear | 73:7fd3701def5b | 109 | break; |
itslinear | 73:7fd3701def5b | 110 | case 11: |
itslinear | 73:7fd3701def5b | 111 | break; |
cittecla | 2:72886e996098 | 112 | |
itslinear | 73:7fd3701def5b | 113 | case 15: |
itslinear | 73:7fd3701def5b | 114 | break; |
itslinear | 73:7fd3701def5b | 115 | case 16: |
itslinear | 73:7fd3701def5b | 116 | break; |
itslinear | 73:7fd3701def5b | 117 | case 17: |
itslinear | 73:7fd3701def5b | 118 | break; |
aeschsim | 34:9d6dd3a12641 | 119 | |
itslinear | 73:7fd3701def5b | 120 | case 25: |
itslinear | 73:7fd3701def5b | 121 | break; |
itslinear | 73:7fd3701def5b | 122 | case 26: |
itslinear | 73:7fd3701def5b | 123 | break; |
itslinear | 73:7fd3701def5b | 124 | case 27: |
itslinear | 73:7fd3701def5b | 125 | break; |
itslinear | 73:7fd3701def5b | 126 | case 28: |
itslinear | 73:7fd3701def5b | 127 | break; |
cittecla | 2:72886e996098 | 128 | |
cittecla | 2:72886e996098 | 129 | |
itslinear | 73:7fd3701def5b | 130 | case 35: |
itslinear | 73:7fd3701def5b | 131 | break; |
itslinear | 73:7fd3701def5b | 132 | case 36: |
itslinear | 73:7fd3701def5b | 133 | break; |
itslinear | 73:7fd3701def5b | 134 | case 37: |
itslinear | 73:7fd3701def5b | 135 | break; |
itslinear | 73:7fd3701def5b | 136 | case 38: |
itslinear | 73:7fd3701def5b | 137 | break; |
itslinear | 73:7fd3701def5b | 138 | */ |
aeschsim | 40:b5e533e1e033 | 139 | /**************************************************************/ |
aeschsim | 40:b5e533e1e033 | 140 | /* Test Zone */ |
cittecla | 53:1c61cadbcb35 | 141 | |
cittecla | 52:701d0c2f47d7 | 142 | /* init PWM board */ |
cittecla | 52:701d0c2f47d7 | 143 | case 44: |
cittecla | 55:bdab541f434d | 144 | printf("Init PWM\r\n"); |
cittecla | 53:1c61cadbcb35 | 145 | initPWM(50); |
cittecla | 53:1c61cadbcb35 | 146 | enableOutput(); |
cittecla | 52:701d0c2f47d7 | 147 | state = 47; |
cittecla | 52:701d0c2f47d7 | 148 | break; |
aeschsim | 40:b5e533e1e033 | 149 | |
aeschsim | 40:b5e533e1e033 | 150 | /* Time test tool: set Time */ |
aeschsim | 34:9d6dd3a12641 | 151 | case 45: |
aeschsim | 34:9d6dd3a12641 | 152 | s_time time; |
aeschsim | 34:9d6dd3a12641 | 153 | time.second = 30; |
aeschsim | 34:9d6dd3a12641 | 154 | time.minute = 53; |
aeschsim | 34:9d6dd3a12641 | 155 | time.hour = 12; |
aeschsim | 34:9d6dd3a12641 | 156 | time.day = 27; |
aeschsim | 34:9d6dd3a12641 | 157 | time.weekday = 2; |
aeschsim | 34:9d6dd3a12641 | 158 | time.month = 3; |
aeschsim | 34:9d6dd3a12641 | 159 | time.year = 18; |
cittecla | 55:bdab541f434d | 160 | printf("set now time\r\n"); |
aeschsim | 34:9d6dd3a12641 | 161 | setTime(&time); |
cittecla | 55:bdab541f434d | 162 | 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); |
aeschsim | 40:b5e533e1e033 | 163 | state = 47; |
cittecla | 55:bdab541f434d | 164 | printf("change state to: %d\r\n",state); |
aeschsim | 34:9d6dd3a12641 | 165 | break; |
aeschsim | 40:b5e533e1e033 | 166 | |
aeschsim | 40:b5e533e1e033 | 167 | /* Time test tool: get Time */ |
aeschsim | 34:9d6dd3a12641 | 168 | case 46: |
aeschsim | 34:9d6dd3a12641 | 169 | wait(5); |
aeschsim | 34:9d6dd3a12641 | 170 | time = getTime(); |
cittecla | 55:bdab541f434d | 171 | 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); |
aeschsim | 40:b5e533e1e033 | 172 | state = 47; |
aeschsim | 40:b5e533e1e033 | 173 | break; |
aeschsim | 40:b5e533e1e033 | 174 | |
aeschsim | 40:b5e533e1e033 | 175 | /* Console State Switch */ |
aeschsim | 40:b5e533e1e033 | 176 | case 47: |
cittecla | 55:bdab541f434d | 177 | printf("\n\rState Switch: Enter next State: \n\r"); |
itslinear | 81:a869abf56e85 | 178 | 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\r60\twrite_medProtocol\n\r61\twrite_medInventory\n\r62\twrite_medError\n\r63\terase_errorPotocol\n\r64\terase_medPotocol\n\r65\tread_medProtocol\n\r66\tread_medInventory\n\r67\tread_medError\n\r"); |
aeschsim | 40:b5e533e1e033 | 179 | pc.scanf("%d", &state); |
cittecla | 55:bdab541f434d | 180 | printf("Switch to State %d\n\r",state); |
aeschsim | 40:b5e533e1e033 | 181 | fflush(stdin); |
aeschsim | 34:9d6dd3a12641 | 182 | break; |
aeschsim | 40:b5e533e1e033 | 183 | |
aeschsim | 40:b5e533e1e033 | 184 | /* Servo-Board Test Tool */ |
aeschsim | 34:9d6dd3a12641 | 185 | case 48: |
cittecla | 55:bdab541f434d | 186 | printf("\n\r\n\rServo-Board Test Tool\n\rEnter Channel Number and then Duty Cycle\n\r"); |
cittecla | 55:bdab541f434d | 187 | printf("for exit, enter Channel > 15\n\r"); |
aeschsim | 40:b5e533e1e033 | 188 | channel = 0; |
aeschsim | 40:b5e533e1e033 | 189 | while (channel < 16) { |
cittecla | 55:bdab541f434d | 190 | printf("Channel Number: "); |
aeschsim | 40:b5e533e1e033 | 191 | pc.scanf("%d", &channel); |
cittecla | 55:bdab541f434d | 192 | printf("\r\nchannel: %d\n\rDuty Cycle 0..4095: ",channel); |
aeschsim | 40:b5e533e1e033 | 193 | pc.scanf("%d", &dutyCycle); |
cittecla | 55:bdab541f434d | 194 | printf("\n\r%d\n\r",dutyCycle); |
aeschsim | 46:cdc24a24e4e3 | 195 | setPWM((char)channel, (int)dutyCycle); |
aeschsim | 40:b5e533e1e033 | 196 | fflush(stdin); |
aeschsim | 40:b5e533e1e033 | 197 | } |
cittecla | 55:bdab541f434d | 198 | printf("leave Servo-Board Test Tool\n\r"); |
aeschsim | 40:b5e533e1e033 | 199 | state = 47; |
aeschsim | 40:b5e533e1e033 | 200 | break; |
aeschsim | 40:b5e533e1e033 | 201 | |
aeschsim | 40:b5e533e1e033 | 202 | case 49: |
cittecla | 42:ba59ed6a2a06 | 203 | enableOutput(); |
cittecla | 55:bdab541f434d | 204 | printf("Servo output enabled\r\n\n"); |
aeschsim | 40:b5e533e1e033 | 205 | state = 47; |
aeschsim | 34:9d6dd3a12641 | 206 | break; |
cittecla | 2:72886e996098 | 207 | |
aeschsim | 34:9d6dd3a12641 | 208 | case 50: |
cittecla | 42:ba59ed6a2a06 | 209 | disableOutput(); |
cittecla | 55:bdab541f434d | 210 | printf("Servo output disabled\r\n\n"); |
aeschsim | 40:b5e533e1e033 | 211 | state = 47; |
aeschsim | 40:b5e533e1e033 | 212 | break; |
cittecla | 53:1c61cadbcb35 | 213 | |
cittecla | 42:ba59ed6a2a06 | 214 | case 51: |
cittecla | 52:701d0c2f47d7 | 215 | testSd(); |
cittecla | 55:bdab541f434d | 216 | printf("\rSD Card test finished\r\n\n"); |
cittecla | 55:bdab541f434d | 217 | state = 47; |
cittecla | 55:bdab541f434d | 218 | break; |
cittecla | 58:cda5298c9b7f | 219 | |
cittecla | 58:cda5298c9b7f | 220 | |
cittecla | 55:bdab541f434d | 221 | case 52: |
itslinear | 73:7fd3701def5b | 222 | prescription[1] = readMedication(1); |
itslinear | 73:7fd3701def5b | 223 | if(prescription[1].valid) { |
cittecla | 56:218601547d13 | 224 | printf("\rread successful\r\n\n"); |
cittecla | 55:bdab541f434d | 225 | } else { |
cittecla | 55:bdab541f434d | 226 | printf("\rread failed\r\n\n"); |
cittecla | 55:bdab541f434d | 227 | } |
cittecla | 42:ba59ed6a2a06 | 228 | state = 47; |
cittecla | 53:1c61cadbcb35 | 229 | break; |
cittecla | 55:bdab541f434d | 230 | |
cittecla | 55:bdab541f434d | 231 | case 53: |
itslinear | 73:7fd3701def5b | 232 | if(prescription[1].valid == false) { |
cittecla | 57:79fed71031da | 233 | printf("\r\nNo valid data in struct, try to run case 52\r\n\n"); |
cittecla | 55:bdab541f434d | 234 | } else { |
cittecla | 55:bdab541f434d | 235 | printf("\r\nMedication display test tool:\r\n"); |
cittecla | 55:bdab541f434d | 236 | printf("Enter Day (0..6) and Moment (0..4)\r\nTo exit enter Day > 6:\r\n"); |
cittecla | 55:bdab541f434d | 237 | day = 0; |
cittecla | 55:bdab541f434d | 238 | while (day < 7) { |
cittecla | 55:bdab541f434d | 239 | printf("\r\nDay Number: "); |
cittecla | 55:bdab541f434d | 240 | pc.scanf("%d", &day); |
cittecla | 55:bdab541f434d | 241 | if(day < 7) { |
cittecla | 55:bdab541f434d | 242 | printf("\r\nDay: %d\n\rMoment 0..3: ",day); |
cittecla | 55:bdab541f434d | 243 | pc.scanf("%d", &moment); |
cittecla | 55:bdab541f434d | 244 | printf("\r\nMedication for weekday %d Moment %d is ",day,moment); |
cittecla | 55:bdab541f434d | 245 | for(int i=0; i<6; i++) { |
itslinear | 73:7fd3701def5b | 246 | printf("%d", prescription[1].medication.day[day].moment[moment].medContainer.container[i]); |
cittecla | 55:bdab541f434d | 247 | } |
itslinear | 73:7fd3701def5b | 248 | 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); |
cittecla | 55:bdab541f434d | 249 | } |
cittecla | 55:bdab541f434d | 250 | printf("\r\n"); |
cittecla | 55:bdab541f434d | 251 | fflush(stdin); |
cittecla | 55:bdab541f434d | 252 | } |
cittecla | 55:bdab541f434d | 253 | printf("exit Tool\n\r"); |
cittecla | 55:bdab541f434d | 254 | } |
cittecla | 56:218601547d13 | 255 | state = 47; |
cittecla | 56:218601547d13 | 256 | break; |
cittecla | 58:cda5298c9b7f | 257 | case 54: |
itslinear | 73:7fd3701def5b | 258 | writeMedication(0,prescription[1]); |
cittecla | 58:cda5298c9b7f | 259 | state = 47; |
cittecla | 58:cda5298c9b7f | 260 | break; |
aeschsim | 59:1867088695f3 | 261 | case 55: |
aeschsim | 59:1867088695f3 | 262 | /* Demo Tool */ |
PESGruppe1 | 61:086bcd5ca968 | 263 | enableOutput(); |
PESGruppe1 | 61:086bcd5ca968 | 264 | printf("Servo output enabled\r\n\n"); |
PESGruppe1 | 61:086bcd5ca968 | 265 | //summer.period_us(500); |
PESGruppe1 | 61:086bcd5ca968 | 266 | //summer.write(0.5f); |
PESGruppe1 | 61:086bcd5ca968 | 267 | //wait(3); |
PESGruppe1 | 61:086bcd5ca968 | 268 | //summer.write(0.0f); |
PESGruppe1 | 61:086bcd5ca968 | 269 | |
PESGruppe1 | 61:086bcd5ca968 | 270 | //userButton1.fall(&summ); |
aeschsim | 60:7554e4272b3b | 271 | |
PESGruppe1 | 61:086bcd5ca968 | 272 | color = 0xFFFFFF; |
PESGruppe1 | 61:086bcd5ca968 | 273 | colorTime = 0; |
aeschsim | 60:7554e4272b3b | 274 | |
PESGruppe1 | 61:086bcd5ca968 | 275 | setLED(0,color); |
PESGruppe1 | 61:086bcd5ca968 | 276 | wait(5); |
PESGruppe1 | 61:086bcd5ca968 | 277 | printf("start loop\n\r"); |
aeschsim | 59:1867088695f3 | 278 | while(colorTime < DEMOTIME) { |
PESGruppe1 | 61:086bcd5ca968 | 279 | printf("fade1\n\r"); |
aeschsim | 60:7554e4272b3b | 280 | for(r = 0; r <= 255; r++) { |
aeschsim | 59:1867088695f3 | 281 | color &= 0x00FFFF; |
PESGruppe1 | 61:086bcd5ca968 | 282 | color |= (r<<16); |
PESGruppe1 | 61:086bcd5ca968 | 283 | printf("color = %d\n\r",color); |
PESGruppe1 | 61:086bcd5ca968 | 284 | setLED(0,color); |
aeschsim | 59:1867088695f3 | 285 | wait_ms(FADESPEED); |
aeschsim | 59:1867088695f3 | 286 | } |
PESGruppe1 | 61:086bcd5ca968 | 287 | printf("fade2"); |
aeschsim | 60:7554e4272b3b | 288 | for(b = 255; b >= 0; b--) { |
aeschsim | 59:1867088695f3 | 289 | color &= 0xFFFF00; |
PESGruppe1 | 61:086bcd5ca968 | 290 | color |= b; |
PESGruppe1 | 61:086bcd5ca968 | 291 | setLED(0,color); |
aeschsim | 59:1867088695f3 | 292 | wait_ms(FADESPEED); |
aeschsim | 59:1867088695f3 | 293 | } |
PESGruppe1 | 61:086bcd5ca968 | 294 | printf("fade3"); |
aeschsim | 60:7554e4272b3b | 295 | for(g = 0; g <= 255; g++) { |
aeschsim | 59:1867088695f3 | 296 | color &= 0xFF00FF; |
PESGruppe1 | 61:086bcd5ca968 | 297 | color |= (g<<8); |
PESGruppe1 | 61:086bcd5ca968 | 298 | setLED(0,color); |
aeschsim | 59:1867088695f3 | 299 | wait_ms(FADESPEED); |
aeschsim | 59:1867088695f3 | 300 | } |
aeschsim | 59:1867088695f3 | 301 | for(r = 255; r > 0; r--) { |
aeschsim | 59:1867088695f3 | 302 | color &= 0x00FFFF; |
PESGruppe1 | 61:086bcd5ca968 | 303 | color |= (r<<16); |
PESGruppe1 | 61:086bcd5ca968 | 304 | setLED(0,color); |
aeschsim | 59:1867088695f3 | 305 | wait_ms(FADESPEED); |
aeschsim | 59:1867088695f3 | 306 | } |
aeschsim | 59:1867088695f3 | 307 | for(b = 0; b <= 255; b++) { |
aeschsim | 59:1867088695f3 | 308 | color &= 0xFFFF00; |
PESGruppe1 | 61:086bcd5ca968 | 309 | color |= b; |
PESGruppe1 | 61:086bcd5ca968 | 310 | setLED(0,color); |
aeschsim | 59:1867088695f3 | 311 | wait_ms(FADESPEED); |
aeschsim | 59:1867088695f3 | 312 | } |
aeschsim | 59:1867088695f3 | 313 | for (g = 255; g > 0; g--) { |
aeschsim | 59:1867088695f3 | 314 | color &= 0xFF00FF; |
PESGruppe1 | 61:086bcd5ca968 | 315 | color |= (g<<8); |
PESGruppe1 | 61:086bcd5ca968 | 316 | setLED(0,color); |
aeschsim | 59:1867088695f3 | 317 | wait_ms(FADESPEED); |
aeschsim | 59:1867088695f3 | 318 | } |
aeschsim | 59:1867088695f3 | 319 | colorTime++; |
aeschsim | 59:1867088695f3 | 320 | } |
PESGruppe1 | 61:086bcd5ca968 | 321 | printf("exit demo"); |
aeschsim | 59:1867088695f3 | 322 | |
aeschsim | 59:1867088695f3 | 323 | break; |
itslinear | 72:172b40dd16ee | 324 | |
itslinear | 73:7fd3701def5b | 325 | case 60: |
itslinear | 73:7fd3701def5b | 326 | printf("write_medProtocol\n\r"); |
itslinear | 72:172b40dd16ee | 327 | write_medProtocol(medicationTime, outputTime, medication, success, user); |
itslinear | 73:7fd3701def5b | 328 | printf("done\n\r"); |
itslinear | 73:7fd3701def5b | 329 | state = 47; |
itslinear | 73:7fd3701def5b | 330 | |
itslinear | 72:172b40dd16ee | 331 | break; |
itslinear | 72:172b40dd16ee | 332 | |
itslinear | 73:7fd3701def5b | 333 | case 61: |
itslinear | 81:a869abf56e85 | 334 | medInventory.currentTime = getTime(); |
itslinear | 73:7fd3701def5b | 335 | printf("write_medInventory\n\r"); |
itslinear | 80:6e3eb8246ced | 336 | //write_medInventory(medInventory,currentTime,med1,med2,med3,med4,med5,med6); |
itslinear | 80:6e3eb8246ced | 337 | write_medInventory(medInventory); |
itslinear | 73:7fd3701def5b | 338 | state = 47; |
itslinear | 72:172b40dd16ee | 339 | |
itslinear | 73:7fd3701def5b | 340 | break; |
itslinear | 72:172b40dd16ee | 341 | |
itslinear | 73:7fd3701def5b | 342 | case 62: |
itslinear | 73:7fd3701def5b | 343 | printf("write_medError\n\r"); |
itslinear | 81:a869abf56e85 | 344 | write_medError(fail, medicationTime); |
itslinear | 73:7fd3701def5b | 345 | state = 47; |
itslinear | 72:172b40dd16ee | 346 | |
itslinear | 73:7fd3701def5b | 347 | break; |
itslinear | 80:6e3eb8246ced | 348 | |
itslinear | 77:c2e22d1e5d44 | 349 | case 63: |
itslinear | 77:c2e22d1e5d44 | 350 | printf("erase_errorPotocol\n\r"); |
itslinear | 77:c2e22d1e5d44 | 351 | erase_medError(); |
itslinear | 77:c2e22d1e5d44 | 352 | state = 47; |
itslinear | 80:6e3eb8246ced | 353 | |
itslinear | 77:c2e22d1e5d44 | 354 | break; |
itslinear | 72:172b40dd16ee | 355 | |
itslinear | 77:c2e22d1e5d44 | 356 | case 64: |
itslinear | 77:c2e22d1e5d44 | 357 | printf("erase_medPotocol\n\r"); |
itslinear | 77:c2e22d1e5d44 | 358 | erase_medProtocol(); |
itslinear | 77:c2e22d1e5d44 | 359 | state = 47; |
itslinear | 80:6e3eb8246ced | 360 | |
itslinear | 80:6e3eb8246ced | 361 | break; |
itslinear | 80:6e3eb8246ced | 362 | |
itslinear | 80:6e3eb8246ced | 363 | case 65: |
itslinear | 80:6e3eb8246ced | 364 | printf("read_medPotocol\n\r"); |
itslinear | 80:6e3eb8246ced | 365 | send = read_medProtocol(user); |
itslinear | 80:6e3eb8246ced | 366 | printf("%s", send); |
itslinear | 80:6e3eb8246ced | 367 | state = 47; |
itslinear | 80:6e3eb8246ced | 368 | |
itslinear | 77:c2e22d1e5d44 | 369 | break; |
itslinear | 80:6e3eb8246ced | 370 | |
itslinear | 80:6e3eb8246ced | 371 | case 66: |
itslinear | 80:6e3eb8246ced | 372 | printf("read_medInventory\n\r"); |
itslinear | 80:6e3eb8246ced | 373 | medInventory = read_medInventory(); |
itslinear | 80:6e3eb8246ced | 374 | printf("done\r\n"); |
itslinear | 81:a869abf56e85 | 375 | printf("%s\r\n%d\r\n%s\r\n%d\r\n%s\r\n%d\r\n%s\r\n%d\r\n%s\r\n%d\r\n%s\r\n%d\r\n", medInventory.pill[0], medInventory.medContainer.container[0], medInventory.pill[1], medInventory.medContainer.container[1], medInventory.pill[2], medInventory.medContainer.container[2], medInventory.pill[3], medInventory.medContainer.container[3], medInventory.pill[4], medInventory.medContainer.container[4], medInventory.pill[5], medInventory.medContainer.container[5]); |
itslinear | 80:6e3eb8246ced | 376 | state = 47; |
itslinear | 81:a869abf56e85 | 377 | |
itslinear | 81:a869abf56e85 | 378 | break; |
itslinear | 81:a869abf56e85 | 379 | |
itslinear | 81:a869abf56e85 | 380 | case 67: |
itslinear | 81:a869abf56e85 | 381 | printf("read_medError\n\r"); |
itslinear | 81:a869abf56e85 | 382 | send = read_medError(); |
itslinear | 81:a869abf56e85 | 383 | printf("%s", send); |
itslinear | 81:a869abf56e85 | 384 | state = 47; |
itslinear | 81:a869abf56e85 | 385 | |
itslinear | 80:6e3eb8246ced | 386 | break; |
itslinear | 80:6e3eb8246ced | 387 | |
aeschsim | 40:b5e533e1e033 | 388 | default: |
aeschsim | 40:b5e533e1e033 | 389 | state = 47; /* Go to State Switch */ |
aeschsim | 34:9d6dd3a12641 | 390 | break; |
aeschsim | 34:9d6dd3a12641 | 391 | } |
cittecla | 2:72886e996098 | 392 | } |
cittecla | 55:bdab541f434d | 393 | printf("exit while 1 loop"); |
cittecla | 2:72886e996098 | 394 | } |