
Código para o menu no LCD
Dependencies: mbed SDFileSystemSD TextLCD
Fork of TextLCD_HelloWorld2 by
Revision 11:6b7accf18fe2, committed 2018-05-11
- Comitter:
- claraluques
- Date:
- Fri May 11 13:08:29 2018 +0000
- Parent:
- 10:97002056ecda
- Child:
- 12:64ed645e79ad
- Commit message:
- tentando compartilhar no resposit?rio
Changed in this revision
TextLCD.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/TextLCD.lib Fri May 11 12:46:56 2018 +0000 +++ b/TextLCD.lib Fri May 11 13:08:29 2018 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/wim/code/TextLCD/#4e70a08e8869 +https://os.mbed.com/teams/Grupo-T/code/TextLCD/#4e70a08e8869
--- a/main.cpp Fri May 11 12:46:56 2018 +0000 +++ b/main.cpp Fri May 11 13:08:29 2018 +0000 @@ -1,95 +1,13 @@ +/*CÓDIGO PARA LCD MENU HELLEN - GRUPO T*/ + #include "mbed.h" #include "TextLCD.h" - /* + // Host PC Communication channels -Serial pc(USBTX, USBRX); // tx, rx +Serial pc(USBTX, USBRX); // tx, rx //não apagar //I2C Communication -I2C i2c_lcd(D14,D15); // SDA, SCL - -//Botão push -InterruptIn botao(D7); - -//LCD instantiation -TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); // I2C exp: I2C bus, PCF8574 Slaveaddress, LCD Type - -//variáveis int -int colunas = lcd.columns(); -int linhas = lcd.rows(); -int c1 = 510000000; -int pontosl = 10; -int botpres; - -//variáveis float -float coordx = 123; -float coardy = 456; -float coardz = 789; - -//funções -void botao_press(void); -void botao_solto(void); - -int main() { - lcd.setBacklight(TextLCD::LightOn); //liga backlight - lcd.cls(); - lcd.printf("Certifique-se de que voce esta seguro para comecar"); - - botao.rise(&botao_press); - botao.fall(&botao_solto); - wait(2); - - while(1){ - while(1) { - - - if (c1>500000000) { - lcd.cls(); - lcd.printf("FUNCAO JOG"); - lcd.locate(0,1); - //lcd.printf("X: %.1f Y: %d.1 Z: %d.1", coordx, coordy, coordz); - lcd.locate(0,2); - lcd.printf("Aperte > ok p/ salvar o ponto %c", 0x3E); - //wait(0.5) - //lcd.printf("Aperte ok p/ salvar o ponto %c", 0xff); - InterruptIn botao(D7); - c1 = 0; - } - - c1++; - - if(botpres) { //se pressionado, aparece a tela de ponto salvo com contagem de pontos restantes - lcd.cls(); - lcd.locate(0,0); - lcd.printf("Voce salvou um ponto"); - lcd.locate(0,2); - pontosl--; - lcd.printf("Pontos livres: %d",pontosl); - wait(2); - c1=510000000; - break; - } - } - } -} - -void botao_press(void){ - botpres = 1; - printf("pressionado\n\r"); - } -void botao_solto(void) { - botpres = 0; - printf("solto\n\r"); - } - */ - -//#include mbed.h -//#include "TextLCD.h" - -// Host PC Communication channels -Serial pc(USBTX, USBRX); // tx, rx - -//I2C Communication -I2C i2c_lcd(D14,D15); // SDA, SCL +I2C i2c_lcd(D14,D15); // SDA, SCL //não apagar //Botão push InterruptIn botao_enter(D13); @@ -97,11 +15,9 @@ InterruptIn botao_baixo(D9); //LCD instantiation -TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); // I2C exp: I2C bus, PCF8574 Slaveaddress, LCD Type +TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); //não apagar //variáveis int -//int max = 3; -//int min = 0; int bot_enter; int bot_cima; int bot_baixo; @@ -129,11 +45,10 @@ void botbaixo_press(void); void botbaixo_solto(void); -//criar classe "menu" (funções das telas) +//criar classe "menu" (funções para as telas) class Menu{ public: int linha; - //int coluna; int func; void movercursor(int min, int max, int col){ //função para mover cursor de seleção @@ -175,15 +90,8 @@ } bot_baixo = 0; } - //lcd.locate(col, linha); - //lcd.printf("%c", 0x3E); - //printf("%d \n\r",linha); - //printf("%d %d %d \n\r", bot_enter, bot_cima, bot_baixo); - //wait_ms(500); - } - //printf("%d \n\r",linha); + } } - //func 0 void inicializar(){ //função tela incial de boas-vindas @@ -225,7 +133,6 @@ } } - //func 2 void jog(){ //função tela jog bot_enter = 0; @@ -259,7 +166,6 @@ func = 1; } } - } //func 3 @@ -308,7 +214,6 @@ } } } - //func 7 void executarprograma() { //tela para selecionar se deseja executar o programa @@ -363,7 +268,6 @@ } } - //func 9 void executando(){ //tela de executando lcd.cls(); @@ -427,17 +331,10 @@ lcd.setCursor(TextLCD::CurOff_BlkOff); //define tipo de cursor botao_enter.rise(&botenter_press); //chama função botao enter - //botao_enter.fall(&botenter_solto); - botao_cima.rise(&botcima_press); //chama função botao para cima - //botao_cima.fall(&botcima_solto); - botao_baixo.rise(&botbaixo_press); //chama função bota para baixo - //botao_baixo.fall(&botbaixo_solto); - while(1){ - //printf("%d %d %d \n\r", bot_enter, bot_cima, bot_baixo); switch(menu.func){ //faz com que as telas sejam iniciadas case 0: menu.inicializar(); break; case 1: menu.menuprincipal(); break; @@ -454,51 +351,25 @@ } } - } - - - + } - - -//função interrupt botão enter - -void botenter_press(void){ +//função interrupt botão enter + void botenter_press(void){ + penter = bot_enter; + bot_enter = !bot_enter; + printf("enter high"); + } - penter = bot_enter; - bot_enter = !bot_enter; - printf("enter high"); - } -/*void botenter_solto(void) { - penter = bot_enter; - bot_enter = !bot_enter; - printf("enter low"); - }*/ - -//função interrupt botão cima - -void botcima_press(void){ - pcima = bot_cima; - bot_cima = !bot_cima; - printf("cima high"); - } -/*void botcima_solto(void) { - pcima = bot_cima; - bot_cima = !bot_cima; - printf("cima low"); - }*/ +//função interrupt botão cima + void botcima_press(void){ + pcima = bot_cima; + bot_cima = !bot_cima; + printf("cima high"); + } //função interrupt botão baixo - -void botbaixo_press(void){ - pbaixo = bot_baixo; - bot_baixo = !bot_baixo; - printf("baixo high"); - } -/*void botbaixo_solto(void) { - pbaixo = bot_baixo; - bot_baixo = !bot_baixo; - printf("baixo low"); - }*/ - - \ No newline at end of file + void botbaixo_press(void){ + pbaixo = bot_baixo; + bot_baixo = !bot_baixo; + printf("baixo high"); + } \ No newline at end of file