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