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