![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
web server load-drive and reading sensors based on LPC1768
Dependencies: DHT22 EthernetNetIf HTTPServer mbed
main.cpp@0:3125f39d20b4, 2015-12-07 (annotated)
- Committer:
- douglasofranco
- Date:
- Mon Dec 07 14:06:24 2015 +0000
- Revision:
- 0:3125f39d20b4
Web server load-drive and reading sensors based on LPC1768
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
douglasofranco | 0:3125f39d20b4 | 1 | /* SISTEMA DE MONITORAMENTO REMOTO para LPC1768. |
douglasofranco | 0:3125f39d20b4 | 2 | *Este código foi desenvolvido como parte de um projeto de Especialização, e utiliza varias bibliotecas |
douglasofranco | 0:3125f39d20b4 | 3 | *que estão disponiveis em https://developer.mbed.org/code/. |
douglasofranco | 0:3125f39d20b4 | 4 | * |
douglasofranco | 0:3125f39d20b4 | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
douglasofranco | 0:3125f39d20b4 | 6 | * of this software and associated documentation files (the "Software"), to deal |
douglasofranco | 0:3125f39d20b4 | 7 | * in the Software without restriction, including without limitation the rights |
douglasofranco | 0:3125f39d20b4 | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
douglasofranco | 0:3125f39d20b4 | 9 | * copies of the Software, and to permit persons to whom the Software is |
douglasofranco | 0:3125f39d20b4 | 10 | * furnished to do so, subject to the following conditions: |
douglasofranco | 0:3125f39d20b4 | 11 | * |
douglasofranco | 0:3125f39d20b4 | 12 | * The above copyright notice and this permission notice shall be included in |
douglasofranco | 0:3125f39d20b4 | 13 | * all copies or substantial portions of the Software. |
douglasofranco | 0:3125f39d20b4 | 14 | * |
douglasofranco | 0:3125f39d20b4 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
douglasofranco | 0:3125f39d20b4 | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
douglasofranco | 0:3125f39d20b4 | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
douglasofranco | 0:3125f39d20b4 | 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
douglasofranco | 0:3125f39d20b4 | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
douglasofranco | 0:3125f39d20b4 | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
douglasofranco | 0:3125f39d20b4 | 21 | * THE SOFTWARE. |
douglasofranco | 0:3125f39d20b4 | 22 | */ |
douglasofranco | 0:3125f39d20b4 | 23 | |
douglasofranco | 0:3125f39d20b4 | 24 | #include "mbed.h" |
douglasofranco | 0:3125f39d20b4 | 25 | #include "SensorHandler.h" |
douglasofranco | 0:3125f39d20b4 | 26 | #include "EthernetNetIf.h" |
douglasofranco | 0:3125f39d20b4 | 27 | #include "HTTPServer.h" |
douglasofranco | 0:3125f39d20b4 | 28 | #include "Leitura.h" |
douglasofranco | 0:3125f39d20b4 | 29 | #include "Print.h" |
douglasofranco | 0:3125f39d20b4 | 30 | #include "TextLCD.h" |
douglasofranco | 0:3125f39d20b4 | 31 | #include "Atuadores.h" |
douglasofranco | 0:3125f39d20b4 | 32 | //#include "Temporizadores.h" |
douglasofranco | 0:3125f39d20b4 | 33 | |
douglasofranco | 0:3125f39d20b4 | 34 | Ticker to1; |
douglasofranco | 0:3125f39d20b4 | 35 | Ticker to2; |
douglasofranco | 0:3125f39d20b4 | 36 | Ticker to3; |
douglasofranco | 0:3125f39d20b4 | 37 | Ticker Serie; |
douglasofranco | 0:3125f39d20b4 | 38 | Ticker Curr; |
douglasofranco | 0:3125f39d20b4 | 39 | Timer timer3; |
douglasofranco | 0:3125f39d20b4 | 40 | Timer timer4; |
douglasofranco | 0:3125f39d20b4 | 41 | Timer timer5; |
douglasofranco | 0:3125f39d20b4 | 42 | Timer debounce; |
douglasofranco | 0:3125f39d20b4 | 43 | |
douglasofranco | 0:3125f39d20b4 | 44 | DigitalOut led1(LED3); // for alive check |
douglasofranco | 0:3125f39d20b4 | 45 | DigitalOut Lampadas(p30); |
douglasofranco | 0:3125f39d20b4 | 46 | |
douglasofranco | 0:3125f39d20b4 | 47 | InterruptIn Ilumin(p21); |
douglasofranco | 0:3125f39d20b4 | 48 | InterruptIn ArC(p22); |
douglasofranco | 0:3125f39d20b4 | 49 | InterruptIn Carreg(p23); |
douglasofranco | 0:3125f39d20b4 | 50 | InterruptIn Menu(p24); |
douglasofranco | 0:3125f39d20b4 | 51 | |
douglasofranco | 0:3125f39d20b4 | 52 | EthernetNetIf ethif( IpAddr(10,193,240,158), // IP |
douglasofranco | 0:3125f39d20b4 | 53 | IpAddr(255,255,255,248), // Subnet mask |
douglasofranco | 0:3125f39d20b4 | 54 | IpAddr(10,193,240,153), //Gateway |
douglasofranco | 0:3125f39d20b4 | 55 | IpAddr(10,193,4,3) ); // DNS |
douglasofranco | 0:3125f39d20b4 | 56 | |
douglasofranco | 0:3125f39d20b4 | 57 | /* |
douglasofranco | 0:3125f39d20b4 | 58 | EthernetNetIf ethif( IpAddr(192,168,0,18), // IP |
douglasofranco | 0:3125f39d20b4 | 59 | IpAddr(255,255,255,0), // Subnet mask |
douglasofranco | 0:3125f39d20b4 | 60 | IpAddr(192,168,0,1), // Gateway |
douglasofranco | 0:3125f39d20b4 | 61 | IpAddr(192,168,0,1) ); // DNS |
douglasofranco | 0:3125f39d20b4 | 62 | */ |
douglasofranco | 0:3125f39d20b4 | 63 | //EthernetNetIf eth; |
douglasofranco | 0:3125f39d20b4 | 64 | HTTPServer server; |
douglasofranco | 0:3125f39d20b4 | 65 | Leituras sensores; |
douglasofranco | 0:3125f39d20b4 | 66 | Leituras Baterias; |
douglasofranco | 0:3125f39d20b4 | 67 | Leituras EnerEletrica; |
douglasofranco | 0:3125f39d20b4 | 68 | Leituras Correntes1; |
douglasofranco | 0:3125f39d20b4 | 69 | Leituras Correntes2; |
douglasofranco | 0:3125f39d20b4 | 70 | Leituras Correntes3; |
douglasofranco | 0:3125f39d20b4 | 71 | Print imprime; |
douglasofranco | 0:3125f39d20b4 | 72 | Print impri; |
douglasofranco | 0:3125f39d20b4 | 73 | Print Text; |
douglasofranco | 0:3125f39d20b4 | 74 | Print impriCC; |
douglasofranco | 0:3125f39d20b4 | 75 | Print Aviso1; |
douglasofranco | 0:3125f39d20b4 | 76 | Print Aviso2; |
douglasofranco | 0:3125f39d20b4 | 77 | Print clear; |
douglasofranco | 0:3125f39d20b4 | 78 | //Estouro teste; |
douglasofranco | 0:3125f39d20b4 | 79 | Atuadores AR; |
douglasofranco | 0:3125f39d20b4 | 80 | Atuadores CARR; |
douglasofranco | 0:3125f39d20b4 | 81 | Atuadores desligar; |
douglasofranco | 0:3125f39d20b4 | 82 | Atuadores religar; |
douglasofranco | 0:3125f39d20b4 | 83 | |
douglasofranco | 0:3125f39d20b4 | 84 | Serial pc(USBTX, USBRX); // tx, rx |
douglasofranco | 0:3125f39d20b4 | 85 | |
douglasofranco | 0:3125f39d20b4 | 86 | bool g_bLed1 = false; |
douglasofranco | 0:3125f39d20b4 | 87 | bool g_bHighLow = true; |
douglasofranco | 0:3125f39d20b4 | 88 | bool Valor_RetornadoWeb = 0; |
douglasofranco | 0:3125f39d20b4 | 89 | int Bot_Lampada; |
douglasofranco | 0:3125f39d20b4 | 90 | int Bot_Menu; |
douglasofranco | 0:3125f39d20b4 | 91 | int Item = 0; |
douglasofranco | 0:3125f39d20b4 | 92 | int TravaAviso = 0; |
douglasofranco | 0:3125f39d20b4 | 93 | int TravaAviso2 = 0; |
douglasofranco | 0:3125f39d20b4 | 94 | int T =0; |
douglasofranco | 0:3125f39d20b4 | 95 | int trava =0; |
douglasofranco | 0:3125f39d20b4 | 96 | extern int CarregadorB; |
douglasofranco | 0:3125f39d20b4 | 97 | extern int ArCondB; |
douglasofranco | 0:3125f39d20b4 | 98 | |
douglasofranco | 0:3125f39d20b4 | 99 | |
douglasofranco | 0:3125f39d20b4 | 100 | void sensordht(void) |
douglasofranco | 0:3125f39d20b4 | 101 | { |
douglasofranco | 0:3125f39d20b4 | 102 | sensores.clima(); |
douglasofranco | 0:3125f39d20b4 | 103 | if ((TravaAviso == 0) && (TravaAviso2 == 0)) { |
douglasofranco | 0:3125f39d20b4 | 104 | Text.imprimeTexto(); |
douglasofranco | 0:3125f39d20b4 | 105 | imprime.imprimeTemp(); |
douglasofranco | 0:3125f39d20b4 | 106 | } |
douglasofranco | 0:3125f39d20b4 | 107 | } |
douglasofranco | 0:3125f39d20b4 | 108 | |
douglasofranco | 0:3125f39d20b4 | 109 | void sensorbat(void) |
douglasofranco | 0:3125f39d20b4 | 110 | { |
douglasofranco | 0:3125f39d20b4 | 111 | Baterias.TensaoCC(); |
douglasofranco | 0:3125f39d20b4 | 112 | } |
douglasofranco | 0:3125f39d20b4 | 113 | |
douglasofranco | 0:3125f39d20b4 | 114 | void sensorac(void) |
douglasofranco | 0:3125f39d20b4 | 115 | { |
douglasofranco | 0:3125f39d20b4 | 116 | EnerEletrica.TensaoAC(); |
douglasofranco | 0:3125f39d20b4 | 117 | } |
douglasofranco | 0:3125f39d20b4 | 118 | |
douglasofranco | 0:3125f39d20b4 | 119 | void sensorCorrrente (void) |
douglasofranco | 0:3125f39d20b4 | 120 | { |
douglasofranco | 0:3125f39d20b4 | 121 | Correntes1.corrente(); |
douglasofranco | 0:3125f39d20b4 | 122 | Correntes2.corrente2(); |
douglasofranco | 0:3125f39d20b4 | 123 | Correntes3.corrente3(); |
douglasofranco | 0:3125f39d20b4 | 124 | } |
douglasofranco | 0:3125f39d20b4 | 125 | |
douglasofranco | 0:3125f39d20b4 | 126 | void esperaB (void) |
douglasofranco | 0:3125f39d20b4 | 127 | { |
douglasofranco | 0:3125f39d20b4 | 128 | wait_ms(200); |
douglasofranco | 0:3125f39d20b4 | 129 | } |
douglasofranco | 0:3125f39d20b4 | 130 | |
douglasofranco | 0:3125f39d20b4 | 131 | void Bmenu (void) |
douglasofranco | 0:3125f39d20b4 | 132 | { |
douglasofranco | 0:3125f39d20b4 | 133 | if(debounce.read_ms()>300) { // only allow toggle after 20 ms |
douglasofranco | 0:3125f39d20b4 | 134 | if (Bot_Menu !=1) { |
douglasofranco | 0:3125f39d20b4 | 135 | Item = Item + 1; |
douglasofranco | 0:3125f39d20b4 | 136 | if(Item == 1) { |
douglasofranco | 0:3125f39d20b4 | 137 | Text.imprimeTexto(); |
douglasofranco | 0:3125f39d20b4 | 138 | imprime.imprimeTemp(); |
douglasofranco | 0:3125f39d20b4 | 139 | } else if(Item == 2) { |
douglasofranco | 0:3125f39d20b4 | 140 | Text.imprimeTexto(); |
douglasofranco | 0:3125f39d20b4 | 141 | impri.imprimeCurr(); |
douglasofranco | 0:3125f39d20b4 | 142 | } else if(Item == 3) { |
douglasofranco | 0:3125f39d20b4 | 143 | Text.imprimeTexto(); |
douglasofranco | 0:3125f39d20b4 | 144 | impriCC.imprimeCC(); |
douglasofranco | 0:3125f39d20b4 | 145 | Item = 0; |
douglasofranco | 0:3125f39d20b4 | 146 | } |
douglasofranco | 0:3125f39d20b4 | 147 | } |
douglasofranco | 0:3125f39d20b4 | 148 | debounce.reset(); // restart timer after toggle |
douglasofranco | 0:3125f39d20b4 | 149 | } |
douglasofranco | 0:3125f39d20b4 | 150 | } |
douglasofranco | 0:3125f39d20b4 | 151 | |
douglasofranco | 0:3125f39d20b4 | 152 | void Blamapada (void) |
douglasofranco | 0:3125f39d20b4 | 153 | { |
douglasofranco | 0:3125f39d20b4 | 154 | if(debounce.read_ms()>300) { // only allow toggle after 20 ms |
douglasofranco | 0:3125f39d20b4 | 155 | if (Lampadas == 0) { |
douglasofranco | 0:3125f39d20b4 | 156 | Lampadas = 1; |
douglasofranco | 0:3125f39d20b4 | 157 | } else |
douglasofranco | 0:3125f39d20b4 | 158 | Lampadas = 0; |
douglasofranco | 0:3125f39d20b4 | 159 | } |
douglasofranco | 0:3125f39d20b4 | 160 | debounce.reset(); // restart timer after toggle |
douglasofranco | 0:3125f39d20b4 | 161 | } |
douglasofranco | 0:3125f39d20b4 | 162 | |
douglasofranco | 0:3125f39d20b4 | 163 | void Bar (void) |
douglasofranco | 0:3125f39d20b4 | 164 | { |
douglasofranco | 0:3125f39d20b4 | 165 | if(debounce.read_ms()>300) { // only allow toggle after 20 ms |
douglasofranco | 0:3125f39d20b4 | 166 | if (ArCondB == 0) { |
douglasofranco | 0:3125f39d20b4 | 167 | ArCondB = 1; |
douglasofranco | 0:3125f39d20b4 | 168 | } else |
douglasofranco | 0:3125f39d20b4 | 169 | ArCondB = 0; |
douglasofranco | 0:3125f39d20b4 | 170 | } |
douglasofranco | 0:3125f39d20b4 | 171 | debounce.reset(); // restart timer after toggle |
douglasofranco | 0:3125f39d20b4 | 172 | } |
douglasofranco | 0:3125f39d20b4 | 173 | |
douglasofranco | 0:3125f39d20b4 | 174 | void Bcarr (void) |
douglasofranco | 0:3125f39d20b4 | 175 | { |
douglasofranco | 0:3125f39d20b4 | 176 | if(debounce.read_ms()>300) { // only allow toggle after 20 ms |
douglasofranco | 0:3125f39d20b4 | 177 | if (CarregadorB == 0) { |
douglasofranco | 0:3125f39d20b4 | 178 | CarregadorB = 1; |
douglasofranco | 0:3125f39d20b4 | 179 | } else |
douglasofranco | 0:3125f39d20b4 | 180 | CarregadorB = 0; |
douglasofranco | 0:3125f39d20b4 | 181 | } |
douglasofranco | 0:3125f39d20b4 | 182 | debounce.reset(); // restart timer after toggle |
douglasofranco | 0:3125f39d20b4 | 183 | } |
douglasofranco | 0:3125f39d20b4 | 184 | void ImpSerial (void) |
douglasofranco | 0:3125f39d20b4 | 185 | { |
douglasofranco | 0:3125f39d20b4 | 186 | pc.printf("\r valor X9 = %d\n",x9); |
douglasofranco | 0:3125f39d20b4 | 187 | pc.printf("\r valor X92 = %d\n",x92); |
douglasofranco | 0:3125f39d20b4 | 188 | pc.printf("\r valor retornado de gb_Led1= %d\n",g_bLed1); |
douglasofranco | 0:3125f39d20b4 | 189 | pc.printf("\r valor 2 retornado = %d\n",Valor_RetornadoWeb); |
douglasofranco | 0:3125f39d20b4 | 190 | pc.printf("\r bateria = %f\n",Tcc); |
douglasofranco | 0:3125f39d20b4 | 191 | pc.printf("\r getValor = %2.5f\n",getValor); |
douglasofranco | 0:3125f39d20b4 | 192 | pc.printf("\r Bot Carr = %d\n",CarregadorB); |
douglasofranco | 0:3125f39d20b4 | 193 | pc.printf("\r Bot Ar = %d\n",ArCondB); |
douglasofranco | 0:3125f39d20b4 | 194 | pc.printf("\r TravaAviso = %d\n",TravaAviso); |
douglasofranco | 0:3125f39d20b4 | 195 | pc.printf("\r TravaAviso = %d\n",TravaAviso2); |
douglasofranco | 0:3125f39d20b4 | 196 | // pc.printf("\r T = %d\n",T); |
douglasofranco | 0:3125f39d20b4 | 197 | pc.printf("\r Timer 3= %f sec\n", timer3.read()); |
douglasofranco | 0:3125f39d20b4 | 198 | pc.printf("\r Timer 4= %f sec\n", timer4.read()); |
douglasofranco | 0:3125f39d20b4 | 199 | pc.printf("\r Timer 5= %f sec\n", timer5.read()); |
douglasofranco | 0:3125f39d20b4 | 200 | // pc.printf("\r corrente 3= %f\n ",sensorValue_aux3); |
douglasofranco | 0:3125f39d20b4 | 201 | // pc.printf("\r corrente 3= %s\n\n",Corrente3); |
douglasofranco | 0:3125f39d20b4 | 202 | // pc.printf("\r TEnsao AC= %f\n\n", TensAC); |
douglasofranco | 0:3125f39d20b4 | 203 | // pc.printf("\r Estado da Lampada = %d\n\n", Lampadas); |
douglasofranco | 0:3125f39d20b4 | 204 | pc.printf("\r Estado da trava = %d\n\n", trava); |
douglasofranco | 0:3125f39d20b4 | 205 | |
douglasofranco | 0:3125f39d20b4 | 206 | } |
douglasofranco | 0:3125f39d20b4 | 207 | int main() |
douglasofranco | 0:3125f39d20b4 | 208 | { |
douglasofranco | 0:3125f39d20b4 | 209 | |
douglasofranco | 0:3125f39d20b4 | 210 | timer3.start(); |
douglasofranco | 0:3125f39d20b4 | 211 | // timer4.start(); |
douglasofranco | 0:3125f39d20b4 | 212 | Ilumin.mode(PullUp); //Pull up porta do botão lampada |
douglasofranco | 0:3125f39d20b4 | 213 | Menu.mode(PullUp); //Pull up porta do botão menu |
douglasofranco | 0:3125f39d20b4 | 214 | ArC.mode(PullUp); //Pull up porta do botão Ar |
douglasofranco | 0:3125f39d20b4 | 215 | Carreg.mode(PullUp); //Pull up porta do botão Garreg |
douglasofranco | 0:3125f39d20b4 | 216 | to1.attach(&sensordht, 19.3); //Temporizador de leitura do DHT22 |
douglasofranco | 0:3125f39d20b4 | 217 | to2.attach(&sensorbat, 0.7); //Temporizador de leitura das Baterias |
douglasofranco | 0:3125f39d20b4 | 218 | to3.attach(&sensorac, 5.9); |
douglasofranco | 0:3125f39d20b4 | 219 | Curr.attach(&sensorCorrrente, 1.2); |
douglasofranco | 0:3125f39d20b4 | 220 | Serie.attach(&ImpSerial, 4.0); |
douglasofranco | 0:3125f39d20b4 | 221 | debounce.start(); |
douglasofranco | 0:3125f39d20b4 | 222 | |
douglasofranco | 0:3125f39d20b4 | 223 | Menu.fall(&Bmenu); //aguarda a borda de decida para gerar a interrupção do menu |
douglasofranco | 0:3125f39d20b4 | 224 | Ilumin.fall(&Blamapada); //aguarda a borda de decida para gerar a interrupção da lamapada |
douglasofranco | 0:3125f39d20b4 | 225 | ArC.fall(&Bar); //aguarda a borda de decida para gerar a interrupção do Ar |
douglasofranco | 0:3125f39d20b4 | 226 | Carreg.fall(&Bcarr); //aguarda a borda de decida para gerar a interrupção do Carregador |
douglasofranco | 0:3125f39d20b4 | 227 | |
douglasofranco | 0:3125f39d20b4 | 228 | Menu.rise(&esperaB); //aguarda a borda de Subida para gerar a interrupção de espera |
douglasofranco | 0:3125f39d20b4 | 229 | Ilumin.rise(&esperaB); |
douglasofranco | 0:3125f39d20b4 | 230 | ArC.rise(&esperaB); |
douglasofranco | 0:3125f39d20b4 | 231 | Carreg.rise(&esperaB); |
douglasofranco | 0:3125f39d20b4 | 232 | |
douglasofranco | 0:3125f39d20b4 | 233 | // EthernetNetIf setup |
douglasofranco | 0:3125f39d20b4 | 234 | if(ethif.setup()) { |
douglasofranco | 0:3125f39d20b4 | 235 | return 1; |
douglasofranco | 0:3125f39d20b4 | 236 | } |
douglasofranco | 0:3125f39d20b4 | 237 | Text.imprimeTexto(); |
douglasofranco | 0:3125f39d20b4 | 238 | |
douglasofranco | 0:3125f39d20b4 | 239 | // Set web root path handler |
douglasofranco | 0:3125f39d20b4 | 240 | server.addHandler<SensorHandler>("/"); |
douglasofranco | 0:3125f39d20b4 | 241 | // Set http port |
douglasofranco | 0:3125f39d20b4 | 242 | server.bind(80); |
douglasofranco | 0:3125f39d20b4 | 243 | Timer tmLed; |
douglasofranco | 0:3125f39d20b4 | 244 | Timer tm; |
douglasofranco | 0:3125f39d20b4 | 245 | tmLed.start(); |
douglasofranco | 0:3125f39d20b4 | 246 | tm.start(); |
douglasofranco | 0:3125f39d20b4 | 247 | |
douglasofranco | 0:3125f39d20b4 | 248 | while (1) { |
douglasofranco | 0:3125f39d20b4 | 249 | |
douglasofranco | 0:3125f39d20b4 | 250 | if ((( x9==1 ) || (x92 == 1)) && (TravaAviso == 0)) { |
douglasofranco | 0:3125f39d20b4 | 251 | Aviso1.imprimeAviso(); |
douglasofranco | 0:3125f39d20b4 | 252 | TravaAviso = 1; |
douglasofranco | 0:3125f39d20b4 | 253 | timer4.reset(); |
douglasofranco | 0:3125f39d20b4 | 254 | timer4.start(); |
douglasofranco | 0:3125f39d20b4 | 255 | timer5.reset(); |
douglasofranco | 0:3125f39d20b4 | 256 | timer5.start(); |
douglasofranco | 0:3125f39d20b4 | 257 | } |
douglasofranco | 0:3125f39d20b4 | 258 | |
douglasofranco | 0:3125f39d20b4 | 259 | if((( x9==2 ) || (x92 == 2)) && (TravaAviso2 == 0)) { |
douglasofranco | 0:3125f39d20b4 | 260 | Aviso2.imprimeAviso2(); |
douglasofranco | 0:3125f39d20b4 | 261 | TravaAviso2 = 1; |
douglasofranco | 0:3125f39d20b4 | 262 | timer4.reset(); |
douglasofranco | 0:3125f39d20b4 | 263 | timer4.start(); |
douglasofranco | 0:3125f39d20b4 | 264 | timer5.reset(); |
douglasofranco | 0:3125f39d20b4 | 265 | timer5.start(); |
douglasofranco | 0:3125f39d20b4 | 266 | } |
douglasofranco | 0:3125f39d20b4 | 267 | |
douglasofranco | 0:3125f39d20b4 | 268 | if ( (timer3.read()) > 1800) { //tempo em segundos = 30minutos. 1800 *tempo para desligar as cargas |
douglasofranco | 0:3125f39d20b4 | 269 | T ++; |
douglasofranco | 0:3125f39d20b4 | 270 | timer3.reset(); |
douglasofranco | 0:3125f39d20b4 | 271 | if(T==16) { |
douglasofranco | 0:3125f39d20b4 | 272 | desligar.Desliga(); |
douglasofranco | 0:3125f39d20b4 | 273 | TravaAviso=0; |
douglasofranco | 0:3125f39d20b4 | 274 | TravaAviso2=0; |
douglasofranco | 0:3125f39d20b4 | 275 | T = 0; |
douglasofranco | 0:3125f39d20b4 | 276 | } |
douglasofranco | 0:3125f39d20b4 | 277 | } |
douglasofranco | 0:3125f39d20b4 | 278 | if ( (timer4.read()) > 30) { //tempo em segundos = 1minuto. *tempo para apagar aviso |
douglasofranco | 0:3125f39d20b4 | 279 | TravaAviso2= 0; |
douglasofranco | 0:3125f39d20b4 | 280 | TravaAviso= 0 ; |
douglasofranco | 0:3125f39d20b4 | 281 | x9=0; |
douglasofranco | 0:3125f39d20b4 | 282 | x92=0; |
douglasofranco | 0:3125f39d20b4 | 283 | timer4.stop(); |
douglasofranco | 0:3125f39d20b4 | 284 | } |
douglasofranco | 0:3125f39d20b4 | 285 | if ( (timer5.read()) > 1800) { //tempo em segundos = 30minutos. *tempo para religar as garcas |
douglasofranco | 0:3125f39d20b4 | 286 | religar.Religa(); |
douglasofranco | 0:3125f39d20b4 | 287 | timer5.stop(); |
douglasofranco | 0:3125f39d20b4 | 288 | } |
douglasofranco | 0:3125f39d20b4 | 289 | |
douglasofranco | 0:3125f39d20b4 | 290 | AR.AtuadorAr(); |
douglasofranco | 0:3125f39d20b4 | 291 | CARR.AtuadorCarr(); |
douglasofranco | 0:3125f39d20b4 | 292 | |
douglasofranco | 0:3125f39d20b4 | 293 | Net::poll(); |
douglasofranco | 0:3125f39d20b4 | 294 | if( 1.0 < tm.read() ) { |
douglasofranco | 0:3125f39d20b4 | 295 | led1 = !led1; // high->low, low->high |
douglasofranco | 0:3125f39d20b4 | 296 | tm.start(); |
douglasofranco | 0:3125f39d20b4 | 297 | } |
douglasofranco | 0:3125f39d20b4 | 298 | |
douglasofranco | 0:3125f39d20b4 | 299 | if( 1.0 < tmLed.read() ) { |
douglasofranco | 0:3125f39d20b4 | 300 | Valor_RetornadoWeb = g_bLed1; |
douglasofranco | 0:3125f39d20b4 | 301 | |
douglasofranco | 0:3125f39d20b4 | 302 | if(Valor_RetornadoWeb == true && trava == 0) { |
douglasofranco | 0:3125f39d20b4 | 303 | Lampadas = 1; |
douglasofranco | 0:3125f39d20b4 | 304 | trava = 1; |
douglasofranco | 0:3125f39d20b4 | 305 | } |
douglasofranco | 0:3125f39d20b4 | 306 | if(Valor_RetornadoWeb == false && trava == 1) { |
douglasofranco | 0:3125f39d20b4 | 307 | Lampadas = 0; |
douglasofranco | 0:3125f39d20b4 | 308 | trava = 0; |
douglasofranco | 0:3125f39d20b4 | 309 | } |
douglasofranco | 0:3125f39d20b4 | 310 | wait_ms(50); |
douglasofranco | 0:3125f39d20b4 | 311 | tmLed.start(); |
douglasofranco | 0:3125f39d20b4 | 312 | } |
douglasofranco | 0:3125f39d20b4 | 313 | } |
douglasofranco | 0:3125f39d20b4 | 314 | } |
douglasofranco | 0:3125f39d20b4 | 315 |