Código para o menu no LCD
Dependencies: mbed SDFileSystemSD TextLCD
Fork of TextLCD_HelloWorld2 by
main.cpp@26:59081efdce79, 2018-05-16 (annotated)
- Committer:
- claraluques
- Date:
- Wed May 16 16:49:45 2018 +0000
- Revision:
- 26:59081efdce79
- Parent:
- 22:22ddb0b21d48
- Child:
- 27:83d2a710cc2f
jog funcionando, sem home ou exec (nao est? recebendo "a");
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" |
claraluques | 19:2c890ae2d187 | 5 | #include "string" |
claraluques | 11:6b7accf18fe2 | 6 | |
claraluques | 5:30f5ffe0ea0b | 7 | // Host PC Communication channels |
claraluques | 11:6b7accf18fe2 | 8 | Serial pc(USBTX, USBRX); // tx, rx //não apagar |
wim | 4:a3e4bb2053cb | 9 | |
claraluques | 5:30f5ffe0ea0b | 10 | //I2C Communication |
claraluques | 11:6b7accf18fe2 | 11 | I2C i2c_lcd(D14,D15); // SDA, SCL //não apagar |
claraluques | 5:30f5ffe0ea0b | 12 | |
claraluques | 5:30f5ffe0ea0b | 13 | //Botão push |
claraluques | 5:30f5ffe0ea0b | 14 | InterruptIn botao_enter(D13); |
claraluques | 5:30f5ffe0ea0b | 15 | InterruptIn botao_cima(D10); |
claraluques | 5:30f5ffe0ea0b | 16 | InterruptIn botao_baixo(D9); |
claraluques | 5:30f5ffe0ea0b | 17 | |
claraluques | 5:30f5ffe0ea0b | 18 | //LCD instantiation |
claraluques | 11:6b7accf18fe2 | 19 | TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); //não apagar |
claraluques | 5:30f5ffe0ea0b | 20 | |
claraluques | 5:30f5ffe0ea0b | 21 | //variáveis int |
claraluques | 5:30f5ffe0ea0b | 22 | int bot_enter; |
claraluques | 5:30f5ffe0ea0b | 23 | int bot_cima; |
claraluques | 5:30f5ffe0ea0b | 24 | int bot_baixo; |
claraluques | 6:24cbbdf2dac2 | 25 | int penter = 0; |
claraluques | 6:24cbbdf2dac2 | 26 | int pcima = 0; |
claraluques | 6:24cbbdf2dac2 | 27 | int pbaixo = 0; |
claraluques | 9:86b5a317fcd4 | 28 | int cola; |
claraluques | 9:86b5a317fcd4 | 29 | int exec; |
claraluques | 12:64ed645e79ad | 30 | int select = 0; |
claraluques | 26:59081efdce79 | 31 | int pontos = 0; |
claraluques | 26:59081efdce79 | 32 | int salvar = 0; |
claraluques | 26:59081efdce79 | 33 | int maxpontos = 5; |
claraluques | 26:59081efdce79 | 34 | int home; |
wim | 0:a75049de1a82 | 35 | |
claraluques | 5:30f5ffe0ea0b | 36 | //variáveis float |
claraluques | 7:e2c1b0338286 | 37 | float cx = 120.458; |
claraluques | 7:e2c1b0338286 | 38 | float cy = 457.854; |
claraluques | 7:e2c1b0338286 | 39 | float cz = 782.659; |
claraluques | 8:b80f50544ddd | 40 | float cx_salva; |
claraluques | 8:b80f50544ddd | 41 | float cy_salva; |
claraluques | 8:b80f50544ddd | 42 | float cz_salva; |
claraluques | 5:30f5ffe0ea0b | 43 | |
claraluques | 5:30f5ffe0ea0b | 44 | //funções interrupt |
claraluques | 5:30f5ffe0ea0b | 45 | void botenter_press(void); |
claraluques | 5:30f5ffe0ea0b | 46 | void botenter_solto(void); |
wim | 0:a75049de1a82 | 47 | |
claraluques | 5:30f5ffe0ea0b | 48 | void botcima_press(void); |
claraluques | 5:30f5ffe0ea0b | 49 | void botcima_solto(void); |
claraluques | 5:30f5ffe0ea0b | 50 | |
claraluques | 5:30f5ffe0ea0b | 51 | void botbaixo_press(void); |
claraluques | 5:30f5ffe0ea0b | 52 | void botbaixo_solto(void); |
claraluques | 5:30f5ffe0ea0b | 53 | |
claraluques | 19:2c890ae2d187 | 54 | #include "classes.h" |
claraluques | 19:2c890ae2d187 | 55 | |
claraluques | 9:86b5a317fcd4 | 56 | Menu::Menu(){ //não apagar |
claraluques | 12:64ed645e79ad | 57 | func = 0; |
claraluques | 9:86b5a317fcd4 | 58 | } |
wim | 3:f238b4f7874f | 59 | |
claraluques | 5:30f5ffe0ea0b | 60 | Menu menu; |
claraluques | 19:2c890ae2d187 | 61 | |
claraluques | 5:30f5ffe0ea0b | 62 | int main () { |
claraluques | 5:30f5ffe0ea0b | 63 | lcd.setBacklight(TextLCD::LightOn); //liga backlight |
claraluques | 9:86b5a317fcd4 | 64 | lcd.setCursor(TextLCD::CurOff_BlkOff); //define tipo de cursor |
claraluques | 5:30f5ffe0ea0b | 65 | |
claraluques | 9:86b5a317fcd4 | 66 | botao_enter.rise(&botenter_press); //chama função botao enter |
claraluques | 9:86b5a317fcd4 | 67 | botao_cima.rise(&botcima_press); //chama função botao para cima |
claraluques | 9:86b5a317fcd4 | 68 | botao_baixo.rise(&botbaixo_press); //chama função bota para baixo |
claraluques | 6:24cbbdf2dac2 | 69 | |
claraluques | 5:30f5ffe0ea0b | 70 | while(1){ |
claraluques | 9:86b5a317fcd4 | 71 | switch(menu.func){ //faz com que as telas sejam iniciadas |
claraluques | 5:30f5ffe0ea0b | 72 | case 0: menu.inicializar(); break; |
claraluques | 5:30f5ffe0ea0b | 73 | case 1: menu.menuprincipal(); break; |
claraluques | 6:24cbbdf2dac2 | 74 | case 2: menu.jog(); break; |
claraluques | 12:64ed645e79ad | 75 | case 3: menu.automatico(); break; |
claraluques | 13:1670c34440a5 | 76 | case 4: menu.config(); break; |
claraluques | 9:86b5a317fcd4 | 77 | case 5: menu.telasalvamento(); break; |
claraluques | 9:86b5a317fcd4 | 78 | case 6: menu.telacola(); break; |
claraluques | 9:86b5a317fcd4 | 79 | case 7: menu.executarprograma(); break; |
claraluques | 9:86b5a317fcd4 | 80 | case 8: menu.telazerar(); break; |
claraluques | 9:86b5a317fcd4 | 81 | case 9: menu.executando(); break; |
claraluques | 9:86b5a317fcd4 | 82 | case 10: menu.zerado(); break; |
claraluques | 9:86b5a317fcd4 | 83 | case 11: menu.finalizado(); break; |
claraluques | 26:59081efdce79 | 84 | //case 15: menu.gohome(); break; |
claraluques | 13:1670c34440a5 | 85 | case 16: menu.limitepontos(); break; |
claraluques | 26:59081efdce79 | 86 | case 17: menu.salvarprog(); break; |
claraluques | 5:30f5ffe0ea0b | 87 | } |
claraluques | 5:30f5ffe0ea0b | 88 | } |
claraluques | 11:6b7accf18fe2 | 89 | } |
claraluques | 5:30f5ffe0ea0b | 90 | |
claraluques | 11:6b7accf18fe2 | 91 | //função interrupt botão enter |
claraluques | 11:6b7accf18fe2 | 92 | void botenter_press(void){ |
claraluques | 11:6b7accf18fe2 | 93 | penter = bot_enter; |
claraluques | 11:6b7accf18fe2 | 94 | bot_enter = !bot_enter; |
claraluques | 20:ccbd80b668ce | 95 | //printf("enter high"); |
claraluques | 11:6b7accf18fe2 | 96 | } |
claraluques | 9:86b5a317fcd4 | 97 | |
claraluques | 11:6b7accf18fe2 | 98 | //função interrupt botão cima |
claraluques | 11:6b7accf18fe2 | 99 | void botcima_press(void){ |
claraluques | 11:6b7accf18fe2 | 100 | pcima = bot_cima; |
claraluques | 11:6b7accf18fe2 | 101 | bot_cima = !bot_cima; |
claraluques | 20:ccbd80b668ce | 102 | //printf("cima high"); |
claraluques | 11:6b7accf18fe2 | 103 | } |
wim | 0:a75049de1a82 | 104 | |
claraluques | 5:30f5ffe0ea0b | 105 | //função interrupt botão baixo |
claraluques | 11:6b7accf18fe2 | 106 | void botbaixo_press(void){ |
claraluques | 11:6b7accf18fe2 | 107 | pbaixo = bot_baixo; |
claraluques | 11:6b7accf18fe2 | 108 | bot_baixo = !bot_baixo; |
claraluques | 20:ccbd80b668ce | 109 | //printf("baixo high"); |
claraluques | 21:7603fe283ba4 | 110 | } |