Utilizando a Nucleo F103RB com um módulo LCD e um Joystick para interface

Dependencies:   mbed

Committer:
kaiquedog
Date:
Tue Jun 09 02:31:51 2020 +0000
Revision:
4:a0a633b93fd0
Parent:
3:fcdbe4af1b6d
Child:
5:c549c4b25997
FINAL;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kaiquedog 0:bf743d54917c 1 // /
kaiquedog 0:bf743d54917c 2 // _,.------....___,.' ',.-.
kaiquedog 0:bf743d54917c 3 // ,-' _,.--" |
kaiquedog 0:bf743d54917c 4 // ,' _.-' .
kaiquedog 0:bf743d54917c 5 // / , ,' `
kaiquedog 0:bf743d54917c 6 // . / / ``.
kaiquedog 0:bf743d54917c 7 // | | . \.\
kaiquedog 0:bf743d54917c 8 // ____ |___._. | __ \ `.
kaiquedog 0:bf743d54917c 9 // .' `---"" ``"-.--"'` \ . \
kaiquedog 0:bf743d54917c 10 // . , __ ` | .
kaiquedog 0:bf743d54917c 11 // `,' ,-"' . \ | L
kaiquedog 0:bf743d54917c 12 // ,' ' _.' -._ / |
kaiquedog 0:bf743d54917c 13 // ,`-. ,". `--' >. ,' |
kaiquedog 0:bf743d54917c 14 // . .'\' `-' __ , ,-. / `.__.- ,'
kaiquedog 0:bf743d54917c 15 // ||:, . ,' ; / / \ ` `. . .'/
kaiquedog 0:bf743d54917c 16 // j|:D \ `--' ' ,'_ . . `.__, \ , /
kaiquedog 0:bf743d54917c 17 // L:_ | . "' :_; `.'.'
kaiquedog 0:bf743d54917c 18 //. ""' """""' V
kaiquedog 0:bf743d54917c 19 // `. . `. _,.. `
kaiquedog 0:bf743d54917c 20 // `,_ . . _,-'/ .. `,' __ `
kaiquedog 0:bf743d54917c 21 // ) \`._ ___....----"' ,' .' \ | ' \ .
kaiquedog 0:bf743d54917c 22 // / `. "`-.--"' _,' ,' `---' | `./ |
kaiquedog 0:bf743d54917c 23 // . _ `""'--.._____..--" , ' |
kaiquedog 0:bf743d54917c 24 // | ." `. `-. /-. / ,
kaiquedog 0:bf743d54917c 25 // | `._.' `,_ ; / ,' .
kaiquedog 0:bf743d54917c 26 // .' /| `-. . ,' , ,
kaiquedog 0:bf743d54917c 27 // '-.__ __ _,',' '`-..___;-...__ ,.'\ ____.___.'
kaiquedog 0:bf743d54917c 28 // `"^--'..' '-`-^-'"-- `-^-'`.''"""""`.,^.`.--'
kaiquedog 0:bf743d54917c 29 #include "mbed.h"
kaiquedog 0:bf743d54917c 30 #include "LCD_ka.h"
kaiquedog 0:bf743d54917c 31 #include "Joystick.h"
kaiquedog 0:bf743d54917c 32 #include "Motor_de_passo.h"
kaiquedog 0:bf743d54917c 33
kaiquedog 4:a0a633b93fd0 34 Motor Ze(PB_13, PB_14, PB_15, PB_1, D9, D10, 'Z'); // (IN1, IN2, IN3, IN4, Sensor 1, Sensor 2, Eixo) (para shield do arduino, (PB_13, PB_14, PB_15, PB_1, D2, D3, 'X')
kaiquedog 3:fcdbe4af1b6d 35 Joystick Joy(A1, A2, USER_BUTTON); // (VRX, VRY, SW)
kaiquedog 3:fcdbe4af1b6d 36 LCD lcd(D6, D7, D2, D3, D4, D5); // Para conectar como arduíno: (D8, D9, D4, D5, D6, D7); Para default: (D6, D7, D2, D3, D4, D5);
kaiquedog 3:fcdbe4af1b6d 37 InterruptIn mybutton(D8); // Para shield, D10
kaiquedog 3:fcdbe4af1b6d 38 DigitalOut Rele(D11);
kaiquedog 3:fcdbe4af1b6d 39
kaiquedog 0:bf743d54917c 40
kaiquedog 0:bf743d54917c 41 /*
kaiquedog 0:bf743d54917c 42 **************************
kaiquedog 0:bf743d54917c 43 ***** INICIA FUNÇÕES *****
kaiquedog 0:bf743d54917c 44 **************************
kaiquedog 0:bf743d54917c 45 */
kaiquedog 0:bf743d54917c 46
kaiquedog 3:fcdbe4af1b6d 47 void Loop_Horario(); // Loop para girar o motor no sentido horário
kaiquedog 3:fcdbe4af1b6d 48 void Loop_Anti_Horario(); // Loop para girar o motor no sentido anti-horário
kaiquedog 3:fcdbe4af1b6d 49 void Aumenta_Vel(); // Função que aumenta a velocidade
kaiquedog 3:fcdbe4af1b6d 50 void Diminui_Vel(); // Função que Diminui a velocidade
kaiquedog 3:fcdbe4af1b6d 51 void Tela_1(); // Seletor de velocidades e sentido de rotação
kaiquedog 3:fcdbe4af1b6d 52 void Tela_2(); // Modo Step
kaiquedog 3:fcdbe4af1b6d 53 void Tela_Instrucao(int a); // Tela de instrução select
kaiquedog 3:fcdbe4af1b6d 54 void Tela_Instrucao_1(int a); // Tela de instrução para manuseio
kaiquedog 3:fcdbe4af1b6d 55 void Emergencia(); // Função para o botão de emergência
kaiquedog 3:fcdbe4af1b6d 56 void Loop_Menu(); // Loop da tela de menu
kaiquedog 3:fcdbe4af1b6d 57
kaiquedog 0:bf743d54917c 58
kaiquedog 0:bf743d54917c 59 /*
kaiquedog 0:bf743d54917c 60 **************************
kaiquedog 0:bf743d54917c 61 **** INICIA VARIÁVEIS ****
kaiquedog 0:bf743d54917c 62 **************************
kaiquedog 0:bf743d54917c 63 */
kaiquedog 3:fcdbe4af1b6d 64
kaiquedog 0:bf743d54917c 65 double tempos[] = {0.2, 0.02, 0.002}; // Tempos para mudar a velocidade
kaiquedog 0:bf743d54917c 66 string porcentagem[] = {"0.1%", " 10%", "100%"}; // Porcentagens em uma string para printar
kaiquedog 3:fcdbe4af1b6d 67 int t = 0; // Variável que guarda a posição do tempo e da porcentagem
kaiquedog 3:fcdbe4af1b6d 68 int menu = 1; // Variável que guarda o estado do menu
kaiquedog 3:fcdbe4af1b6d 69 int t1 = 1; // Variável que guarda o estado da tela 1
kaiquedog 3:fcdbe4af1b6d 70 int t2 = 1; // Variável que guarda o estado da tela 2
kaiquedog 3:fcdbe4af1b6d 71
kaiquedog 3:fcdbe4af1b6d 72
kaiquedog 0:bf743d54917c 73 /*
kaiquedog 0:bf743d54917c 74 ************************
kaiquedog 0:bf743d54917c 75 **** LOOP PRINCIPAL ****
kaiquedog 0:bf743d54917c 76 ************************
kaiquedog 0:bf743d54917c 77 */
kaiquedog 0:bf743d54917c 78
kaiquedog 0:bf743d54917c 79 int main(){
kaiquedog 0:bf743d54917c 80 if (mybutton == 1){
kaiquedog 0:bf743d54917c 81 Emergencia();
kaiquedog 0:bf743d54917c 82 }
kaiquedog 0:bf743d54917c 83 mybutton.rise(&Emergencia);
kaiquedog 3:fcdbe4af1b6d 84 /*
kaiquedog 3:fcdbe4af1b6d 85 lcd.printf(" Bem Vindo!");
kaiquedog 3:fcdbe4af1b6d 86 wait(2);
kaiquedog 3:fcdbe4af1b6d 87 lcd.clc();
kaiquedog 3:fcdbe4af1b6d 88 lcd.printf("A mesa esta vazia?");
kaiquedog 3:fcdbe4af1b6d 89 lcd.printf("S N");
kaiquedog 3:fcdbe4af1b6d 90 int vazia = 0;
kaiquedog 3:fcdbe4af1b6d 91 while (vazia == 0){
kaiquedog 3:fcdbe4af1b6d 92 switch (Joy.ler_x())
kaiquedog 3:fcdbe4af1b6d 93 {
kaiquedog 3:fcdbe4af1b6d 94 case 0: lcd.cima(); wait(0.2); break;
kaiquedog 3:fcdbe4af1b6d 95 case 1: lcd.baixo(); wait(0.2); break;
kaiquedog 3:fcdbe4af1b6d 96 }
kaiquedog 3:fcdbe4af1b6d 97 switch (Joy.ler_y())
kaiquedog 3:fcdbe4af1b6d 98 {
kaiquedog 3:fcdbe4af1b6d 99 case 0: lcd.direita(); wait(0.2); break;
kaiquedog 3:fcdbe4af1b6d 100 case 1: lcd.esquerda(); wait(0.2); break;
kaiquedog 3:fcdbe4af1b6d 101 }
kaiquedog 3:fcdbe4af1b6d 102 switch (Joy.bot_select())
kaiquedog 3:fcdbe4af1b6d 103 {
kaiquedog 3:fcdbe4af1b6d 104 case 0: if ((lcd.Lepos()[1] == '2') && (lcd.Lepos()[3] == '1')){
kaiquedog 3:fcdbe4af1b6d 105 vazia = 1;}
kaiquedog 3:fcdbe4af1b6d 106
kaiquedog 3:fcdbe4af1b6d 107 else{ wait(0.2); lcd.clc(); lcd.printf("Esvazie a mesa"); wait(1); lcd.clc(); lcd.printf("Está vazia?")lcd.pos(2,1); lcd.printf(">Sim >Nao");}
kaiquedog 3:fcdbe4af1b6d 108 }
kaiquedog 3:fcdbe4af1b6d 109 }
kaiquedog 3:fcdbe4af1b6d 110 */
kaiquedog 3:fcdbe4af1b6d 111
kaiquedog 0:bf743d54917c 112 Loop_Menu();
kaiquedog 0:bf743d54917c 113 }
kaiquedog 0:bf743d54917c 114
kaiquedog 3:fcdbe4af1b6d 115
kaiquedog 0:bf743d54917c 116 /*
kaiquedog 0:bf743d54917c 117 ************************
kaiquedog 0:bf743d54917c 118 **** DEFINE FUNÇÕES ****
kaiquedog 0:bf743d54917c 119 ************************
kaiquedog 0:bf743d54917c 120 */
kaiquedog 0:bf743d54917c 121
kaiquedog 0:bf743d54917c 122 void Loop_Menu(){
kaiquedog 0:bf743d54917c 123 wait(0.2);
kaiquedog 0:bf743d54917c 124 lcd.clc();
kaiquedog 0:bf743d54917c 125 lcd.printf("> Modo Livre");
kaiquedog 0:bf743d54917c 126 lcd.pos(2,1);
kaiquedog 0:bf743d54917c 127 lcd.printf("> Modo Steps");
kaiquedog 0:bf743d54917c 128 menu = 1;
kaiquedog 0:bf743d54917c 129 lcd.home();
kaiquedog 0:bf743d54917c 130 while(menu >= 1){
kaiquedog 0:bf743d54917c 131 switch (Joy.ler_x())
kaiquedog 0:bf743d54917c 132 {
kaiquedog 0:bf743d54917c 133 case 0: lcd.cima(); wait(0.2); break;
kaiquedog 0:bf743d54917c 134 case 1: lcd.baixo(); wait(0.2); break;
kaiquedog 0:bf743d54917c 135 }
kaiquedog 0:bf743d54917c 136 switch (Joy.ler_y())
kaiquedog 0:bf743d54917c 137 {
kaiquedog 0:bf743d54917c 138 case 0: lcd.direita(); wait(0.2); break;
kaiquedog 0:bf743d54917c 139 case 1: lcd.esquerda(); wait(0.2); break;
kaiquedog 0:bf743d54917c 140 }
kaiquedog 0:bf743d54917c 141 switch (Joy.bot_select())
kaiquedog 0:bf743d54917c 142 {
kaiquedog 0:bf743d54917c 143 case 0: menu = 0;
kaiquedog 0:bf743d54917c 144 if ((lcd.Lepos()[1] == '1') && (lcd.Lepos()[3] == '1')){
kaiquedog 0:bf743d54917c 145 Tela_Instrucao(1);}
kaiquedog 0:bf743d54917c 146 if ((lcd.Lepos()[1] == '2') && (lcd.Lepos()[3] == '1')){
kaiquedog 0:bf743d54917c 147 Tela_Instrucao(2);}
kaiquedog 0:bf743d54917c 148 wait(0.2); break;
kaiquedog 0:bf743d54917c 149 }
kaiquedog 0:bf743d54917c 150 if (menu == 2){
kaiquedog 0:bf743d54917c 151 lcd.clc();
kaiquedog 0:bf743d54917c 152 lcd.printf("> Modo Livre");
kaiquedog 0:bf743d54917c 153 lcd.pos(2,1);
kaiquedog 0:bf743d54917c 154 lcd.printf("> Modo Steps");
kaiquedog 0:bf743d54917c 155 menu = 1;
kaiquedog 0:bf743d54917c 156 lcd.home();
kaiquedog 0:bf743d54917c 157 }
kaiquedog 0:bf743d54917c 158 }
kaiquedog 0:bf743d54917c 159
kaiquedog 0:bf743d54917c 160 }
kaiquedog 0:bf743d54917c 161
kaiquedog 0:bf743d54917c 162 void Loop_Horario(){ // Enquanto o valor de VRX for > 800 o motor continua girando.
kaiquedog 0:bf743d54917c 163 while( Joy.ler_x() == 0){
kaiquedog 4:a0a633b93fd0 164 Ze.Full();
kaiquedog 4:a0a633b93fd0 165 lcd.pos(2,5);
kaiquedog 4:a0a633b93fd0 166 lcd.printf("%.3f", Ze.Angulo); lcd.putc(0xDF); lcd.putc(0x10);
kaiquedog 0:bf743d54917c 167 }
kaiquedog 4:a0a633b93fd0 168 Ze.mot = 0b0000;
kaiquedog 0:bf743d54917c 169 }
kaiquedog 0:bf743d54917c 170
kaiquedog 0:bf743d54917c 171 void Loop_Anti_Horario(){ // Enquanto o valor de VRX for < 200 o motor continua girando
kaiquedog 0:bf743d54917c 172 while( Joy.ler_x() == 1){
kaiquedog 4:a0a633b93fd0 173 Ze.Full_();
kaiquedog 4:a0a633b93fd0 174 lcd.pos(2,5);
kaiquedog 4:a0a633b93fd0 175 lcd.printf("%.3f", Ze.Angulo); lcd.putc(0xDF); lcd.putc(0x10);
kaiquedog 0:bf743d54917c 176 }
kaiquedog 4:a0a633b93fd0 177 Ze.mot = 0b0000;
kaiquedog 0:bf743d54917c 178 }
kaiquedog 0:bf743d54917c 179
kaiquedog 0:bf743d54917c 180 void Aumenta_Vel(){ // Incrementa t em 1, muda a relação de tempo do Motor e printa o valor em porcentagem na tela
kaiquedog 0:bf743d54917c 181 t++;
kaiquedog 0:bf743d54917c 182 if (t == 3){
kaiquedog 0:bf743d54917c 183 t = 2;
kaiquedog 0:bf743d54917c 184 }
kaiquedog 4:a0a633b93fd0 185 Ze.Tempo = tempos[t];
kaiquedog 4:a0a633b93fd0 186 lcd.pos(1,5);
kaiquedog 0:bf743d54917c 187 lcd.printf("%s", porcentagem[t]);
kaiquedog 0:bf743d54917c 188 }
kaiquedog 0:bf743d54917c 189
kaiquedog 0:bf743d54917c 190 void Diminui_Vel(){ // Decrementa t em 1, muda a relação de tempo do Motor e printa o valor em porcentagem na tela
kaiquedog 0:bf743d54917c 191 t--;
kaiquedog 0:bf743d54917c 192 if (t == -1){
kaiquedog 0:bf743d54917c 193 t = 0;
kaiquedog 0:bf743d54917c 194 }
kaiquedog 4:a0a633b93fd0 195 Ze.Tempo = tempos[t];
kaiquedog 4:a0a633b93fd0 196 lcd.pos(1,5);
kaiquedog 0:bf743d54917c 197 lcd.printf("%s", porcentagem[t]);
kaiquedog 0:bf743d54917c 198 }
kaiquedog 0:bf743d54917c 199
kaiquedog 0:bf743d54917c 200 void Tela_1(){ // Função que define o funcionamento da tela 1
kaiquedog 0:bf743d54917c 201 wait(0.2);
kaiquedog 0:bf743d54917c 202 lcd.clc();
kaiquedog 4:a0a633b93fd0 203 Ze.Tempo = tempos[t]; // Define o tempo inicial
kaiquedog 4:a0a633b93fd0 204 Ze.Angulo = 0; // Reseta o ângulo ao entrar na tela
kaiquedog 4:a0a633b93fd0 205 Ze.Posicao = 0;
kaiquedog 4:a0a633b93fd0 206
kaiquedog 4:a0a633b93fd0 207 lcd.pos(1,1); lcd.printf("Vel %s", porcentagem[t]); // Insere a parte de velocidade no LCD
kaiquedog 4:a0a633b93fd0 208 lcd.pos(2,1); lcd.printf("Pos %.3f", Ze.Angulo);
kaiquedog 0:bf743d54917c 209
kaiquedog 0:bf743d54917c 210 while (t1 == 1){
kaiquedog 0:bf743d54917c 211 switch (Joy.ler_x()) // Lê o valor de VRX
kaiquedog 0:bf743d54917c 212 {
kaiquedog 4:a0a633b93fd0 213 case 0: Loop_Horario(); wait(0.2); break; // Se for > 800 Printa na tela um check da direção e gira o motor no sentido horário
kaiquedog 4:a0a633b93fd0 214 case 1: Loop_Anti_Horario(); wait(0.2); break; // Se for < 200 Printa na tela um check da direção e gira o motor no sentido horário
kaiquedog 0:bf743d54917c 215 }
kaiquedog 0:bf743d54917c 216 switch (Joy.ler_y()) // Lê o valor de VRY
kaiquedog 0:bf743d54917c 217 {
kaiquedog 0:bf743d54917c 218 case 0: Aumenta_Vel(); wait(0.2); break; // Se for > 800 Printa na tela o valor em % e aumenta a velocidade
kaiquedog 0:bf743d54917c 219 case 1: Diminui_Vel(); wait(0.2); break; // Se for < 200 Printa na tela o valor em % e Diminui a velocidade
kaiquedog 0:bf743d54917c 220 }
kaiquedog 0:bf743d54917c 221 switch (Joy.bot_select())
kaiquedog 0:bf743d54917c 222 {
kaiquedog 0:bf743d54917c 223 case 0: t1 = 2; break;
kaiquedog 0:bf743d54917c 224 }
kaiquedog 0:bf743d54917c 225 }
kaiquedog 0:bf743d54917c 226 }
kaiquedog 0:bf743d54917c 227
kaiquedog 0:bf743d54917c 228 void Tela_2(){ // Função que define o funcionamento da tela 2
kaiquedog 0:bf743d54917c 229 wait(0.2);
kaiquedog 0:bf743d54917c 230 lcd.clc();
kaiquedog 4:a0a633b93fd0 231 Ze.Tempo = tempos[0]; // Define o tempo inicial
kaiquedog 4:a0a633b93fd0 232 Ze.Angulo = 0; // Reseta o ângulo ao entrar na tela
kaiquedog 4:a0a633b93fd0 233 Ze.Posicao = 0;
kaiquedog 3:fcdbe4af1b6d 234 lcd.printf("Pos"); // Insere a parte de velocidade no LCD
kaiquedog 0:bf743d54917c 235 while (t2 == 1){
kaiquedog 3:fcdbe4af1b6d 236 switch (Joy.ler_x()) // Lê o valor de VRX
kaiquedog 0:bf743d54917c 237 {
kaiquedog 4:a0a633b93fd0 238 case 0: Ze.Full(); lcd.pos(1,5); lcd.printf("%.2f",Ze.Posicao); lcd.putc(0xE4); lcd.printf("m "); lcd.pos(2,5); lcd.printf("%.2f",Ze.Angulo); lcd.putc(0xDF); lcd.putc(0x10); break; // Se for > 800 Printa na tela um check da direção e gira o motor no sentido horário
kaiquedog 4:a0a633b93fd0 239 case 1: Ze.Full_(); lcd.pos(1,5); lcd.printf("%.2f",Ze.Posicao); lcd.putc(0xE4); lcd.printf("m "); lcd.pos(2,5); lcd.printf("%.2f",Ze.Angulo); lcd.putc(0xDF); lcd.putc(0x10); break; // Se for < 200 Printa na tela um check da direção e gira o motor no sentido horário
kaiquedog 0:bf743d54917c 240 }
kaiquedog 0:bf743d54917c 241 switch (Joy.ler_y()) // Lê o valor de VRY
kaiquedog 0:bf743d54917c 242 {
kaiquedog 3:fcdbe4af1b6d 243 case 0: wait(0.2); break;
kaiquedog 3:fcdbe4af1b6d 244 case 1: wait(0.2); break;
kaiquedog 0:bf743d54917c 245 }
kaiquedog 0:bf743d54917c 246 switch (Joy.bot_select())
kaiquedog 0:bf743d54917c 247 {
kaiquedog 0:bf743d54917c 248 case 0: t2 = 2; break;
kaiquedog 0:bf743d54917c 249 }
kaiquedog 4:a0a633b93fd0 250 Ze.mot = 0b0000;
kaiquedog 0:bf743d54917c 251 }
kaiquedog 0:bf743d54917c 252 }
kaiquedog 0:bf743d54917c 253
kaiquedog 0:bf743d54917c 254 void Tela_Instrucao(int a){ // Função que define o funcionamento da tela 1
kaiquedog 0:bf743d54917c 255 wait(0.2);
kaiquedog 0:bf743d54917c 256 lcd.clc();
kaiquedog 0:bf743d54917c 257 lcd.printf("Aperte o select para seguir");
kaiquedog 0:bf743d54917c 258 int ti = 1;
kaiquedog 0:bf743d54917c 259 while (ti == 1){
kaiquedog 0:bf743d54917c 260 switch (Joy.bot_select())
kaiquedog 0:bf743d54917c 261 {
kaiquedog 0:bf743d54917c 262 case 0: ti = 2; Tela_Instrucao_1(a); break;
kaiquedog 0:bf743d54917c 263 }
kaiquedog 0:bf743d54917c 264
kaiquedog 0:bf743d54917c 265 if (menu == 2){
kaiquedog 0:bf743d54917c 266 ti = 0;
kaiquedog 0:bf743d54917c 267 Loop_Menu();
kaiquedog 0:bf743d54917c 268 }
kaiquedog 0:bf743d54917c 269 }
kaiquedog 0:bf743d54917c 270 }
kaiquedog 0:bf743d54917c 271
kaiquedog 0:bf743d54917c 272
kaiquedog 0:bf743d54917c 273 void Tela_Instrucao_1(int a){ // Função que define o funcionamento da tela 1
kaiquedog 0:bf743d54917c 274 wait(0.2);
kaiquedog 0:bf743d54917c 275 lcd.clc();
kaiquedog 0:bf743d54917c 276 lcd.putc(0x03); lcd.printf("Gira "); lcd.putc(0x05); lcd.putc(0xFF); lcd.putc(0x04); lcd.printf("Gira "); lcd.putc(0x06); lcd.putc(0xFF);
kaiquedog 0:bf743d54917c 277 lcd.putc(0x7F); lcd.printf("Velo +"); lcd.putc(0xFF); lcd.putc(0x7E); lcd.printf("Velo -"); lcd.putc(0xFF);
kaiquedog 0:bf743d54917c 278 int ti1 = 1;
kaiquedog 0:bf743d54917c 279 t1 = 1;
kaiquedog 0:bf743d54917c 280 t2 = 1;
kaiquedog 0:bf743d54917c 281 while (ti1 == 1){
kaiquedog 0:bf743d54917c 282 switch (Joy.bot_select())
kaiquedog 0:bf743d54917c 283 {
kaiquedog 0:bf743d54917c 284 case 0: ti1 = 0;
kaiquedog 0:bf743d54917c 285 if (a == 1){
kaiquedog 0:bf743d54917c 286 Tela_1(); Loop_Menu();}
kaiquedog 0:bf743d54917c 287 if (a == 2){
kaiquedog 0:bf743d54917c 288 Tela_2(); Loop_Menu();}
kaiquedog 0:bf743d54917c 289 break;
kaiquedog 0:bf743d54917c 290 }
kaiquedog 0:bf743d54917c 291 if (menu == 2){
kaiquedog 0:bf743d54917c 292 ti1 = 0;
kaiquedog 0:bf743d54917c 293 Loop_Menu();
kaiquedog 0:bf743d54917c 294 }
kaiquedog 0:bf743d54917c 295 }
kaiquedog 0:bf743d54917c 296 }
kaiquedog 0:bf743d54917c 297
kaiquedog 0:bf743d54917c 298 void Emergencia(){
kaiquedog 0:bf743d54917c 299 Rele = 1;
kaiquedog 0:bf743d54917c 300 lcd.clc();
kaiquedog 0:bf743d54917c 301 lcd.printf("!!!Emergencia!!!!!!pressionado!!");
kaiquedog 0:bf743d54917c 302 while(mybutton == 1){
kaiquedog 0:bf743d54917c 303 wait(0.2);
kaiquedog 0:bf743d54917c 304 }
kaiquedog 0:bf743d54917c 305 Rele = 0;
kaiquedog 0:bf743d54917c 306 lcd.clc();
kaiquedog 0:bf743d54917c 307 t1 = 2;
kaiquedog 0:bf743d54917c 308 t2 = 2;
kaiquedog 0:bf743d54917c 309 menu = 2;
kaiquedog 0:bf743d54917c 310 }