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

Dependencies:   mbed

Committer:
rhisis
Date:
Wed Jun 10 12:47:58 2020 +0000
Revision:
8:5b030b6cb4cd
Parent:
7:c74ad3669dfa
Child:
9:891ffa97d8fb
GATE 2 CAICAO

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