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