float impossible dans RPC donc weight1 et 2 en float > f0 et f1 en int pour sa: f0 = (int) weight1;....
Dependencies: mbed HTTPServer EthernetNetIf HX711 TextLCD RPCInterface
HTTPServerExample.cpp@5:3754211a1b5b, 2022-06-11 (annotated)
- Committer:
- tostestas19
- Date:
- Sat Jun 11 21:11:21 2022 +0000
- Revision:
- 5:3754211a1b5b
- Parent:
- 4:5b29715e0aaa
- Child:
- 6:2aba0ce3dedd
projet 2022
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 0:0b1369ae8b74 | 1 | #include "mbed.h" |
donatien | 0:0b1369ae8b74 | 2 | #include "EthernetNetIf.h" |
donatien | 0:0b1369ae8b74 | 3 | #include "HTTPServer.h" |
LouisReynier | 3:c2b64cce42d8 | 4 | #include "SerialRPCInterface.h" |
tostestas19 | 5:3754211a1b5b | 5 | #include "HX711.h" |
tostestas19 | 5:3754211a1b5b | 6 | #include "TextLCD.h" |
tostestas19 | 5:3754211a1b5b | 7 | |
tostestas19 | 5:3754211a1b5b | 8 | #define BLINKING_RATE 0.5 |
tostestas19 | 5:3754211a1b5b | 9 | #define temps_on 0.5 |
LouisReynier | 3:c2b64cce42d8 | 10 | |
LouisReynier | 3:c2b64cce42d8 | 11 | // LR 2/2/17 |
LouisReynier | 3:c2b64cce42d8 | 12 | // sur ce fichier j'ai rajouté une variable RPC count que je peux lire à distance |
LouisReynier | 3:c2b64cce42d8 | 13 | // adresse/rpc/count/read/ |
donatien | 0:0b1369ae8b74 | 14 | |
tostestas19 | 5:3754211a1b5b | 15 | // LCD and Joystick Setting |
tostestas19 | 5:3754211a1b5b | 16 | TextLCD lcd(p8, p10, p11, p5, p6, p7); // rs, e, d4-d7 |
tostestas19 | 5:3754211a1b5b | 17 | //rs e d4 d5 d6 d7 |
tostestas19 | 5:3754211a1b5b | 18 | |
tostestas19 | 5:3754211a1b5b | 19 | DigitalOut led1(LED1); |
tostestas19 | 5:3754211a1b5b | 20 | DigitalOut led2(LED2); |
tostestas19 | 5:3754211a1b5b | 21 | DigitalOut led3(LED3); |
tostestas19 | 5:3754211a1b5b | 22 | DigitalOut led4(LED4); |
tostestas19 | 5:3754211a1b5b | 23 | |
tostestas19 | 5:3754211a1b5b | 24 | DigitalOut RW(p9); |
tostestas19 | 4:5b29715e0aaa | 25 | //AnalogIn Pot1(p19, "pot1"); |
tostestas19 | 4:5b29715e0aaa | 26 | //AnalogIn Pot2(p20, "pot2"); |
LouisReynier | 3:c2b64cce42d8 | 27 | |
tostestas19 | 5:3754211a1b5b | 28 | //LED BICOLORE |
tostestas19 | 5:3754211a1b5b | 29 | //DigitalOut ledB1(p29); // SI 1 LED ROUGE |
tostestas19 | 5:3754211a1b5b | 30 | //DigitalOut ledB2(p30); // SI 1 LED VERT |
tostestas19 | 5:3754211a1b5b | 31 | DigitalOut myledR(p30); // LED Rouge |
tostestas19 | 5:3754211a1b5b | 32 | DigitalOut myledV(p29); // LED Vert |
tostestas19 | 5:3754211a1b5b | 33 | |
tostestas19 | 5:3754211a1b5b | 34 | // BOUTON |
tostestas19 | 5:3754211a1b5b | 35 | DigitalIn Up(p12); |
tostestas19 | 5:3754211a1b5b | 36 | DigitalIn Down(p13); |
tostestas19 | 5:3754211a1b5b | 37 | DigitalIn Left(p14); |
tostestas19 | 5:3754211a1b5b | 38 | DigitalIn Right(p15); |
tostestas19 | 5:3754211a1b5b | 39 | DigitalIn Center(p16); |
tostestas19 | 5:3754211a1b5b | 40 | |
tostestas19 | 5:3754211a1b5b | 41 | //HX711 |
tostestas19 | 5:3754211a1b5b | 42 | HX711 scale1(p22, p21); //22 , 21 |
tostestas19 | 5:3754211a1b5b | 43 | HX711 scale2(p24, p23); //24 , 23 |
tostestas19 | 5:3754211a1b5b | 44 | |
tostestas19 | 5:3754211a1b5b | 45 | |
LouisReynier | 3:c2b64cce42d8 | 46 | int count = 0 ; |
tostestas19 | 4:5b29715e0aaa | 47 | //int F1 = 0 ; |
tostestas19 | 4:5b29715e0aaa | 48 | //int F2 = 0 ; |
tostestas19 | 4:5b29715e0aaa | 49 | |
tostestas19 | 4:5b29715e0aaa | 50 | |
tostestas19 | 5:3754211a1b5b | 51 | //int pot1 ; a renplacer |
tostestas19 | 5:3754211a1b5b | 52 | //int pot2; a remplacer |
tostestas19 | 5:3754211a1b5b | 53 | int MOI = 0; // en kg*cm2 |
tostestas19 | 5:3754211a1b5b | 54 | int f0 = 256 ; //256 ; // en g |
tostestas19 | 5:3754211a1b5b | 55 | int f1 = 657 ; //657 ; // en g |
tostestas19 | 5:3754211a1b5b | 56 | int m = 0 ; // en g |
tostestas19 | 5:3754211a1b5b | 57 | int l1 = 45 ; // en cm |
tostestas19 | 5:3754211a1b5b | 58 | int lg = 0 ; // en cm |
tostestas19 | 5:3754211a1b5b | 59 | int menu = 0; |
tostestas19 | 5:3754211a1b5b | 60 | int tempo_saisie = 130 ; |
tostestas19 | 5:3754211a1b5b | 61 | |
tostestas19 | 5:3754211a1b5b | 62 | |
tostestas19 | 5:3754211a1b5b | 63 | float calibration_factor1 = 2325; //2325 // -7050 worked for my 440lb max scale setup |
tostestas19 | 5:3754211a1b5b | 64 | float calibration_factor2 = 2178; //2178 |
tostestas19 | 5:3754211a1b5b | 65 | int averageSamples = 5; //NOMBRE DE MESURE |
tostestas19 | 5:3754211a1b5b | 66 | float weight1 = 0; // F1 |
tostestas19 | 5:3754211a1b5b | 67 | float weight2 = 0; // F0 |
tostestas19 | 5:3754211a1b5b | 68 | |
tostestas19 | 5:3754211a1b5b | 69 | RPCVariable<int> rpc_f0(&f0, "f0"); |
tostestas19 | 5:3754211a1b5b | 70 | RPCVariable<int> rpc_f1(&f1, "f1"); |
tostestas19 | 4:5b29715e0aaa | 71 | |
tostestas19 | 4:5b29715e0aaa | 72 | |
LouisReynier | 3:c2b64cce42d8 | 73 | RPCVariable<int> rpc_count(&count, "count"); |
donatien | 0:0b1369ae8b74 | 74 | LocalFileSystem fs("webfs"); |
donatien | 0:0b1369ae8b74 | 75 | |
donatien | 0:0b1369ae8b74 | 76 | EthernetNetIf eth; |
donatien | 0:0b1369ae8b74 | 77 | HTTPServer svr; |
donatien | 0:0b1369ae8b74 | 78 | |
tostestas19 | 5:3754211a1b5b | 79 | |
tostestas19 | 5:3754211a1b5b | 80 | |
tostestas19 | 5:3754211a1b5b | 81 | |
donatien | 0:0b1369ae8b74 | 82 | int main() { |
tostestas19 | 4:5b29715e0aaa | 83 | |
tostestas19 | 5:3754211a1b5b | 84 | menu = 0 ; |
tostestas19 | 5:3754211a1b5b | 85 | RW = 0 ; |
tostestas19 | 5:3754211a1b5b | 86 | |
tostestas19 | 5:3754211a1b5b | 87 | |
tostestas19 | 5:3754211a1b5b | 88 | |
tostestas19 | 5:3754211a1b5b | 89 | |
tostestas19 | 5:3754211a1b5b | 90 | lcd.locate(0,0); |
tostestas19 | 5:3754211a1b5b | 91 | lcd.printf(" mesure MOI "); |
tostestas19 | 5:3754211a1b5b | 92 | lcd.locate(0,1); |
tostestas19 | 5:3754211a1b5b | 93 | lcd.printf(" club de golf "); |
tostestas19 | 5:3754211a1b5b | 94 | wait_ms(2000); |
tostestas19 | 5:3754211a1b5b | 95 | lcd.cls(); |
tostestas19 | 4:5b29715e0aaa | 96 | |
donatien | 0:0b1369ae8b74 | 97 | Base::add_rpc_class<DigitalOut>(); |
donatien | 0:0b1369ae8b74 | 98 | |
donatien | 1:114e347434c1 | 99 | printf("Setting up...\n"); |
LouisReynier | 3:c2b64cce42d8 | 100 | |
tostestas19 | 4:5b29715e0aaa | 101 | // modif LR config IP manuelle sinon dhcp |
tostestas19 | 4:5b29715e0aaa | 102 | /* |
tostestas19 | 4:5b29715e0aaa | 103 | EthernetNetIf eth( IpAddr(10,119,24,230), // IP |
tostestas19 | 4:5b29715e0aaa | 104 | IpAddr(255,255,252,0), // Subnet mask |
tostestas19 | 4:5b29715e0aaa | 105 | IpAddr(10,119,24,245), // Gateway |
tostestas19 | 4:5b29715e0aaa | 106 | IpAddr(10,119,24,245) ); // DNS |
LouisReynier | 3:c2b64cce42d8 | 107 | |
tostestas19 | 4:5b29715e0aaa | 108 | */ |
donatien | 0:0b1369ae8b74 | 109 | EthernetErr ethErr = eth.setup(); |
donatien | 0:0b1369ae8b74 | 110 | if(ethErr) |
donatien | 0:0b1369ae8b74 | 111 | { |
donatien | 0:0b1369ae8b74 | 112 | printf("Error %d in setup.\n", ethErr); |
donatien | 0:0b1369ae8b74 | 113 | return -1; |
donatien | 0:0b1369ae8b74 | 114 | } |
donatien | 0:0b1369ae8b74 | 115 | printf("Setup OK\n"); |
LouisReynier | 3:c2b64cce42d8 | 116 | // on définit où seront stockés les fichiers ! |
donatien | 0:0b1369ae8b74 | 117 | FSHandler::mount("/webfs", "/files"); //Mount /webfs path on /files web path |
donatien | 0:0b1369ae8b74 | 118 | FSHandler::mount("/webfs", "/"); //Mount /webfs path on web root path |
donatien | 0:0b1369ae8b74 | 119 | |
LouisReynier | 3:c2b64cce42d8 | 120 | svr.addHandler<SimpleHandler>("/hello"); // http://a.b.c.d/hello : hello world ! |
donatien | 0:0b1369ae8b74 | 121 | svr.addHandler<RPCHandler>("/rpc"); |
donatien | 0:0b1369ae8b74 | 122 | svr.addHandler<FSHandler>("/files"); |
donatien | 0:0b1369ae8b74 | 123 | svr.addHandler<FSHandler>("/"); //Default handler |
donatien | 0:0b1369ae8b74 | 124 | //Example : Access to mbed.htm : http://a.b.c.d/mbed.htm or http://a.b.c.d/files/mbed.htm |
donatien | 0:0b1369ae8b74 | 125 | |
donatien | 0:0b1369ae8b74 | 126 | svr.bind(80); |
donatien | 0:0b1369ae8b74 | 127 | |
donatien | 0:0b1369ae8b74 | 128 | printf("Listening...\n"); |
tostestas19 | 5:3754211a1b5b | 129 | scale1.setScale(0); |
tostestas19 | 5:3754211a1b5b | 130 | scale1.tare(); //Reset the scale to 0 |
tostestas19 | 5:3754211a1b5b | 131 | |
tostestas19 | 5:3754211a1b5b | 132 | scale2.setScale(0); |
tostestas19 | 5:3754211a1b5b | 133 | scale2.tare(); //Reset the scale to 0 |
tostestas19 | 5:3754211a1b5b | 134 | long zero_factor1 = scale1.averageValue(averageSamples); //Get a baseline reading / Obtenez une lecture de base CAPTEUR 1 |
tostestas19 | 5:3754211a1b5b | 135 | long zero_factor2 = scale2.averageValue(averageSamples); //Get a baseline reading / Obtenez une lecture de base CAPTEUR 2 |
tostestas19 | 5:3754211a1b5b | 136 | scale1.setScale(calibration_factor1); //Adjust to this calibration factor / Ajuster à ce facteur d'étalonnage |
tostestas19 | 5:3754211a1b5b | 137 | scale2.setScale(calibration_factor2); //Adjust to this calibration factor / Ajuster à ce facteur d'étalonnage |
donatien | 0:0b1369ae8b74 | 138 | |
tostestas19 | 5:3754211a1b5b | 139 | |
donatien | 0:0b1369ae8b74 | 140 | Timer tm; |
donatien | 0:0b1369ae8b74 | 141 | tm.start(); |
donatien | 0:0b1369ae8b74 | 142 | //Listen indefinitely |
tostestas19 | 5:3754211a1b5b | 143 | |
donatien | 0:0b1369ae8b74 | 144 | while(true) |
donatien | 0:0b1369ae8b74 | 145 | { |
tostestas19 | 4:5b29715e0aaa | 146 | //F1 = 1000*Pot1.read(); |
tostestas19 | 4:5b29715e0aaa | 147 | //F2 = 1000*Pot2.read(); |
tostestas19 | 4:5b29715e0aaa | 148 | |
tostestas19 | 5:3754211a1b5b | 149 | // pot2 = 926; |
tostestas19 | 5:3754211a1b5b | 150 | //pot1 = 351; |
tostestas19 | 5:3754211a1b5b | 151 | wait_ms(100); |
tostestas19 | 5:3754211a1b5b | 152 | weight1 = scale1.getGram(); |
tostestas19 | 5:3754211a1b5b | 153 | |
tostestas19 | 5:3754211a1b5b | 154 | weight2 = scale2.getGram(); |
tostestas19 | 5:3754211a1b5b | 155 | |
tostestas19 | 5:3754211a1b5b | 156 | // f0 = (int) weight1 ; |
tostestas19 | 5:3754211a1b5b | 157 | // f1 = (int) weight2 ; |
tostestas19 | 5:3754211a1b5b | 158 | |
tostestas19 | 5:3754211a1b5b | 159 | f0 = weight1 ; |
tostestas19 | 5:3754211a1b5b | 160 | f1 = weight2 ; |
tostestas19 | 5:3754211a1b5b | 161 | printf("wo = %f g : w1 = %f g \n", weight1 , weight2); |
tostestas19 | 5:3754211a1b5b | 162 | printf("fo = %d g : fi = %d g \n", f0 , f1); |
donatien | 0:0b1369ae8b74 | 163 | Net::poll(); |
tostestas19 | 4:5b29715e0aaa | 164 | |
tostestas19 | 4:5b29715e0aaa | 165 | |
donatien | 0:0b1369ae8b74 | 166 | if(tm.read()>.5) |
donatien | 0:0b1369ae8b74 | 167 | { |
donatien | 0:0b1369ae8b74 | 168 | led1=!led1; //Show that we are alive |
LouisReynier | 3:c2b64cce42d8 | 169 | count ++ ; |
donatien | 0:0b1369ae8b74 | 170 | tm.start(); |
donatien | 0:0b1369ae8b74 | 171 | } |
tostestas19 | 5:3754211a1b5b | 172 | |
tostestas19 | 5:3754211a1b5b | 173 | |
tostestas19 | 5:3754211a1b5b | 174 | /* |
tostestas19 | 5:3754211a1b5b | 175 | |
tostestas19 | 5:3754211a1b5b | 176 | m = f1 - f0 ; |
tostestas19 | 5:3754211a1b5b | 177 | lg = (l1*f1)/(f1-f0); |
tostestas19 | 5:3754211a1b5b | 178 | MOI = m*lg*lg/1000 ;*/ |
tostestas19 | 5:3754211a1b5b | 179 | |
tostestas19 | 5:3754211a1b5b | 180 | switch(menu) |
tostestas19 | 5:3754211a1b5b | 181 | { |
tostestas19 | 5:3754211a1b5b | 182 | |
tostestas19 | 5:3754211a1b5b | 183 | case(0): |
tostestas19 | 5:3754211a1b5b | 184 | |
tostestas19 | 5:3754211a1b5b | 185 | lcd.locate(1,0); |
tostestas19 | 5:3754211a1b5b | 186 | lcd.printf("*Mesures Forces"); |
tostestas19 | 5:3754211a1b5b | 187 | lcd.locate(1,1); |
tostestas19 | 5:3754211a1b5b | 188 | lcd.printf(" Calcul MOI "); |
tostestas19 | 5:3754211a1b5b | 189 | wait_ms(tempo_saisie); |
tostestas19 | 5:3754211a1b5b | 190 | |
tostestas19 | 5:3754211a1b5b | 191 | if (!Center ){ |
tostestas19 | 5:3754211a1b5b | 192 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 193 | menu = 3 ; |
tostestas19 | 5:3754211a1b5b | 194 | } |
tostestas19 | 5:3754211a1b5b | 195 | |
tostestas19 | 5:3754211a1b5b | 196 | if (!Down){ |
tostestas19 | 5:3754211a1b5b | 197 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 198 | menu = 1 ;} |
tostestas19 | 5:3754211a1b5b | 199 | |
tostestas19 | 5:3754211a1b5b | 200 | if (!Right ){ |
tostestas19 | 5:3754211a1b5b | 201 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 202 | menu = 7 ; |
tostestas19 | 5:3754211a1b5b | 203 | } |
tostestas19 | 5:3754211a1b5b | 204 | |
tostestas19 | 5:3754211a1b5b | 205 | myledV = 0; |
tostestas19 | 5:3754211a1b5b | 206 | myledR = 0; |
tostestas19 | 5:3754211a1b5b | 207 | |
tostestas19 | 5:3754211a1b5b | 208 | |
tostestas19 | 5:3754211a1b5b | 209 | break; //fin case 0 |
tostestas19 | 5:3754211a1b5b | 210 | |
tostestas19 | 5:3754211a1b5b | 211 | |
tostestas19 | 5:3754211a1b5b | 212 | case(1): |
tostestas19 | 5:3754211a1b5b | 213 | |
tostestas19 | 5:3754211a1b5b | 214 | |
tostestas19 | 5:3754211a1b5b | 215 | |
tostestas19 | 5:3754211a1b5b | 216 | lcd.locate(1,0); |
tostestas19 | 5:3754211a1b5b | 217 | lcd.printf(" Mesures Forces"); |
tostestas19 | 5:3754211a1b5b | 218 | lcd.locate(1,1); |
tostestas19 | 5:3754211a1b5b | 219 | lcd.printf("*Calcul MOI "); |
tostestas19 | 5:3754211a1b5b | 220 | wait_ms(tempo_saisie); |
tostestas19 | 5:3754211a1b5b | 221 | |
tostestas19 | 5:3754211a1b5b | 222 | if (!Center ){ |
tostestas19 | 5:3754211a1b5b | 223 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 224 | menu = 4 ; |
tostestas19 | 5:3754211a1b5b | 225 | } |
tostestas19 | 5:3754211a1b5b | 226 | |
tostestas19 | 5:3754211a1b5b | 227 | if (!Down){ |
tostestas19 | 5:3754211a1b5b | 228 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 229 | menu = 2 ;} |
tostestas19 | 5:3754211a1b5b | 230 | |
tostestas19 | 5:3754211a1b5b | 231 | if (!Up){ |
tostestas19 | 5:3754211a1b5b | 232 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 233 | menu = 0 ;} |
tostestas19 | 5:3754211a1b5b | 234 | |
tostestas19 | 5:3754211a1b5b | 235 | if (!Right ){ |
tostestas19 | 5:3754211a1b5b | 236 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 237 | menu = 7 ; |
tostestas19 | 5:3754211a1b5b | 238 | } |
tostestas19 | 5:3754211a1b5b | 239 | myledV = 0; |
tostestas19 | 5:3754211a1b5b | 240 | myledR = 0; |
tostestas19 | 5:3754211a1b5b | 241 | |
tostestas19 | 5:3754211a1b5b | 242 | |
tostestas19 | 5:3754211a1b5b | 243 | break; //fin case 1 |
tostestas19 | 5:3754211a1b5b | 244 | |
tostestas19 | 5:3754211a1b5b | 245 | |
tostestas19 | 5:3754211a1b5b | 246 | case (2): |
tostestas19 | 5:3754211a1b5b | 247 | |
tostestas19 | 5:3754211a1b5b | 248 | lcd.locate(1,0); |
tostestas19 | 5:3754211a1b5b | 249 | lcd.printf(" Calcul MOI "); |
tostestas19 | 5:3754211a1b5b | 250 | lcd.locate(1,1); |
tostestas19 | 5:3754211a1b5b | 251 | lcd.printf("*Masse/longueur"); |
tostestas19 | 5:3754211a1b5b | 252 | wait_ms(tempo_saisie); |
tostestas19 | 5:3754211a1b5b | 253 | |
tostestas19 | 5:3754211a1b5b | 254 | if (!Center ){ |
tostestas19 | 5:3754211a1b5b | 255 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 256 | menu = 5 ; |
tostestas19 | 5:3754211a1b5b | 257 | } |
tostestas19 | 5:3754211a1b5b | 258 | |
tostestas19 | 5:3754211a1b5b | 259 | if (!Up){ |
tostestas19 | 5:3754211a1b5b | 260 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 261 | menu = 1 ;} |
tostestas19 | 5:3754211a1b5b | 262 | |
tostestas19 | 5:3754211a1b5b | 263 | if (!Right ){ |
tostestas19 | 5:3754211a1b5b | 264 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 265 | menu = 7 ; |
tostestas19 | 5:3754211a1b5b | 266 | } |
tostestas19 | 5:3754211a1b5b | 267 | |
tostestas19 | 5:3754211a1b5b | 268 | |
tostestas19 | 5:3754211a1b5b | 269 | myledV = 0; |
tostestas19 | 5:3754211a1b5b | 270 | myledR = 0; |
tostestas19 | 5:3754211a1b5b | 271 | |
tostestas19 | 5:3754211a1b5b | 272 | break; //fin case 2 |
tostestas19 | 5:3754211a1b5b | 273 | |
tostestas19 | 5:3754211a1b5b | 274 | case (3): |
tostestas19 | 5:3754211a1b5b | 275 | |
tostestas19 | 5:3754211a1b5b | 276 | lcd.locate(1,0); |
tostestas19 | 5:3754211a1b5b | 277 | lcd.printf("F0 = %d g", f0); |
tostestas19 | 5:3754211a1b5b | 278 | lcd.locate(1,1); |
tostestas19 | 5:3754211a1b5b | 279 | lcd.printf("F1 = %d g", f1); |
tostestas19 | 5:3754211a1b5b | 280 | wait_ms(tempo_saisie); |
tostestas19 | 5:3754211a1b5b | 281 | |
tostestas19 | 5:3754211a1b5b | 282 | if (!Left ){ |
tostestas19 | 5:3754211a1b5b | 283 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 284 | menu = 0 ; |
tostestas19 | 5:3754211a1b5b | 285 | } |
tostestas19 | 5:3754211a1b5b | 286 | |
tostestas19 | 5:3754211a1b5b | 287 | myledV = 1; |
tostestas19 | 5:3754211a1b5b | 288 | wait(0.2); |
tostestas19 | 5:3754211a1b5b | 289 | myledV = 0; |
tostestas19 | 5:3754211a1b5b | 290 | wait(0.2); |
tostestas19 | 5:3754211a1b5b | 291 | myledR = 0; |
tostestas19 | 5:3754211a1b5b | 292 | |
tostestas19 | 5:3754211a1b5b | 293 | |
tostestas19 | 5:3754211a1b5b | 294 | break; //fin case 3 |
tostestas19 | 5:3754211a1b5b | 295 | |
tostestas19 | 5:3754211a1b5b | 296 | case (4): |
tostestas19 | 5:3754211a1b5b | 297 | |
tostestas19 | 5:3754211a1b5b | 298 | lcd.locate(0,0); |
tostestas19 | 5:3754211a1b5b | 299 | lcd.printf("MOI= %d kg*cm2", MOI); |
tostestas19 | 5:3754211a1b5b | 300 | wait_ms(tempo_saisie); |
tostestas19 | 5:3754211a1b5b | 301 | |
tostestas19 | 5:3754211a1b5b | 302 | if (!Left ){ |
tostestas19 | 5:3754211a1b5b | 303 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 304 | menu = 1 ; |
tostestas19 | 5:3754211a1b5b | 305 | } |
tostestas19 | 5:3754211a1b5b | 306 | |
tostestas19 | 5:3754211a1b5b | 307 | myledR = 1; |
tostestas19 | 5:3754211a1b5b | 308 | wait(0.2); |
tostestas19 | 5:3754211a1b5b | 309 | myledR = 0; |
tostestas19 | 5:3754211a1b5b | 310 | wait(0.2); |
tostestas19 | 5:3754211a1b5b | 311 | myledV = 0; |
tostestas19 | 5:3754211a1b5b | 312 | |
tostestas19 | 5:3754211a1b5b | 313 | |
tostestas19 | 5:3754211a1b5b | 314 | break; //fin case 4 |
tostestas19 | 5:3754211a1b5b | 315 | |
tostestas19 | 5:3754211a1b5b | 316 | case (5): |
tostestas19 | 5:3754211a1b5b | 317 | |
tostestas19 | 5:3754211a1b5b | 318 | lcd.locate(1,0); |
tostestas19 | 5:3754211a1b5b | 319 | lcd.printf(" Masse = %d g" , m); |
tostestas19 | 5:3754211a1b5b | 320 | wait_ms(tempo_saisie); |
tostestas19 | 5:3754211a1b5b | 321 | |
tostestas19 | 5:3754211a1b5b | 322 | if (!Left ){ |
tostestas19 | 5:3754211a1b5b | 323 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 324 | menu = 2 ; |
tostestas19 | 5:3754211a1b5b | 325 | } |
tostestas19 | 5:3754211a1b5b | 326 | |
tostestas19 | 5:3754211a1b5b | 327 | if (!Right ){ |
tostestas19 | 5:3754211a1b5b | 328 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 329 | menu = 6 ; |
tostestas19 | 5:3754211a1b5b | 330 | } |
tostestas19 | 5:3754211a1b5b | 331 | |
tostestas19 | 5:3754211a1b5b | 332 | |
tostestas19 | 5:3754211a1b5b | 333 | myledV = 1; |
tostestas19 | 5:3754211a1b5b | 334 | myledR = 0; |
tostestas19 | 5:3754211a1b5b | 335 | |
tostestas19 | 5:3754211a1b5b | 336 | |
tostestas19 | 5:3754211a1b5b | 337 | break; //fin case 5 |
tostestas19 | 5:3754211a1b5b | 338 | |
tostestas19 | 5:3754211a1b5b | 339 | |
tostestas19 | 5:3754211a1b5b | 340 | case (6): |
tostestas19 | 5:3754211a1b5b | 341 | |
tostestas19 | 5:3754211a1b5b | 342 | lcd.locate(1,0); |
tostestas19 | 5:3754211a1b5b | 343 | lcd.printf(" l1 = %d cm" , l1); |
tostestas19 | 5:3754211a1b5b | 344 | lcd.locate(1,1); |
tostestas19 | 5:3754211a1b5b | 345 | lcd.printf(" lg = %d cm" , lg); |
tostestas19 | 5:3754211a1b5b | 346 | wait_ms(tempo_saisie); |
tostestas19 | 5:3754211a1b5b | 347 | |
tostestas19 | 5:3754211a1b5b | 348 | if (!Left ){ |
tostestas19 | 5:3754211a1b5b | 349 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 350 | menu = 2 ; |
tostestas19 | 5:3754211a1b5b | 351 | } |
tostestas19 | 5:3754211a1b5b | 352 | |
tostestas19 | 5:3754211a1b5b | 353 | myledR = 1; |
tostestas19 | 5:3754211a1b5b | 354 | myledV = 0; |
tostestas19 | 5:3754211a1b5b | 355 | |
tostestas19 | 5:3754211a1b5b | 356 | |
tostestas19 | 5:3754211a1b5b | 357 | break; //fin case 6 |
tostestas19 | 5:3754211a1b5b | 358 | |
tostestas19 | 5:3754211a1b5b | 359 | |
tostestas19 | 5:3754211a1b5b | 360 | case (7): |
tostestas19 | 5:3754211a1b5b | 361 | |
tostestas19 | 5:3754211a1b5b | 362 | |
tostestas19 | 5:3754211a1b5b | 363 | lcd.locate(1,0); |
tostestas19 | 5:3754211a1b5b | 364 | lcd.printf(" HTML "); |
tostestas19 | 5:3754211a1b5b | 365 | wait_ms(tempo_saisie); |
tostestas19 | 5:3754211a1b5b | 366 | |
tostestas19 | 5:3754211a1b5b | 367 | if (!Left ){ |
tostestas19 | 5:3754211a1b5b | 368 | lcd.cls(); |
tostestas19 | 5:3754211a1b5b | 369 | menu = 0 ; |
tostestas19 | 5:3754211a1b5b | 370 | } |
tostestas19 | 5:3754211a1b5b | 371 | |
tostestas19 | 5:3754211a1b5b | 372 | myledR = 1; |
tostestas19 | 5:3754211a1b5b | 373 | wait(0.2); |
tostestas19 | 5:3754211a1b5b | 374 | myledV = 0; |
tostestas19 | 5:3754211a1b5b | 375 | wait(0.2); |
tostestas19 | 5:3754211a1b5b | 376 | |
tostestas19 | 5:3754211a1b5b | 377 | myledR = 0; |
tostestas19 | 5:3754211a1b5b | 378 | wait(0.2); |
tostestas19 | 5:3754211a1b5b | 379 | myledV = 1; |
tostestas19 | 5:3754211a1b5b | 380 | wait(0.2); |
tostestas19 | 5:3754211a1b5b | 381 | |
tostestas19 | 5:3754211a1b5b | 382 | break; //fin case 7 |
tostestas19 | 5:3754211a1b5b | 383 | // http://192.168.1.102/rpc/pot1/read dans le navigateur permet de lire l'état du potard ! |
donatien | 0:0b1369ae8b74 | 384 | } |
donatien | 0:0b1369ae8b74 | 385 | |
donatien | 0:0b1369ae8b74 | 386 | |
donatien | 0:0b1369ae8b74 | 387 | } |
tostestas19 | 5:3754211a1b5b | 388 | } |