![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
current code
Dependencies: mbed Motor TextLCD Keypad Frdmlz25 DHT11
main.cpp@1:c7d87cc6718a, 2018-11-02 (annotated)
- Committer:
- alex123456
- Date:
- Fri Nov 02 00:13:56 2018 +0000
- Revision:
- 1:c7d87cc6718a
- Parent:
- 0:dc0a6c236ec1
- Child:
- 2:8ed2269ab264
- Child:
- 5:83908d1e6213
The new version including 2,3 type.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
alex123456 | 0:dc0a6c236ec1 | 1 | #include "mbed.h" |
alex123456 | 0:dc0a6c236ec1 | 2 | #include "Dht11.h" |
alex123456 | 0:dc0a6c236ec1 | 3 | #include "TSL2561.h" |
alex123456 | 0:dc0a6c236ec1 | 4 | #include "Keypad.h" |
alex123456 | 0:dc0a6c236ec1 | 5 | #include "TextLCD.h" |
alex123456 | 0:dc0a6c236ec1 | 6 | |
alex123456 | 0:dc0a6c236ec1 | 7 | //Setup a new plant1 data |
alex123456 | 0:dc0a6c236ec1 | 8 | float p1_tMin=35.0, p1_tMax=45.0; |
alex123456 | 0:dc0a6c236ec1 | 9 | float p1_lMin=300.0, p1_lMax=50000.0; |
alex123456 | 0:dc0a6c236ec1 | 10 | float p1_hMin=60.0, p1_hMax=70.0; |
alex123456 | 0:dc0a6c236ec1 | 11 | //Setup a new plant2 data |
alex123456 | 0:dc0a6c236ec1 | 12 | float p2_tMin=10.0, p2_tMax=25.0; |
alex123456 | 0:dc0a6c236ec1 | 13 | float p2_lMin=200.0, p2_lMax=50000.0; |
alex123456 | 0:dc0a6c236ec1 | 14 | float p2_hMin=10.0, p2_hMax=40.0; |
alex123456 | 0:dc0a6c236ec1 | 15 | //Setup a new plant3 data |
alex123456 | 0:dc0a6c236ec1 | 16 | float p3_tMin=15.0, p3_tMax=25.0; |
alex123456 | 0:dc0a6c236ec1 | 17 | float p3_lMin=100.0, p3_lMax=50000.0; |
alex123456 | 0:dc0a6c236ec1 | 18 | float p3_hMin=30.0, p3_hMax=70.0; |
alex123456 | 0:dc0a6c236ec1 | 19 | |
alex123456 | 0:dc0a6c236ec1 | 20 | Serial PC(PTE0, PTE1); |
alex123456 | 0:dc0a6c236ec1 | 21 | #define PC_PRINTX(z,x) if(z==1) PC.printf(x); |
alex123456 | 0:dc0a6c236ec1 | 22 | #define PC_PRINTLNX(z,x) if(z==1) {PC.printf(x); PC.printf("\r\n");} |
alex123456 | 0:dc0a6c236ec1 | 23 | #define PC_PRINTXY(z,x, y) if(z==1) PC.printf(x, y); |
alex123456 | 0:dc0a6c236ec1 | 24 | #define PC_PRINTLNXY(z,x, y) if(z==1) {PC.printf(x, y); PC.printf("\r\n");} |
alex123456 | 0:dc0a6c236ec1 | 25 | |
alex123456 | 0:dc0a6c236ec1 | 26 | |
alex123456 | 0:dc0a6c236ec1 | 27 | //Setup a new plant data |
alex123456 | 0:dc0a6c236ec1 | 28 | |
alex123456 | 0:dc0a6c236ec1 | 29 | Dht11 sensor(PTB0); |
alex123456 | 0:dc0a6c236ec1 | 30 | TSL2561 tsl2561(TSL2561_ADDR_FLOAT);// Use the tsl2561 sensor |
alex123456 | 0:dc0a6c236ec1 | 31 | |
alex123456 | 0:dc0a6c236ec1 | 32 | |
alex123456 | 0:dc0a6c236ec1 | 33 | //Setup output |
alex123456 | 0:dc0a6c236ec1 | 34 | DigitalOut output1(PTD3); //Setup output |
alex123456 | 0:dc0a6c236ec1 | 35 | DigitalOut output2(PTD2); //Setup output |
alex123456 | 0:dc0a6c236ec1 | 36 | DigitalOut output3(PTE5); //Setup output |
alex123456 | 0:dc0a6c236ec1 | 37 | DigitalOut output4(PTD5); //Setup output |
alex123456 | 0:dc0a6c236ec1 | 38 | Keypad KeyInput(PTC4,PTC3,PTC0,PTC7,PTC11,PTC10,PTC6,PTC5); |
alex123456 | 0:dc0a6c236ec1 | 39 | TextLCD lcd(PTB8,PTB9,PTB10,PTB11,PTE2,PTE3,TextLCD::LCD16x2); |
alex123456 | 0:dc0a6c236ec1 | 40 | //float output1=0,output2=0,output3=0,output4=0;// lighting// ventilation// watering// heating |
alex123456 | 0:dc0a6c236ec1 | 41 | |
alex123456 | 0:dc0a6c236ec1 | 42 | |
alex123456 | 0:dc0a6c236ec1 | 43 | |
alex123456 | 0:dc0a6c236ec1 | 44 | |
alex123456 | 0:dc0a6c236ec1 | 45 | int main() { |
alex123456 | 0:dc0a6c236ec1 | 46 | int val_hud; |
alex123456 | 1:c7d87cc6718a | 47 | char keym,tempkey; |
alex123456 | 0:dc0a6c236ec1 | 48 | uint16_t val_lig; |
alex123456 | 0:dc0a6c236ec1 | 49 | float val_tmp,t; |
alex123456 | 0:dc0a6c236ec1 | 50 | // int output1,output2,output3,output4; |
alex123456 | 0:dc0a6c236ec1 | 51 | |
alex123456 | 0:dc0a6c236ec1 | 52 | |
alex123456 | 0:dc0a6c236ec1 | 53 | lcd.printf("-----START------"); |
alex123456 | 0:dc0a6c236ec1 | 54 | wait(2); |
alex123456 | 0:dc0a6c236ec1 | 55 | lcd.printf("WELCOME TO 6711"); |
alex123456 | 0:dc0a6c236ec1 | 56 | wait(3); |
alex123456 | 0:dc0a6c236ec1 | 57 | |
alex123456 | 0:dc0a6c236ec1 | 58 | |
alex123456 | 0:dc0a6c236ec1 | 59 | |
alex123456 | 0:dc0a6c236ec1 | 60 | while (1) { |
alex123456 | 0:dc0a6c236ec1 | 61 | lcd.printf("Please input the No. of plant"); |
alex123456 | 0:dc0a6c236ec1 | 62 | wait(0.2); |
alex123456 | 0:dc0a6c236ec1 | 63 | keym=KeyInput.ReadKey(); |
alex123456 | 1:c7d87cc6718a | 64 | tempkey=keym; |
alex123456 | 0:dc0a6c236ec1 | 65 | lcd.cls(); |
alex123456 | 0:dc0a6c236ec1 | 66 | if (keym!='\0') { |
alex123456 | 0:dc0a6c236ec1 | 67 | lcd.printf("The type of plant is %c",keym); |
alex123456 | 0:dc0a6c236ec1 | 68 | wait(3); |
alex123456 | 0:dc0a6c236ec1 | 69 | lcd.cls();; |
alex123456 | 0:dc0a6c236ec1 | 70 | |
alex123456 | 0:dc0a6c236ec1 | 71 | //while(keym!='0') { |
alex123456 | 0:dc0a6c236ec1 | 72 | while(1) { |
alex123456 | 1:c7d87cc6718a | 73 | keym=KeyInput.ReadKey(); // input a key see if it is the key to trun out |
alex123456 | 1:c7d87cc6718a | 74 | if (keym=='\0'){ |
alex123456 | 1:c7d87cc6718a | 75 | keym=tempkey; |
alex123456 | 1:c7d87cc6718a | 76 | } |
alex123456 | 1:c7d87cc6718a | 77 | else if (keym!='\0') { |
alex123456 | 1:c7d87cc6718a | 78 | lcd.printf("If you want reset, plesee input zer0 !"); |
alex123456 | 1:c7d87cc6718a | 79 | keym=KeyInput.ReadKey(); |
alex123456 | 1:c7d87cc6718a | 80 | if (keym=='0'){ |
alex123456 | 1:c7d87cc6718a | 81 | break; |
alex123456 | 1:c7d87cc6718a | 82 | } |
alex123456 | 0:dc0a6c236ec1 | 83 | |
alex123456 | 1:c7d87cc6718a | 84 | } |
alex123456 | 0:dc0a6c236ec1 | 85 | |
alex123456 | 0:dc0a6c236ec1 | 86 | // get temperature and humidity data from sensor |
alex123456 | 0:dc0a6c236ec1 | 87 | sensor.read(); |
alex123456 | 0:dc0a6c236ec1 | 88 | t=sensor.getFahrenheit(); |
alex123456 | 0:dc0a6c236ec1 | 89 | val_tmp=(t-32)/1.8; |
alex123456 | 0:dc0a6c236ec1 | 90 | val_hud=sensor.getHumidity(); |
alex123456 | 0:dc0a6c236ec1 | 91 | lcd.printf("T: %2.1fC\n", val_tmp); |
alex123456 | 0:dc0a6c236ec1 | 92 | lcd.printf("H: %d%%\n",val_hud); |
alex123456 | 0:dc0a6c236ec1 | 93 | wait(3); |
alex123456 | 0:dc0a6c236ec1 | 94 | lcd.cls(); |
alex123456 | 0:dc0a6c236ec1 | 95 | |
alex123456 | 0:dc0a6c236ec1 | 96 | // get light data |
alex123456 | 0:dc0a6c236ec1 | 97 | val_lig = tsl2561.getLuminosity(TSL2561_VISIBLE); |
alex123456 | 0:dc0a6c236ec1 | 98 | lcd.printf("Illu is:%d Lux\n",val_lig); |
alex123456 | 0:dc0a6c236ec1 | 99 | wait(2); |
alex123456 | 0:dc0a6c236ec1 | 100 | lcd.cls(); |
alex123456 | 1:c7d87cc6718a | 101 | |
alex123456 | 0:dc0a6c236ec1 | 102 | // compare data |
alex123456 | 0:dc0a6c236ec1 | 103 | lcd.printf("key is:%c \n",keym); |
alex123456 | 0:dc0a6c236ec1 | 104 | wait(2); |
alex123456 | 0:dc0a6c236ec1 | 105 | if (keym=='1') { |
alex123456 | 0:dc0a6c236ec1 | 106 | if (val_tmp>=p1_tMin && val_tmp<=p1_tMax) { |
alex123456 | 0:dc0a6c236ec1 | 107 | if (val_hud>=p1_hMin && val_hud<=p1_hMax) { |
alex123456 | 0:dc0a6c236ec1 | 108 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 0:dc0a6c236ec1 | 109 | output1=0; |
alex123456 | 0:dc0a6c236ec1 | 110 | output2=0; |
alex123456 | 0:dc0a6c236ec1 | 111 | output3=0; |
alex123456 | 0:dc0a6c236ec1 | 112 | output4=0; |
alex123456 | 0:dc0a6c236ec1 | 113 | } |
alex123456 | 0:dc0a6c236ec1 | 114 | else if (val_lig<p1_lMin){ |
alex123456 | 0:dc0a6c236ec1 | 115 | output1=1; |
alex123456 | 0:dc0a6c236ec1 | 116 | output2=0; |
alex123456 | 0:dc0a6c236ec1 | 117 | output3=0; |
alex123456 | 0:dc0a6c236ec1 | 118 | output4=0; |
alex123456 | 0:dc0a6c236ec1 | 119 | } |
alex123456 | 0:dc0a6c236ec1 | 120 | } |
alex123456 | 0:dc0a6c236ec1 | 121 | |
alex123456 | 0:dc0a6c236ec1 | 122 | |
alex123456 | 0:dc0a6c236ec1 | 123 | else if (val_hud<=p1_hMin ) { |
alex123456 | 0:dc0a6c236ec1 | 124 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 0:dc0a6c236ec1 | 125 | output1=0; |
alex123456 | 0:dc0a6c236ec1 | 126 | output2=0; |
alex123456 | 0:dc0a6c236ec1 | 127 | output3=1; |
alex123456 | 0:dc0a6c236ec1 | 128 | output4=0; |
alex123456 | 0:dc0a6c236ec1 | 129 | } |
alex123456 | 0:dc0a6c236ec1 | 130 | else if (val_lig<p1_lMin){ |
alex123456 | 0:dc0a6c236ec1 | 131 | output1=1; |
alex123456 | 0:dc0a6c236ec1 | 132 | output2=0; |
alex123456 | 0:dc0a6c236ec1 | 133 | output3=1; |
alex123456 | 0:dc0a6c236ec1 | 134 | output4=0; |
alex123456 | 0:dc0a6c236ec1 | 135 | } |
alex123456 | 0:dc0a6c236ec1 | 136 | } |
alex123456 | 0:dc0a6c236ec1 | 137 | else { |
alex123456 | 0:dc0a6c236ec1 | 138 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 0:dc0a6c236ec1 | 139 | output1=0; |
alex123456 | 0:dc0a6c236ec1 | 140 | output2=1; |
alex123456 | 0:dc0a6c236ec1 | 141 | output3=0; |
alex123456 | 0:dc0a6c236ec1 | 142 | output4=0; |
alex123456 | 0:dc0a6c236ec1 | 143 | } |
alex123456 | 0:dc0a6c236ec1 | 144 | else if (val_lig<=p1_lMin){ |
alex123456 | 0:dc0a6c236ec1 | 145 | output1=1; |
alex123456 | 0:dc0a6c236ec1 | 146 | output2=1; |
alex123456 | 0:dc0a6c236ec1 | 147 | output3=0; |
alex123456 | 0:dc0a6c236ec1 | 148 | output4=0; |
alex123456 | 0:dc0a6c236ec1 | 149 | } |
alex123456 | 0:dc0a6c236ec1 | 150 | } |
alex123456 | 0:dc0a6c236ec1 | 151 | |
alex123456 | 0:dc0a6c236ec1 | 152 | |
alex123456 | 0:dc0a6c236ec1 | 153 | } |
alex123456 | 0:dc0a6c236ec1 | 154 | else if (val_tmp<=p1_tMin){ |
alex123456 | 0:dc0a6c236ec1 | 155 | if (val_hud>=p1_hMin && val_hud<=p1_hMax){ |
alex123456 | 0:dc0a6c236ec1 | 156 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 0:dc0a6c236ec1 | 157 | output1=0; |
alex123456 | 0:dc0a6c236ec1 | 158 | output2=0; |
alex123456 | 0:dc0a6c236ec1 | 159 | output3=0; |
alex123456 | 0:dc0a6c236ec1 | 160 | output4=1; |
alex123456 | 0:dc0a6c236ec1 | 161 | } |
alex123456 | 0:dc0a6c236ec1 | 162 | else if (val_lig<=p1_lMin){ |
alex123456 | 0:dc0a6c236ec1 | 163 | output1=1; |
alex123456 | 0:dc0a6c236ec1 | 164 | output2=0; |
alex123456 | 0:dc0a6c236ec1 | 165 | output3=0; |
alex123456 | 0:dc0a6c236ec1 | 166 | output4=1; |
alex123456 | 0:dc0a6c236ec1 | 167 | } |
alex123456 | 0:dc0a6c236ec1 | 168 | } |
alex123456 | 0:dc0a6c236ec1 | 169 | |
alex123456 | 0:dc0a6c236ec1 | 170 | else if (val_hud<=p1_hMin ) { |
alex123456 | 0:dc0a6c236ec1 | 171 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 0:dc0a6c236ec1 | 172 | output1=0; |
alex123456 | 0:dc0a6c236ec1 | 173 | output2=0; |
alex123456 | 0:dc0a6c236ec1 | 174 | output3=1; |
alex123456 | 0:dc0a6c236ec1 | 175 | output4=1; |
alex123456 | 0:dc0a6c236ec1 | 176 | } |
alex123456 | 0:dc0a6c236ec1 | 177 | else if (val_lig<=p1_lMin){ |
alex123456 | 0:dc0a6c236ec1 | 178 | output1=1; |
alex123456 | 0:dc0a6c236ec1 | 179 | output2=0; |
alex123456 | 0:dc0a6c236ec1 | 180 | output3=1; |
alex123456 | 0:dc0a6c236ec1 | 181 | output4=1; |
alex123456 | 0:dc0a6c236ec1 | 182 | } |
alex123456 | 0:dc0a6c236ec1 | 183 | } |
alex123456 | 0:dc0a6c236ec1 | 184 | else { |
alex123456 | 0:dc0a6c236ec1 | 185 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 0:dc0a6c236ec1 | 186 | output1=0; |
alex123456 | 0:dc0a6c236ec1 | 187 | output2=1; |
alex123456 | 0:dc0a6c236ec1 | 188 | output3=0; |
alex123456 | 0:dc0a6c236ec1 | 189 | output4=1; |
alex123456 | 0:dc0a6c236ec1 | 190 | } |
alex123456 | 0:dc0a6c236ec1 | 191 | else if (val_lig<=p1_lMin){ |
alex123456 | 0:dc0a6c236ec1 | 192 | output1=1; |
alex123456 | 0:dc0a6c236ec1 | 193 | output2=1; |
alex123456 | 0:dc0a6c236ec1 | 194 | output3=0; |
alex123456 | 0:dc0a6c236ec1 | 195 | output4=1; |
alex123456 | 0:dc0a6c236ec1 | 196 | } |
alex123456 | 0:dc0a6c236ec1 | 197 | } |
alex123456 | 0:dc0a6c236ec1 | 198 | } |
alex123456 | 0:dc0a6c236ec1 | 199 | |
alex123456 | 0:dc0a6c236ec1 | 200 | |
alex123456 | 0:dc0a6c236ec1 | 201 | |
alex123456 | 0:dc0a6c236ec1 | 202 | else{ |
alex123456 | 0:dc0a6c236ec1 | 203 | if (val_hud>=p1_hMin && val_hud<=p1_hMax){ |
alex123456 | 0:dc0a6c236ec1 | 204 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 0:dc0a6c236ec1 | 205 | output1=0; |
alex123456 | 0:dc0a6c236ec1 | 206 | output2=1; |
alex123456 | 0:dc0a6c236ec1 | 207 | output3=1; |
alex123456 | 0:dc0a6c236ec1 | 208 | output4=0; |
alex123456 | 0:dc0a6c236ec1 | 209 | } |
alex123456 | 0:dc0a6c236ec1 | 210 | else if (val_lig<=p1_lMin){ |
alex123456 | 0:dc0a6c236ec1 | 211 | output1=1; |
alex123456 | 0:dc0a6c236ec1 | 212 | output2=1; |
alex123456 | 0:dc0a6c236ec1 | 213 | output3=1; |
alex123456 | 0:dc0a6c236ec1 | 214 | output4=0; |
alex123456 | 0:dc0a6c236ec1 | 215 | } |
alex123456 | 0:dc0a6c236ec1 | 216 | } |
alex123456 | 0:dc0a6c236ec1 | 217 | |
alex123456 | 0:dc0a6c236ec1 | 218 | else if (val_hud<=p1_hMin ) { |
alex123456 | 0:dc0a6c236ec1 | 219 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 0:dc0a6c236ec1 | 220 | output1=0; |
alex123456 | 0:dc0a6c236ec1 | 221 | output2=1; |
alex123456 | 0:dc0a6c236ec1 | 222 | output3=1; |
alex123456 | 0:dc0a6c236ec1 | 223 | output4=0; |
alex123456 | 0:dc0a6c236ec1 | 224 | } |
alex123456 | 0:dc0a6c236ec1 | 225 | else if (val_lig<=p1_lMin){ |
alex123456 | 0:dc0a6c236ec1 | 226 | output1=1; |
alex123456 | 0:dc0a6c236ec1 | 227 | output2=1; |
alex123456 | 0:dc0a6c236ec1 | 228 | output3=1; |
alex123456 | 0:dc0a6c236ec1 | 229 | output4=0; |
alex123456 | 0:dc0a6c236ec1 | 230 | } |
alex123456 | 0:dc0a6c236ec1 | 231 | } |
alex123456 | 0:dc0a6c236ec1 | 232 | else{ |
alex123456 | 0:dc0a6c236ec1 | 233 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 0:dc0a6c236ec1 | 234 | output1=0; |
alex123456 | 0:dc0a6c236ec1 | 235 | output2=1; |
alex123456 | 0:dc0a6c236ec1 | 236 | output3=0; |
alex123456 | 0:dc0a6c236ec1 | 237 | output4=0; |
alex123456 | 0:dc0a6c236ec1 | 238 | } |
alex123456 | 0:dc0a6c236ec1 | 239 | else if (val_lig<=p1_lMin){ |
alex123456 | 0:dc0a6c236ec1 | 240 | output1=1; |
alex123456 | 0:dc0a6c236ec1 | 241 | output2=1; |
alex123456 | 0:dc0a6c236ec1 | 242 | output3=0; |
alex123456 | 0:dc0a6c236ec1 | 243 | output4=0; |
alex123456 | 0:dc0a6c236ec1 | 244 | } |
alex123456 | 0:dc0a6c236ec1 | 245 | } |
alex123456 | 0:dc0a6c236ec1 | 246 | } |
alex123456 | 0:dc0a6c236ec1 | 247 | |
alex123456 | 1:c7d87cc6718a | 248 | } |
alex123456 | 1:c7d87cc6718a | 249 | //-------------------------- sceond type----------------------------------------- |
alex123456 | 1:c7d87cc6718a | 250 | else if (keym=='2') { |
alex123456 | 1:c7d87cc6718a | 251 | if (val_tmp>=p2_tMin && val_tmp<=p2_tMax) { |
alex123456 | 1:c7d87cc6718a | 252 | if (val_hud>=p2_hMin && val_hud<=p2_hMax) { |
alex123456 | 1:c7d87cc6718a | 253 | if (val_lig>=p2_lMin && val_lig<=p2_lMax) { |
alex123456 | 1:c7d87cc6718a | 254 | output1=0; |
alex123456 | 1:c7d87cc6718a | 255 | output2=0; |
alex123456 | 1:c7d87cc6718a | 256 | output3=0; |
alex123456 | 1:c7d87cc6718a | 257 | output4=0; |
alex123456 | 1:c7d87cc6718a | 258 | } |
alex123456 | 1:c7d87cc6718a | 259 | else if (val_lig<p2_lMin){ |
alex123456 | 1:c7d87cc6718a | 260 | output1=1; |
alex123456 | 1:c7d87cc6718a | 261 | output2=0; |
alex123456 | 1:c7d87cc6718a | 262 | output3=0; |
alex123456 | 1:c7d87cc6718a | 263 | output4=0; |
alex123456 | 1:c7d87cc6718a | 264 | } |
alex123456 | 1:c7d87cc6718a | 265 | } |
alex123456 | 1:c7d87cc6718a | 266 | |
alex123456 | 1:c7d87cc6718a | 267 | |
alex123456 | 1:c7d87cc6718a | 268 | else if (val_hud<=p2_hMin ) { |
alex123456 | 1:c7d87cc6718a | 269 | if (val_lig>=p2_lMin && val_lig<=p2_lMax) { |
alex123456 | 1:c7d87cc6718a | 270 | output1=0; |
alex123456 | 1:c7d87cc6718a | 271 | output2=0; |
alex123456 | 1:c7d87cc6718a | 272 | output3=1; |
alex123456 | 1:c7d87cc6718a | 273 | output4=0; |
alex123456 | 1:c7d87cc6718a | 274 | } |
alex123456 | 1:c7d87cc6718a | 275 | else if (val_lig<p2_lMin){ |
alex123456 | 1:c7d87cc6718a | 276 | output1=1; |
alex123456 | 1:c7d87cc6718a | 277 | output2=0; |
alex123456 | 1:c7d87cc6718a | 278 | output3=1; |
alex123456 | 1:c7d87cc6718a | 279 | output4=0; |
alex123456 | 1:c7d87cc6718a | 280 | } |
alex123456 | 1:c7d87cc6718a | 281 | } |
alex123456 | 1:c7d87cc6718a | 282 | else { |
alex123456 | 1:c7d87cc6718a | 283 | if (val_lig>=p2_lMin && val_lig<=p2_lMax) { |
alex123456 | 1:c7d87cc6718a | 284 | output1=0; |
alex123456 | 1:c7d87cc6718a | 285 | output2=1; |
alex123456 | 1:c7d87cc6718a | 286 | output3=0; |
alex123456 | 1:c7d87cc6718a | 287 | output4=0; |
alex123456 | 1:c7d87cc6718a | 288 | } |
alex123456 | 1:c7d87cc6718a | 289 | else if (val_lig<=p1_lMin){ |
alex123456 | 1:c7d87cc6718a | 290 | output1=1; |
alex123456 | 1:c7d87cc6718a | 291 | output2=1; |
alex123456 | 1:c7d87cc6718a | 292 | output3=0; |
alex123456 | 1:c7d87cc6718a | 293 | output4=0; |
alex123456 | 1:c7d87cc6718a | 294 | } |
alex123456 | 1:c7d87cc6718a | 295 | } |
alex123456 | 1:c7d87cc6718a | 296 | |
alex123456 | 1:c7d87cc6718a | 297 | |
alex123456 | 1:c7d87cc6718a | 298 | } |
alex123456 | 1:c7d87cc6718a | 299 | else if (val_tmp<=p1_tMin){ |
alex123456 | 1:c7d87cc6718a | 300 | if (val_hud>=p2_hMin && val_hud<=p2_hMax){ |
alex123456 | 1:c7d87cc6718a | 301 | if (val_lig>=p2_lMin && val_lig<=p2_lMax) { |
alex123456 | 1:c7d87cc6718a | 302 | output1=0; |
alex123456 | 1:c7d87cc6718a | 303 | output2=0; |
alex123456 | 1:c7d87cc6718a | 304 | output3=0; |
alex123456 | 1:c7d87cc6718a | 305 | output4=1; |
alex123456 | 1:c7d87cc6718a | 306 | } |
alex123456 | 1:c7d87cc6718a | 307 | else if (val_lig<=p2_lMin){ |
alex123456 | 1:c7d87cc6718a | 308 | output1=1; |
alex123456 | 1:c7d87cc6718a | 309 | output2=0; |
alex123456 | 1:c7d87cc6718a | 310 | output3=0; |
alex123456 | 1:c7d87cc6718a | 311 | output4=1; |
alex123456 | 1:c7d87cc6718a | 312 | } |
alex123456 | 1:c7d87cc6718a | 313 | } |
alex123456 | 1:c7d87cc6718a | 314 | |
alex123456 | 1:c7d87cc6718a | 315 | else if (val_hud<=p2_hMin ) { |
alex123456 | 1:c7d87cc6718a | 316 | if (val_lig>=p2_lMin && val_lig<=p2_lMax) { |
alex123456 | 1:c7d87cc6718a | 317 | output1=0; |
alex123456 | 1:c7d87cc6718a | 318 | output2=0; |
alex123456 | 1:c7d87cc6718a | 319 | output3=1; |
alex123456 | 1:c7d87cc6718a | 320 | output4=1; |
alex123456 | 1:c7d87cc6718a | 321 | } |
alex123456 | 1:c7d87cc6718a | 322 | else if (val_lig<=p1_lMin){ |
alex123456 | 1:c7d87cc6718a | 323 | output1=1; |
alex123456 | 1:c7d87cc6718a | 324 | output2=0; |
alex123456 | 1:c7d87cc6718a | 325 | output3=1; |
alex123456 | 1:c7d87cc6718a | 326 | output4=1; |
alex123456 | 1:c7d87cc6718a | 327 | } |
alex123456 | 1:c7d87cc6718a | 328 | } |
alex123456 | 1:c7d87cc6718a | 329 | else { |
alex123456 | 1:c7d87cc6718a | 330 | if (val_lig>=p2_lMin && val_lig<=p2_lMax) { |
alex123456 | 1:c7d87cc6718a | 331 | output1=0; |
alex123456 | 1:c7d87cc6718a | 332 | output2=1; |
alex123456 | 1:c7d87cc6718a | 333 | output3=0; |
alex123456 | 1:c7d87cc6718a | 334 | output4=1; |
alex123456 | 1:c7d87cc6718a | 335 | } |
alex123456 | 1:c7d87cc6718a | 336 | else if (val_lig<=p2_lMin){ |
alex123456 | 1:c7d87cc6718a | 337 | output1=1; |
alex123456 | 1:c7d87cc6718a | 338 | output2=1; |
alex123456 | 1:c7d87cc6718a | 339 | output3=0; |
alex123456 | 1:c7d87cc6718a | 340 | output4=1; |
alex123456 | 1:c7d87cc6718a | 341 | } |
alex123456 | 1:c7d87cc6718a | 342 | } |
alex123456 | 1:c7d87cc6718a | 343 | } |
alex123456 | 1:c7d87cc6718a | 344 | |
alex123456 | 1:c7d87cc6718a | 345 | |
alex123456 | 1:c7d87cc6718a | 346 | |
alex123456 | 1:c7d87cc6718a | 347 | else{ |
alex123456 | 1:c7d87cc6718a | 348 | if (val_hud>=p2_hMin && val_hud<=p2_hMax){ |
alex123456 | 1:c7d87cc6718a | 349 | if (val_lig>=p2_lMin && val_lig<=p2_lMax) { |
alex123456 | 1:c7d87cc6718a | 350 | output1=0; |
alex123456 | 1:c7d87cc6718a | 351 | output2=1; |
alex123456 | 1:c7d87cc6718a | 352 | output3=1; |
alex123456 | 1:c7d87cc6718a | 353 | output4=0; |
alex123456 | 1:c7d87cc6718a | 354 | } |
alex123456 | 1:c7d87cc6718a | 355 | else if (val_lig<=p2_lMin){ |
alex123456 | 1:c7d87cc6718a | 356 | output1=1; |
alex123456 | 1:c7d87cc6718a | 357 | output2=1; |
alex123456 | 1:c7d87cc6718a | 358 | output3=1; |
alex123456 | 1:c7d87cc6718a | 359 | output4=0; |
alex123456 | 1:c7d87cc6718a | 360 | } |
alex123456 | 1:c7d87cc6718a | 361 | } |
alex123456 | 1:c7d87cc6718a | 362 | |
alex123456 | 1:c7d87cc6718a | 363 | else if (val_hud<=p2_hMin ) { |
alex123456 | 1:c7d87cc6718a | 364 | if (val_lig>=p2_lMin && val_lig<=p2_lMax) { |
alex123456 | 1:c7d87cc6718a | 365 | output1=0; |
alex123456 | 1:c7d87cc6718a | 366 | output2=1; |
alex123456 | 1:c7d87cc6718a | 367 | output3=1; |
alex123456 | 1:c7d87cc6718a | 368 | output4=0; |
alex123456 | 1:c7d87cc6718a | 369 | } |
alex123456 | 1:c7d87cc6718a | 370 | else if (val_lig<=p2_lMin){ |
alex123456 | 1:c7d87cc6718a | 371 | output1=1; |
alex123456 | 1:c7d87cc6718a | 372 | output2=1; |
alex123456 | 1:c7d87cc6718a | 373 | output3=1; |
alex123456 | 1:c7d87cc6718a | 374 | output4=0; |
alex123456 | 1:c7d87cc6718a | 375 | } |
alex123456 | 1:c7d87cc6718a | 376 | } |
alex123456 | 1:c7d87cc6718a | 377 | else{ |
alex123456 | 1:c7d87cc6718a | 378 | if (val_lig>=p2_lMin && val_lig<=p2_lMax) { |
alex123456 | 1:c7d87cc6718a | 379 | output1=0; |
alex123456 | 1:c7d87cc6718a | 380 | output2=1; |
alex123456 | 1:c7d87cc6718a | 381 | output3=0; |
alex123456 | 1:c7d87cc6718a | 382 | output4=0; |
alex123456 | 1:c7d87cc6718a | 383 | } |
alex123456 | 1:c7d87cc6718a | 384 | else if (val_lig<=p2_lMin){ |
alex123456 | 1:c7d87cc6718a | 385 | output1=1; |
alex123456 | 1:c7d87cc6718a | 386 | output2=1; |
alex123456 | 1:c7d87cc6718a | 387 | output3=0; |
alex123456 | 1:c7d87cc6718a | 388 | output4=0; |
alex123456 | 1:c7d87cc6718a | 389 | } |
alex123456 | 1:c7d87cc6718a | 390 | } |
alex123456 | 1:c7d87cc6718a | 391 | } |
alex123456 | 1:c7d87cc6718a | 392 | } |
alex123456 | 1:c7d87cc6718a | 393 | //-------------------------- Third type----------------------------------------- |
alex123456 | 1:c7d87cc6718a | 394 | else{ |
alex123456 | 1:c7d87cc6718a | 395 | if (val_tmp>=p1_tMin && val_tmp<=p1_tMax) { |
alex123456 | 1:c7d87cc6718a | 396 | if (val_hud>=p1_hMin && val_hud<=p1_hMax) { |
alex123456 | 1:c7d87cc6718a | 397 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 1:c7d87cc6718a | 398 | output1=0; |
alex123456 | 1:c7d87cc6718a | 399 | output2=0; |
alex123456 | 1:c7d87cc6718a | 400 | output3=0; |
alex123456 | 1:c7d87cc6718a | 401 | output4=0; |
alex123456 | 1:c7d87cc6718a | 402 | } |
alex123456 | 1:c7d87cc6718a | 403 | else if (val_lig<p1_lMin){ |
alex123456 | 1:c7d87cc6718a | 404 | output1=1; |
alex123456 | 1:c7d87cc6718a | 405 | output2=0; |
alex123456 | 1:c7d87cc6718a | 406 | output3=0; |
alex123456 | 1:c7d87cc6718a | 407 | output4=0; |
alex123456 | 1:c7d87cc6718a | 408 | } |
alex123456 | 1:c7d87cc6718a | 409 | } |
alex123456 | 1:c7d87cc6718a | 410 | |
alex123456 | 1:c7d87cc6718a | 411 | |
alex123456 | 1:c7d87cc6718a | 412 | else if (val_hud<=p1_hMin ) { |
alex123456 | 1:c7d87cc6718a | 413 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 1:c7d87cc6718a | 414 | output1=0; |
alex123456 | 1:c7d87cc6718a | 415 | output2=0; |
alex123456 | 1:c7d87cc6718a | 416 | output3=1; |
alex123456 | 1:c7d87cc6718a | 417 | output4=0; |
alex123456 | 1:c7d87cc6718a | 418 | } |
alex123456 | 1:c7d87cc6718a | 419 | else if (val_lig<p1_lMin){ |
alex123456 | 1:c7d87cc6718a | 420 | output1=1; |
alex123456 | 1:c7d87cc6718a | 421 | output2=0; |
alex123456 | 1:c7d87cc6718a | 422 | output3=1; |
alex123456 | 1:c7d87cc6718a | 423 | output4=0; |
alex123456 | 1:c7d87cc6718a | 424 | } |
alex123456 | 1:c7d87cc6718a | 425 | } |
alex123456 | 1:c7d87cc6718a | 426 | else { |
alex123456 | 1:c7d87cc6718a | 427 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 1:c7d87cc6718a | 428 | output1=0; |
alex123456 | 1:c7d87cc6718a | 429 | output2=1; |
alex123456 | 1:c7d87cc6718a | 430 | output3=0; |
alex123456 | 1:c7d87cc6718a | 431 | output4=0; |
alex123456 | 1:c7d87cc6718a | 432 | } |
alex123456 | 1:c7d87cc6718a | 433 | else if (val_lig<=p1_lMin){ |
alex123456 | 1:c7d87cc6718a | 434 | output1=1; |
alex123456 | 1:c7d87cc6718a | 435 | output2=1; |
alex123456 | 1:c7d87cc6718a | 436 | output3=0; |
alex123456 | 1:c7d87cc6718a | 437 | output4=0; |
alex123456 | 1:c7d87cc6718a | 438 | } |
alex123456 | 1:c7d87cc6718a | 439 | } |
alex123456 | 1:c7d87cc6718a | 440 | |
alex123456 | 1:c7d87cc6718a | 441 | |
alex123456 | 1:c7d87cc6718a | 442 | } |
alex123456 | 1:c7d87cc6718a | 443 | else if (val_tmp<=p1_tMin){ |
alex123456 | 1:c7d87cc6718a | 444 | if (val_hud>=p1_hMin && val_hud<=p1_hMax){ |
alex123456 | 1:c7d87cc6718a | 445 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 1:c7d87cc6718a | 446 | output1=0; |
alex123456 | 1:c7d87cc6718a | 447 | output2=0; |
alex123456 | 1:c7d87cc6718a | 448 | output3=0; |
alex123456 | 1:c7d87cc6718a | 449 | output4=1; |
alex123456 | 1:c7d87cc6718a | 450 | } |
alex123456 | 1:c7d87cc6718a | 451 | else if (val_lig<=p1_lMin){ |
alex123456 | 1:c7d87cc6718a | 452 | output1=1; |
alex123456 | 1:c7d87cc6718a | 453 | output2=0; |
alex123456 | 1:c7d87cc6718a | 454 | output3=0; |
alex123456 | 1:c7d87cc6718a | 455 | output4=1; |
alex123456 | 1:c7d87cc6718a | 456 | } |
alex123456 | 1:c7d87cc6718a | 457 | } |
alex123456 | 1:c7d87cc6718a | 458 | |
alex123456 | 1:c7d87cc6718a | 459 | else if (val_hud<=p1_hMin ) { |
alex123456 | 1:c7d87cc6718a | 460 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 1:c7d87cc6718a | 461 | output1=0; |
alex123456 | 1:c7d87cc6718a | 462 | output2=0; |
alex123456 | 1:c7d87cc6718a | 463 | output3=1; |
alex123456 | 1:c7d87cc6718a | 464 | output4=1; |
alex123456 | 1:c7d87cc6718a | 465 | } |
alex123456 | 1:c7d87cc6718a | 466 | else if (val_lig<=p1_lMin){ |
alex123456 | 1:c7d87cc6718a | 467 | output1=1; |
alex123456 | 1:c7d87cc6718a | 468 | output2=0; |
alex123456 | 1:c7d87cc6718a | 469 | output3=1; |
alex123456 | 1:c7d87cc6718a | 470 | output4=1; |
alex123456 | 1:c7d87cc6718a | 471 | } |
alex123456 | 1:c7d87cc6718a | 472 | } |
alex123456 | 1:c7d87cc6718a | 473 | else { |
alex123456 | 1:c7d87cc6718a | 474 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 1:c7d87cc6718a | 475 | output1=0; |
alex123456 | 1:c7d87cc6718a | 476 | output2=1; |
alex123456 | 1:c7d87cc6718a | 477 | output3=0; |
alex123456 | 1:c7d87cc6718a | 478 | output4=1; |
alex123456 | 1:c7d87cc6718a | 479 | } |
alex123456 | 1:c7d87cc6718a | 480 | else if (val_lig<=p1_lMin){ |
alex123456 | 1:c7d87cc6718a | 481 | output1=1; |
alex123456 | 1:c7d87cc6718a | 482 | output2=1; |
alex123456 | 1:c7d87cc6718a | 483 | output3=0; |
alex123456 | 1:c7d87cc6718a | 484 | output4=1; |
alex123456 | 1:c7d87cc6718a | 485 | } |
alex123456 | 1:c7d87cc6718a | 486 | } |
alex123456 | 1:c7d87cc6718a | 487 | } |
alex123456 | 1:c7d87cc6718a | 488 | |
alex123456 | 1:c7d87cc6718a | 489 | |
alex123456 | 1:c7d87cc6718a | 490 | |
alex123456 | 1:c7d87cc6718a | 491 | else{ |
alex123456 | 1:c7d87cc6718a | 492 | if (val_hud>=p1_hMin && val_hud<=p1_hMax){ |
alex123456 | 1:c7d87cc6718a | 493 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 1:c7d87cc6718a | 494 | output1=0; |
alex123456 | 1:c7d87cc6718a | 495 | output2=1; |
alex123456 | 1:c7d87cc6718a | 496 | output3=1; |
alex123456 | 1:c7d87cc6718a | 497 | output4=0; |
alex123456 | 1:c7d87cc6718a | 498 | } |
alex123456 | 1:c7d87cc6718a | 499 | else if (val_lig<=p1_lMin){ |
alex123456 | 1:c7d87cc6718a | 500 | output1=1; |
alex123456 | 1:c7d87cc6718a | 501 | output2=1; |
alex123456 | 1:c7d87cc6718a | 502 | output3=1; |
alex123456 | 1:c7d87cc6718a | 503 | output4=0; |
alex123456 | 1:c7d87cc6718a | 504 | } |
alex123456 | 1:c7d87cc6718a | 505 | } |
alex123456 | 1:c7d87cc6718a | 506 | |
alex123456 | 1:c7d87cc6718a | 507 | else if (val_hud<=p1_hMin ) { |
alex123456 | 1:c7d87cc6718a | 508 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 1:c7d87cc6718a | 509 | output1=0; |
alex123456 | 1:c7d87cc6718a | 510 | output2=1; |
alex123456 | 1:c7d87cc6718a | 511 | output3=1; |
alex123456 | 1:c7d87cc6718a | 512 | output4=0; |
alex123456 | 1:c7d87cc6718a | 513 | } |
alex123456 | 1:c7d87cc6718a | 514 | else if (val_lig<=p1_lMin){ |
alex123456 | 1:c7d87cc6718a | 515 | output1=1; |
alex123456 | 1:c7d87cc6718a | 516 | output2=1; |
alex123456 | 1:c7d87cc6718a | 517 | output3=1; |
alex123456 | 1:c7d87cc6718a | 518 | output4=0; |
alex123456 | 1:c7d87cc6718a | 519 | } |
alex123456 | 1:c7d87cc6718a | 520 | } |
alex123456 | 1:c7d87cc6718a | 521 | else{ |
alex123456 | 1:c7d87cc6718a | 522 | if (val_lig>=p1_lMin && val_lig<=p1_lMax) { |
alex123456 | 1:c7d87cc6718a | 523 | output1=0; |
alex123456 | 1:c7d87cc6718a | 524 | output2=1; |
alex123456 | 1:c7d87cc6718a | 525 | output3=0; |
alex123456 | 1:c7d87cc6718a | 526 | output4=0; |
alex123456 | 1:c7d87cc6718a | 527 | } |
alex123456 | 1:c7d87cc6718a | 528 | else if (val_lig<=p1_lMin){ |
alex123456 | 1:c7d87cc6718a | 529 | output1=1; |
alex123456 | 1:c7d87cc6718a | 530 | output2=1; |
alex123456 | 1:c7d87cc6718a | 531 | output3=0; |
alex123456 | 1:c7d87cc6718a | 532 | output4=0; |
alex123456 | 1:c7d87cc6718a | 533 | } |
alex123456 | 1:c7d87cc6718a | 534 | } |
alex123456 | 1:c7d87cc6718a | 535 | } |
alex123456 | 1:c7d87cc6718a | 536 | } |
alex123456 | 0:dc0a6c236ec1 | 537 | |
alex123456 | 1:c7d87cc6718a | 538 | |
alex123456 | 0:dc0a6c236ec1 | 539 | } |
alex123456 | 0:dc0a6c236ec1 | 540 | } |
alex123456 | 0:dc0a6c236ec1 | 541 | } |
alex123456 | 0:dc0a6c236ec1 | 542 | } |