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