Código para o menu no LCD
Dependencies: mbed SDFileSystemSD TextLCD
Fork of TextLCD_HelloWorld2 by
main.cpp@42:48096cfdea78, 2018-06-10 (annotated)
- Committer:
- lucasfontenla
- Date:
- Sun Jun 10 21:52:12 2018 +0000
- Revision:
- 42:48096cfdea78
- Parent:
- 41:a1ab19cc1387
- Child:
- 43:4684aba69ba6
Tudo funcionando. Falra somente adicionar o "cancelar" no modo wifi
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
claraluques | 11:6b7accf18fe2 | 1 | /*CÓDIGO PARA LCD MENU HELLEN - GRUPO T*/ |
claraluques | 11:6b7accf18fe2 | 2 | |
wim | 0:a75049de1a82 | 3 | #include "mbed.h" |
wim | 0:a75049de1a82 | 4 | #include "TextLCD.h" |
lucasfontenla | 28:b3c51076ebe8 | 5 | #include "SDFileSystem.h" |
claraluques | 19:2c890ae2d187 | 6 | #include "string" |
lucasfontenla | 29:558eccdfc079 | 7 | #include "vector" |
claraluques | 11:6b7accf18fe2 | 8 | |
claraluques | 32:c293f89170b0 | 9 | Timer timer; |
claraluques | 33:0149960e95c1 | 10 | Timer timer2; |
claraluques | 34:7c7fac39a250 | 11 | Timer enter_debounce_timer; |
claraluques | 34:7c7fac39a250 | 12 | Timer cima_debounce_timer; |
claraluques | 34:7c7fac39a250 | 13 | Timer baixo_debounce_timer; |
claraluques | 36:12d202855231 | 14 | Timer tpontinhos; |
lucasfontenla | 41:a1ab19cc1387 | 15 | Timer wifi_serial; |
lucasfontenla | 42:48096cfdea78 | 16 | Timer clean_wifi; |
wim | 4:a3e4bb2053cb | 17 | |
claraluques | 5:30f5ffe0ea0b | 18 | //I2C Communication |
claraluques | 11:6b7accf18fe2 | 19 | I2C i2c_lcd(D14,D15); // SDA, SCL //não apagar |
claraluques | 5:30f5ffe0ea0b | 20 | |
claraluques | 5:30f5ffe0ea0b | 21 | //Botão push |
lucasfontenla | 39:fbad08986621 | 22 | InterruptIn botao_enter(D12); |
lucasfontenla | 40:e70f811c69dc | 23 | InterruptIn botao_cima(D9); |
lucasfontenla | 39:fbad08986621 | 24 | InterruptIn botao_baixo(D13); |
claraluques | 5:30f5ffe0ea0b | 25 | |
lucasfontenla | 40:e70f811c69dc | 26 | InterruptIn emergencia(D3); |
lucasfontenla | 40:e70f811c69dc | 27 | |
claraluques | 5:30f5ffe0ea0b | 28 | //LCD instantiation |
claraluques | 11:6b7accf18fe2 | 29 | TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); //não apagar |
claraluques | 5:30f5ffe0ea0b | 30 | |
claraluques | 5:30f5ffe0ea0b | 31 | //variáveis int |
claraluques | 31:77eb51d4ee18 | 32 | int bot_enter = 0; |
claraluques | 31:77eb51d4ee18 | 33 | int bot_cima = 0; |
claraluques | 31:77eb51d4ee18 | 34 | int bot_baixo = 0; |
claraluques | 31:77eb51d4ee18 | 35 | int penter = 1; |
claraluques | 31:77eb51d4ee18 | 36 | int pcima = 1; |
claraluques | 31:77eb51d4ee18 | 37 | int pbaixo = 1; |
claraluques | 9:86b5a317fcd4 | 38 | int cola; |
claraluques | 9:86b5a317fcd4 | 39 | int exec; |
claraluques | 12:64ed645e79ad | 40 | int select = 0; |
claraluques | 26:59081efdce79 | 41 | int pontos = 0; |
claraluques | 26:59081efdce79 | 42 | int salvar = 0; |
claraluques | 35:11e3f3c8cb4e | 43 | int maxpontos = 100; |
claraluques | 26:59081efdce79 | 44 | int home; |
claraluques | 32:c293f89170b0 | 45 | int coluna = 1; |
claraluques | 32:c293f89170b0 | 46 | int contador = 0; |
claraluques | 32:c293f89170b0 | 47 | int sair = 0; |
claraluques | 33:0149960e95c1 | 48 | int voltar = 0; |
claraluques | 33:0149960e95c1 | 49 | int quebrar = 0; |
claraluques | 35:11e3f3c8cb4e | 50 | int f = 0; |
claraluques | 36:12d202855231 | 51 | int limpar_cola = 0; |
wim | 0:a75049de1a82 | 52 | |
lucasfontenla | 41:a1ab19cc1387 | 53 | int jog_working = 0; |
lucasfontenla | 41:a1ab19cc1387 | 54 | int emerg = 0; |
lucasfontenla | 41:a1ab19cc1387 | 55 | |
claraluques | 5:30f5ffe0ea0b | 56 | //variáveis float |
claraluques | 33:0149960e95c1 | 57 | float cx = 120.45; |
claraluques | 33:0149960e95c1 | 58 | float cy = 457.85; |
claraluques | 33:0149960e95c1 | 59 | float cz = 782.65; |
claraluques | 8:b80f50544ddd | 60 | float cx_salva; |
claraluques | 8:b80f50544ddd | 61 | float cy_salva; |
claraluques | 8:b80f50544ddd | 62 | float cz_salva; |
claraluques | 5:30f5ffe0ea0b | 63 | |
claraluques | 5:30f5ffe0ea0b | 64 | //funções interrupt |
claraluques | 5:30f5ffe0ea0b | 65 | void botenter_press(void); |
claraluques | 32:c293f89170b0 | 66 | void botcima_press(void); |
claraluques | 32:c293f89170b0 | 67 | void botbaixo_press(void); |
claraluques | 32:c293f89170b0 | 68 | void botenter_release(void); |
claraluques | 33:0149960e95c1 | 69 | void botcima_release(void); |
lucasfontenla | 40:e70f811c69dc | 70 | void emergencia_press(void); |
lucasfontenla | 40:e70f811c69dc | 71 | void emergencia_release(void); |
lucasfontenla | 40:e70f811c69dc | 72 | void wifiRx(void); |
wim | 0:a75049de1a82 | 73 | |
claraluques | 5:30f5ffe0ea0b | 74 | |
claraluques | 19:2c890ae2d187 | 75 | #include "classes.h" |
claraluques | 19:2c890ae2d187 | 76 | |
claraluques | 9:86b5a317fcd4 | 77 | Menu::Menu(){ //não apagar |
claraluques | 12:64ed645e79ad | 78 | func = 0; |
claraluques | 9:86b5a317fcd4 | 79 | } |
wim | 3:f238b4f7874f | 80 | |
claraluques | 5:30f5ffe0ea0b | 81 | Menu menu; |
claraluques | 19:2c890ae2d187 | 82 | |
claraluques | 5:30f5ffe0ea0b | 83 | int main () { |
lucasfontenla | 40:e70f811c69dc | 84 | printf("Starting...\n\r"); |
claraluques | 5:30f5ffe0ea0b | 85 | lcd.setBacklight(TextLCD::LightOn); //liga backlight |
claraluques | 9:86b5a317fcd4 | 86 | lcd.setCursor(TextLCD::CurOff_BlkOff); //define tipo de cursor |
lucasfontenla | 41:a1ab19cc1387 | 87 | |
claraluques | 31:77eb51d4ee18 | 88 | botao_enter.fall(&botenter_press); //chama função botao enter |
claraluques | 31:77eb51d4ee18 | 89 | botao_cima.fall(&botcima_press); //chama função botao para cima |
claraluques | 31:77eb51d4ee18 | 90 | botao_baixo.fall(&botbaixo_press); //chama função bota para baixo |
lucasfontenla | 39:fbad08986621 | 91 | |
claraluques | 32:c293f89170b0 | 92 | botao_enter.rise(&botenter_release); //chama função ler timer |
claraluques | 33:0149960e95c1 | 93 | botao_cima.rise(&botcima_release); |
claraluques | 32:c293f89170b0 | 94 | |
claraluques | 34:7c7fac39a250 | 95 | enter_debounce_timer.start(); // não apagar |
claraluques | 34:7c7fac39a250 | 96 | cima_debounce_timer.start(); |
claraluques | 34:7c7fac39a250 | 97 | baixo_debounce_timer.start(); |
claraluques | 6:24cbbdf2dac2 | 98 | |
lucasfontenla | 40:e70f811c69dc | 99 | emergencia.fall(&emergencia_press); |
lucasfontenla | 40:e70f811c69dc | 100 | emergencia.rise(&emergencia_release); |
lucasfontenla | 40:e70f811c69dc | 101 | |
lucasfontenla | 40:e70f811c69dc | 102 | if(!emergencia.read()){ |
lucasfontenla | 40:e70f811c69dc | 103 | printf("EMERGENCIA PRESSIONADO\n\r"); |
lucasfontenla | 40:e70f811c69dc | 104 | menu.tela_emergencia(); |
lucasfontenla | 40:e70f811c69dc | 105 | while(!emergencia.read()); |
lucasfontenla | 40:e70f811c69dc | 106 | printf("OK\n\r"); |
lucasfontenla | 40:e70f811c69dc | 107 | } |
lucasfontenla | 40:e70f811c69dc | 108 | |
lucasfontenla | 40:e70f811c69dc | 109 | while(1){ |
claraluques | 9:86b5a317fcd4 | 110 | switch(menu.func){ //faz com que as telas sejam iniciadas |
claraluques | 5:30f5ffe0ea0b | 111 | case 0: menu.inicializar(); break; |
claraluques | 5:30f5ffe0ea0b | 112 | case 1: menu.menuprincipal(); break; |
claraluques | 6:24cbbdf2dac2 | 113 | case 2: menu.jog(); break; |
claraluques | 12:64ed645e79ad | 114 | case 3: menu.automatico(); break; |
claraluques | 13:1670c34440a5 | 115 | case 4: menu.config(); break; |
claraluques | 9:86b5a317fcd4 | 116 | case 5: menu.telasalvamento(); break; |
claraluques | 9:86b5a317fcd4 | 117 | case 6: menu.telacola(); break; |
claraluques | 9:86b5a317fcd4 | 118 | case 7: menu.executarprograma(); break; |
claraluques | 9:86b5a317fcd4 | 119 | case 8: menu.telazerar(); break; |
claraluques | 9:86b5a317fcd4 | 120 | case 9: menu.executando(); break; |
claraluques | 9:86b5a317fcd4 | 121 | case 10: menu.zerado(); break; |
claraluques | 9:86b5a317fcd4 | 122 | case 11: menu.finalizado(); break; |
claraluques | 36:12d202855231 | 123 | case 12: menu.limpeza_livre(); break; |
lucasfontenla | 42:48096cfdea78 | 124 | case 13: menu.wifi(); break; |
claraluques | 36:12d202855231 | 125 | case 14: menu.limparcola(); break; |
claraluques | 27:83d2a710cc2f | 126 | case 15: menu.gohome(); break; |
claraluques | 13:1670c34440a5 | 127 | case 16: menu.limitepontos(); break; |
claraluques | 26:59081efdce79 | 128 | case 17: menu.salvarprog(); break; |
claraluques | 27:83d2a710cc2f | 129 | case 18: menu.ctzhome(); break; |
claraluques | 27:83d2a710cc2f | 130 | case 19: menu.origem(); break; |
claraluques | 30:614dcbd74cdc | 131 | case 20: menu.nomeprog(); break; |
claraluques | 32:c293f89170b0 | 132 | case 21: menu.mudar_nome(); break; |
claraluques | 33:0149960e95c1 | 133 | case 22: menu.salva2(); break; |
claraluques | 35:11e3f3c8cb4e | 134 | case 23: menu.deletepoint(); break; |
claraluques | 35:11e3f3c8cb4e | 135 | case 24: menu.sempontos(); break; |
claraluques | 36:12d202855231 | 136 | case 25: menu.salvando_arq(); break; |
claraluques | 36:12d202855231 | 137 | case 26: menu.exec_auto(); break; |
claraluques | 36:12d202855231 | 138 | case 27: menu.indo_limpeza(); break; |
claraluques | 36:12d202855231 | 139 | case 28: menu.chegou_limpeza(); break; |
claraluques | 36:12d202855231 | 140 | case 29: menu.limpando(); break; |
claraluques | 36:12d202855231 | 141 | case 30: menu.limpeza_completa(); break; |
lucasfontenla | 41:a1ab19cc1387 | 142 | case 31: menu.tela_emergencia(); break; |
lucasfontenla | 40:e70f811c69dc | 143 | } |
lucasfontenla | 40:e70f811c69dc | 144 | } |
lucasfontenla | 40:e70f811c69dc | 145 | } |
claraluques | 5:30f5ffe0ea0b | 146 | |
claraluques | 11:6b7accf18fe2 | 147 | //função interrupt botão enter |
claraluques | 34:7c7fac39a250 | 148 | void botenter_press(void){ |
claraluques | 34:7c7fac39a250 | 149 | printf("ENTER!\n\r"); |
claraluques | 35:11e3f3c8cb4e | 150 | //printf("timer: %.3f\n\r", enter_debounce_timer.read()); |
claraluques | 34:7c7fac39a250 | 151 | if(enter_debounce_timer.read()>0.2){ |
claraluques | 34:7c7fac39a250 | 152 | penter = bot_enter; |
claraluques | 34:7c7fac39a250 | 153 | bot_enter = !bot_enter; |
claraluques | 35:11e3f3c8cb4e | 154 | //printf("enter high, timer reset FALL\n\r"); |
claraluques | 34:7c7fac39a250 | 155 | timer.reset(); |
claraluques | 34:7c7fac39a250 | 156 | timer.start(); |
claraluques | 34:7c7fac39a250 | 157 | enter_debounce_timer.reset(); |
claraluques | 34:7c7fac39a250 | 158 | enter_debounce_timer.start(); |
claraluques | 34:7c7fac39a250 | 159 | } |
claraluques | 34:7c7fac39a250 | 160 | } |
claraluques | 9:86b5a317fcd4 | 161 | |
claraluques | 11:6b7accf18fe2 | 162 | //função interrupt botão cima |
claraluques | 11:6b7accf18fe2 | 163 | void botcima_press(void){ |
claraluques | 34:7c7fac39a250 | 164 | printf("CIMA!\n\r"); |
lucasfontenla | 39:fbad08986621 | 165 | printf("timer: %.3f\n\r", cima_debounce_timer.read()); |
lucasfontenla | 39:fbad08986621 | 166 | printf("timer: %.3f\n\r", baixo_debounce_timer.read()); |
claraluques | 34:7c7fac39a250 | 167 | if(cima_debounce_timer.read()>0.2){ |
claraluques | 34:7c7fac39a250 | 168 | pcima = bot_cima; |
claraluques | 34:7c7fac39a250 | 169 | bot_cima = !bot_cima; |
claraluques | 34:7c7fac39a250 | 170 | timer2.reset(); |
claraluques | 34:7c7fac39a250 | 171 | timer2.start(); |
claraluques | 34:7c7fac39a250 | 172 | cima_debounce_timer.reset(); |
claraluques | 34:7c7fac39a250 | 173 | cima_debounce_timer.start(); |
claraluques | 34:7c7fac39a250 | 174 | } |
claraluques | 34:7c7fac39a250 | 175 | } |
wim | 0:a75049de1a82 | 176 | |
claraluques | 5:30f5ffe0ea0b | 177 | //função interrupt botão baixo |
claraluques | 11:6b7accf18fe2 | 178 | void botbaixo_press(void){ |
claraluques | 34:7c7fac39a250 | 179 | printf("BAIXO!\n\r"); |
claraluques | 35:11e3f3c8cb4e | 180 | //printf("timer: %.3f\n\r", baixo_debounce_timer.read()); |
claraluques | 34:7c7fac39a250 | 181 | if(baixo_debounce_timer.read()>0.2){ |
claraluques | 34:7c7fac39a250 | 182 | pbaixo = bot_baixo; |
claraluques | 34:7c7fac39a250 | 183 | bot_baixo = !bot_baixo; |
claraluques | 34:7c7fac39a250 | 184 | baixo_debounce_timer.reset(); |
claraluques | 34:7c7fac39a250 | 185 | baixo_debounce_timer.start(); |
claraluques | 34:7c7fac39a250 | 186 | } |
claraluques | 34:7c7fac39a250 | 187 | } |
claraluques | 34:7c7fac39a250 | 188 | |
claraluques | 32:c293f89170b0 | 189 | //função para ler o timer |
claraluques | 32:c293f89170b0 | 190 | void botenter_release(void){ |
claraluques | 32:c293f89170b0 | 191 | timer.stop(); |
claraluques | 33:0149960e95c1 | 192 | quebrar = 1; |
claraluques | 33:0149960e95c1 | 193 | } |
claraluques | 33:0149960e95c1 | 194 | |
claraluques | 33:0149960e95c1 | 195 | |
claraluques | 33:0149960e95c1 | 196 | //função para ler o timer 2 |
claraluques | 33:0149960e95c1 | 197 | void botcima_release(void){ |
claraluques | 33:0149960e95c1 | 198 | timer2.stop(); |
claraluques | 34:7c7fac39a250 | 199 | //printf("%f,%d, timer 2 RISE\n\r", t2, voltar); |
lucasfontenla | 40:e70f811c69dc | 200 | } |
lucasfontenla | 40:e70f811c69dc | 201 | |
lucasfontenla | 41:a1ab19cc1387 | 202 | void wifiRx(void){ |
lucasfontenla | 42:48096cfdea78 | 203 | clean_wifi.reset(); |
lucasfontenla | 42:48096cfdea78 | 204 | clean_wifi.start(); |
lucasfontenla | 42:48096cfdea78 | 205 | printf("FUNC WIFI!\n\r"); |
lucasfontenla | 41:a1ab19cc1387 | 206 | wifi_serial.reset(); |
lucasfontenla | 41:a1ab19cc1387 | 207 | float timeout_time = 2.0; |
lucasfontenla | 41:a1ab19cc1387 | 208 | |
lucasfontenla | 41:a1ab19cc1387 | 209 | char recv; |
lucasfontenla | 41:a1ab19cc1387 | 210 | string buffer; |
lucasfontenla | 41:a1ab19cc1387 | 211 | |
lucasfontenla | 41:a1ab19cc1387 | 212 | int glue = 0; |
lucasfontenla | 41:a1ab19cc1387 | 213 | int jog_mode = 0; |
lucasfontenla | 42:48096cfdea78 | 214 | int kill_jog_mode = 0; |
lucasfontenla | 41:a1ab19cc1387 | 215 | int move_mode = 0; |
lucasfontenla | 41:a1ab19cc1387 | 216 | int zero_mode = 0; |
lucasfontenla | 41:a1ab19cc1387 | 217 | int machine_zero_mode = 0; |
lucasfontenla | 41:a1ab19cc1387 | 218 | int upload_code = 0; |
lucasfontenla | 41:a1ab19cc1387 | 219 | int start_mode = 0; |
lucasfontenla | 42:48096cfdea78 | 220 | wifi_serial.start(); |
lucasfontenla | 42:48096cfdea78 | 221 | |
lucasfontenla | 42:48096cfdea78 | 222 | while(1){ |
lucasfontenla | 42:48096cfdea78 | 223 | recv = WiFi.getc(); |
lucasfontenla | 42:48096cfdea78 | 224 | printf("Recv: %c\n\r", recv); |
lucasfontenla | 42:48096cfdea78 | 225 | |
lucasfontenla | 42:48096cfdea78 | 226 | if(wifi_serial.read() > timeout_time){ |
lucasfontenla | 42:48096cfdea78 | 227 | wifi_serial.stop(); |
lucasfontenla | 42:48096cfdea78 | 228 | printf("Serial timeout"); |
lucasfontenla | 42:48096cfdea78 | 229 | break; |
lucasfontenla | 42:48096cfdea78 | 230 | } |
lucasfontenla | 41:a1ab19cc1387 | 231 | |
lucasfontenla | 42:48096cfdea78 | 232 | if(recv == 'x'){ |
lucasfontenla | 42:48096cfdea78 | 233 | printf("Jog: %d, Kill Jog: %d, Glue: %d, Move: %d, Start: %d\n\r", jog_mode, kill_jog_mode, glue, move_mode, start_mode); |
lucasfontenla | 42:48096cfdea78 | 234 | if(glue){ |
lucasfontenla | 42:48096cfdea78 | 235 | machine.clean_glue(); |
lucasfontenla | 42:48096cfdea78 | 236 | lcd.locate(0,1); |
lucasfontenla | 42:48096cfdea78 | 237 | lcd.printf("Modo cola "); |
lucasfontenla | 42:48096cfdea78 | 238 | } else if(jog_mode){ |
lucasfontenla | 42:48096cfdea78 | 239 | if(kill_jog_mode){ |
lucasfontenla | 42:48096cfdea78 | 240 | machine.kill_jog(); |
lucasfontenla | 42:48096cfdea78 | 241 | lcd.locate(0,1); |
lucasfontenla | 42:48096cfdea78 | 242 | lcd.printf("Modo desabilitar JOG"); |
lucasfontenla | 42:48096cfdea78 | 243 | } else { |
lucasfontenla | 42:48096cfdea78 | 244 | machine.jog(); |
lucasfontenla | 42:48096cfdea78 | 245 | lcd.locate(0,1); |
lucasfontenla | 42:48096cfdea78 | 246 | lcd.printf("Habilitar JOG "); |
lucasfontenla | 41:a1ab19cc1387 | 247 | } |
lucasfontenla | 42:48096cfdea78 | 248 | } else if(move_mode){ |
lucasfontenla | 42:48096cfdea78 | 249 | machine.move(buffer); |
lucasfontenla | 42:48096cfdea78 | 250 | machine.start_program(); |
lucasfontenla | 42:48096cfdea78 | 251 | lcd.locate(0,1); |
lucasfontenla | 42:48096cfdea78 | 252 | lcd.printf("Modo mover "); |
lucasfontenla | 42:48096cfdea78 | 253 | } else if(zero_mode){ |
lucasfontenla | 42:48096cfdea78 | 254 | if(machine_zero_mode){ |
lucasfontenla | 42:48096cfdea78 | 255 | machine.machine_zero(); |
lucasfontenla | 42:48096cfdea78 | 256 | lcd.locate(0,1); |
lucasfontenla | 42:48096cfdea78 | 257 | lcd.printf("Zerar máquina "); |
lucasfontenla | 42:48096cfdea78 | 258 | } |
lucasfontenla | 42:48096cfdea78 | 259 | } else if(start_mode){ |
lucasfontenla | 42:48096cfdea78 | 260 | machine.start_program(); |
lucasfontenla | 42:48096cfdea78 | 261 | } else if(upload_code){ |
lucasfontenla | 42:48096cfdea78 | 262 | machine.move(buffer); |
lucasfontenla | 42:48096cfdea78 | 263 | lcd.locate(0,1); |
lucasfontenla | 42:48096cfdea78 | 264 | lcd.printf("Modo carregar codigo"); |
lucasfontenla | 41:a1ab19cc1387 | 265 | } |
lucasfontenla | 42:48096cfdea78 | 266 | return; |
lucasfontenla | 42:48096cfdea78 | 267 | } |
lucasfontenla | 42:48096cfdea78 | 268 | |
lucasfontenla | 42:48096cfdea78 | 269 | if(recv == 'g'){ |
lucasfontenla | 42:48096cfdea78 | 270 | glue = 1; |
lucasfontenla | 42:48096cfdea78 | 271 | } |
lucasfontenla | 42:48096cfdea78 | 272 | |
lucasfontenla | 42:48096cfdea78 | 273 | if(recv == 'b'){ |
lucasfontenla | 42:48096cfdea78 | 274 | start_mode = 1; |
lucasfontenla | 42:48096cfdea78 | 275 | } |
lucasfontenla | 42:48096cfdea78 | 276 | |
lucasfontenla | 42:48096cfdea78 | 277 | if(recv == 'j'){ |
lucasfontenla | 42:48096cfdea78 | 278 | jog_mode = 1; |
lucasfontenla | 42:48096cfdea78 | 279 | } |
lucasfontenla | 42:48096cfdea78 | 280 | |
lucasfontenla | 42:48096cfdea78 | 281 | if(recv == 'k' && jog_mode){ |
lucasfontenla | 42:48096cfdea78 | 282 | kill_jog_mode = 1; |
lucasfontenla | 42:48096cfdea78 | 283 | } |
lucasfontenla | 42:48096cfdea78 | 284 | |
lucasfontenla | 42:48096cfdea78 | 285 | if(recv == 'z'){ |
lucasfontenla | 42:48096cfdea78 | 286 | zero_mode = 1; |
lucasfontenla | 42:48096cfdea78 | 287 | } |
lucasfontenla | 42:48096cfdea78 | 288 | |
lucasfontenla | 42:48096cfdea78 | 289 | if(recv == 'm' && zero_mode){ |
lucasfontenla | 42:48096cfdea78 | 290 | machine_zero_mode = 1; |
lucasfontenla | 42:48096cfdea78 | 291 | } |
lucasfontenla | 42:48096cfdea78 | 292 | |
lucasfontenla | 42:48096cfdea78 | 293 | if(recv == 'm' && !zero_mode){ |
lucasfontenla | 42:48096cfdea78 | 294 | printf("MOVE!\n\r"); |
lucasfontenla | 42:48096cfdea78 | 295 | buffer = "u"; |
lucasfontenla | 42:48096cfdea78 | 296 | move_mode = 1; |
lucasfontenla | 42:48096cfdea78 | 297 | } |
lucasfontenla | 42:48096cfdea78 | 298 | |
lucasfontenla | 42:48096cfdea78 | 299 | if(recv == 'u'){ |
lucasfontenla | 42:48096cfdea78 | 300 | buffer = "u"; |
lucasfontenla | 42:48096cfdea78 | 301 | timeout_time = 10.0; |
lucasfontenla | 42:48096cfdea78 | 302 | upload_code = 1; |
lucasfontenla | 42:48096cfdea78 | 303 | } |
lucasfontenla | 42:48096cfdea78 | 304 | |
lucasfontenla | 42:48096cfdea78 | 305 | if(move_mode && recv != 'm'){ |
lucasfontenla | 42:48096cfdea78 | 306 | buffer.push_back(recv); |
lucasfontenla | 42:48096cfdea78 | 307 | } |
lucasfontenla | 42:48096cfdea78 | 308 | |
lucasfontenla | 42:48096cfdea78 | 309 | if(upload_code && recv != 'u'){ |
lucasfontenla | 42:48096cfdea78 | 310 | buffer.push_back(recv); |
lucasfontenla | 42:48096cfdea78 | 311 | } |
lucasfontenla | 42:48096cfdea78 | 312 | } |
lucasfontenla | 41:a1ab19cc1387 | 313 | } |
lucasfontenla | 40:e70f811c69dc | 314 | |
lucasfontenla | 40:e70f811c69dc | 315 | void emergencia_press(void){ |
lucasfontenla | 40:e70f811c69dc | 316 | printf("Emerg Press\n\r"); |
lucasfontenla | 41:a1ab19cc1387 | 317 | emerg = 1; |
lucasfontenla | 40:e70f811c69dc | 318 | } |
lucasfontenla | 40:e70f811c69dc | 319 | |
lucasfontenla | 40:e70f811c69dc | 320 | void emergencia_release(void){ |
lucasfontenla | 40:e70f811c69dc | 321 | printf("Emerg Release\n\r"); |
lucasfontenla | 41:a1ab19cc1387 | 322 | emerg = 0; |
lucasfontenla | 40:e70f811c69dc | 323 | } |