IHM com 4 botões e todas as telas de pontos

Dependencies:   TextLCD mbed

Fork of Menu_IHM by Rodrigo Lino

Committer:
digo1234
Date:
Wed May 09 11:56:00 2018 +0000
Revision:
7:a550ec99045b
Child:
8:bd5509788843
Menu simplificado at? tela 2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
digo1234 7:a550ec99045b 1 /* Hello World! for the TextLCD Enhanced Library*/
digo1234 7:a550ec99045b 2
digo1234 7:a550ec99045b 3 #include "mbed.h"
digo1234 7:a550ec99045b 4 #include "TextLCD.h"
digo1234 7:a550ec99045b 5 #define apertado 0
digo1234 7:a550ec99045b 6 #define solto 1
digo1234 7:a550ec99045b 7
digo1234 7:a550ec99045b 8 //#include "TextLCDScroll.h"
digo1234 7:a550ec99045b 9
digo1234 7:a550ec99045b 10 InterruptIn button1(D5);
digo1234 7:a550ec99045b 11 InterruptIn button2(D4);
digo1234 7:a550ec99045b 12
digo1234 7:a550ec99045b 13 DigitalOut led(LED2);
digo1234 7:a550ec99045b 14
digo1234 7:a550ec99045b 15 // Host PC Communication channels
digo1234 7:a550ec99045b 16 Serial pc(USBTX, USBRX); // tx, rx
digo1234 7:a550ec99045b 17
digo1234 7:a550ec99045b 18 // I2C Communication
digo1234 7:a550ec99045b 19 I2C i2c_lcd(D14,D15); // SDA, SCL
digo1234 7:a550ec99045b 20
digo1234 7:a550ec99045b 21
digo1234 7:a550ec99045b 22 TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); // I2C exp: I2C bus, PCF8574 Slaveaddress, LCD Type
digo1234 7:a550ec99045b 23
digo1234 7:a550ec99045b 24 bool previous1=0, previous2=0;
digo1234 7:a550ec99045b 25 int menu=0;
digo1234 7:a550ec99045b 26
digo1234 7:a550ec99045b 27 void aumenta_menu(){
digo1234 7:a550ec99045b 28 menu = menu + 1;
digo1234 7:a550ec99045b 29 if (menu>2){
digo1234 7:a550ec99045b 30 menu=2;
digo1234 7:a550ec99045b 31 }
digo1234 7:a550ec99045b 32 }
digo1234 7:a550ec99045b 33
digo1234 7:a550ec99045b 34 void diminui_menu()
digo1234 7:a550ec99045b 35 {
digo1234 7:a550ec99045b 36 menu = menu - 1;
digo1234 7:a550ec99045b 37 if (menu<0){
digo1234 7:a550ec99045b 38 menu=0;
digo1234 7:a550ec99045b 39 }
digo1234 7:a550ec99045b 40 }
digo1234 7:a550ec99045b 41
digo1234 7:a550ec99045b 42
digo1234 7:a550ec99045b 43 int main() {
digo1234 7:a550ec99045b 44
digo1234 7:a550ec99045b 45 button1.rise(&aumenta_menu);
digo1234 7:a550ec99045b 46 button2.rise(&diminui_menu);
digo1234 7:a550ec99045b 47
digo1234 7:a550ec99045b 48 lcd.setBacklight(TextLCD::LightOn);
digo1234 7:a550ec99045b 49 lcd.setCursor(TextLCD::CurOff_BlkOff);
digo1234 7:a550ec99045b 50
digo1234 7:a550ec99045b 51 while(1){
digo1234 7:a550ec99045b 52
digo1234 7:a550ec99045b 53 while (menu==0){
digo1234 7:a550ec99045b 54 lcd.setAddress(0,0);
digo1234 7:a550ec99045b 55 lcd.printf("SELECIONE UMA FUNCAO ");
digo1234 7:a550ec99045b 56 lcd.setAddress(0,2);
digo1234 7:a550ec99045b 57 lcd.printf("1-SALVAR PONTOS");
digo1234 7:a550ec99045b 58 lcd.setAddress(0,3);
digo1234 7:a550ec99045b 59 lcd.printf("2-FUNCAO B");
digo1234 7:a550ec99045b 60 }
digo1234 7:a550ec99045b 61 lcd.cls();
digo1234 7:a550ec99045b 62 while (menu==1){
digo1234 7:a550ec99045b 63 lcd.setAddress(0,0);
digo1234 7:a550ec99045b 64 lcd.printf("SELECIONE O PONTO 1"); // Ponto 1
digo1234 7:a550ec99045b 65 lcd.setCursor(TextLCD::CurOff_BlkOff);
digo1234 7:a550ec99045b 66 lcd.setAddress(0,2);
digo1234 7:a550ec99045b 67 lcd.printf("1-SALVAR");
digo1234 7:a550ec99045b 68 lcd.setAddress(0,3);
digo1234 7:a550ec99045b 69 lcd.printf("2-CANCELAR OPERACAO");
digo1234 7:a550ec99045b 70 previous1 = 1;
digo1234 7:a550ec99045b 71 printf("dentro do menu1\r\n");
digo1234 7:a550ec99045b 72 }
digo1234 7:a550ec99045b 73 lcd.cls();
digo1234 7:a550ec99045b 74 while (menu==2){
digo1234 7:a550ec99045b 75 lcd.setAddress(0,0);
digo1234 7:a550ec99045b 76 lcd.printf("SELECIONE O PONTO 2"); // Ponto 2
digo1234 7:a550ec99045b 77 lcd.setCursor(TextLCD::CurOff_BlkOff);
digo1234 7:a550ec99045b 78 lcd.setAddress(0,2);
digo1234 7:a550ec99045b 79 lcd.printf("1-SALVAR");
digo1234 7:a550ec99045b 80 lcd.setAddress(0,3);
digo1234 7:a550ec99045b 81 lcd.printf("2-CANCELAR OPERACAO");
digo1234 7:a550ec99045b 82 previous1 = 1;
digo1234 7:a550ec99045b 83 printf("dentro do menu2\r\n");
digo1234 7:a550ec99045b 84 }
digo1234 7:a550ec99045b 85 lcd.cls();
digo1234 7:a550ec99045b 86 }
digo1234 7:a550ec99045b 87 }
digo1234 7:a550ec99045b 88