Rodrigo Lino
/
Menu_IHM
Menu para a IHM
Fork of TextLCD_HelloWorld2 by
main.cpp@5:9936706721a8, 2018-05-07 (annotated)
- Committer:
- digo1234
- Date:
- Mon May 07 17:58:59 2018 +0000
- Revision:
- 5:9936706721a8
- Parent:
- 4:a3e4bb2053cb
- Child:
- 6:49a35089f51b
menu com botoes;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wim | 4:a3e4bb2053cb | 1 | /* Hello World! for the TextLCD Enhanced Library*/ |
wim | 0:a75049de1a82 | 2 | |
wim | 0:a75049de1a82 | 3 | #include "mbed.h" |
wim | 0:a75049de1a82 | 4 | #include "TextLCD.h" |
digo1234 | 5:9936706721a8 | 5 | //#include "TextLCDScroll.h" |
digo1234 | 5:9936706721a8 | 6 | InterruptIn button1(D5); |
digo1234 | 5:9936706721a8 | 7 | InterruptIn button2(D4); |
digo1234 | 5:9936706721a8 | 8 | |
digo1234 | 5:9936706721a8 | 9 | DigitalOut led(LED2); |
wim | 4:a3e4bb2053cb | 10 | |
wim | 0:a75049de1a82 | 11 | // Host PC Communication channels |
wim | 0:a75049de1a82 | 12 | Serial pc(USBTX, USBRX); // tx, rx |
wim | 4:a3e4bb2053cb | 13 | |
wim | 0:a75049de1a82 | 14 | // I2C Communication |
digo1234 | 5:9936706721a8 | 15 | I2C i2c_lcd(D14,D15); // SDA, SCL |
digo1234 | 5:9936706721a8 | 16 | |
digo1234 | 5:9936706721a8 | 17 | |
digo1234 | 5:9936706721a8 | 18 | TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); // I2C exp: I2C bus, PCF8574 Slaveaddress, LCD Type |
digo1234 | 5:9936706721a8 | 19 | |
digo1234 | 5:9936706721a8 | 20 | bool flag_sim=0, flag_nao=0; |
digo1234 | 5:9936706721a8 | 21 | bool flag_sele=0, flag_cancel=0; |
wim | 0:a75049de1a82 | 22 | |
digo1234 | 5:9936706721a8 | 23 | void sim() |
digo1234 | 5:9936706721a8 | 24 | { |
digo1234 | 5:9936706721a8 | 25 | flag_sim=1; |
digo1234 | 5:9936706721a8 | 26 | } |
digo1234 | 5:9936706721a8 | 27 | void nao() |
digo1234 | 5:9936706721a8 | 28 | { |
digo1234 | 5:9936706721a8 | 29 | flag_nao=1; |
digo1234 | 5:9936706721a8 | 30 | } |
digo1234 | 5:9936706721a8 | 31 | void sele() |
digo1234 | 5:9936706721a8 | 32 | { |
digo1234 | 5:9936706721a8 | 33 | flag_sele=1 ; |
digo1234 | 5:9936706721a8 | 34 | } |
digo1234 | 5:9936706721a8 | 35 | void cancel() |
digo1234 | 5:9936706721a8 | 36 | { |
digo1234 | 5:9936706721a8 | 37 | flag_cancel=1 ; |
digo1234 | 5:9936706721a8 | 38 | } |
wim | 4:a3e4bb2053cb | 39 | int main() { |
wim | 0:a75049de1a82 | 40 | |
digo1234 | 5:9936706721a8 | 41 | lcd.setBacklight(TextLCD::LightOn); |
digo1234 | 5:9936706721a8 | 42 | lcd.setCursor(TextLCD::CurOff_BlkOn); |
wim | 4:a3e4bb2053cb | 43 | |
digo1234 | 5:9936706721a8 | 44 | lcd.setAddress(0,0); |
digo1234 | 5:9936706721a8 | 45 | lcd.printf("Selecionar ponto? "); |
digo1234 | 5:9936706721a8 | 46 | lcd.setAddress(0,1); |
digo1234 | 5:9936706721a8 | 47 | lcd.printf("1-Sim"); |
digo1234 | 5:9936706721a8 | 48 | lcd.setAddress(7,1); |
digo1234 | 5:9936706721a8 | 49 | lcd.printf("2-Nao"); |
digo1234 | 5:9936706721a8 | 50 | |
digo1234 | 5:9936706721a8 | 51 | button1.fall(&sim); |
digo1234 | 5:9936706721a8 | 52 | button2.fall(&nao); |
digo1234 | 5:9936706721a8 | 53 | |
digo1234 | 5:9936706721a8 | 54 | while(1) |
digo1234 | 5:9936706721a8 | 55 | { |
digo1234 | 5:9936706721a8 | 56 | |
digo1234 | 5:9936706721a8 | 57 | if(flag_sim==1) |
digo1234 | 5:9936706721a8 | 58 | { |
digo1234 | 5:9936706721a8 | 59 | lcd.cls(); |
digo1234 | 5:9936706721a8 | 60 | lcd.setAddress(0,0); |
digo1234 | 5:9936706721a8 | 61 | lcd.printf("selecione o ponto"); |
digo1234 | 5:9936706721a8 | 62 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
digo1234 | 5:9936706721a8 | 63 | printf("selecione o ponto\r\n"); |
digo1234 | 5:9936706721a8 | 64 | /* button1.fall(&sele); |
digo1234 | 5:9936706721a8 | 65 | button2.fall(&cancel); |
digo1234 | 5:9936706721a8 | 66 | if (flag_sele==1) |
digo1234 | 5:9936706721a8 | 67 | { |
digo1234 | 5:9936706721a8 | 68 | lcd.cls(); |
digo1234 | 5:9936706721a8 | 69 | lcd.setAddress(0,0); |
digo1234 | 5:9936706721a8 | 70 | lcd.printf("Mais algum ponto?"); |
digo1234 | 5:9936706721a8 | 71 | lcd.setAddress(2,1); |
digo1234 | 5:9936706721a8 | 72 | lcd.printf("1-Sim"); |
digo1234 | 5:9936706721a8 | 73 | lcd.setAddress(2,7); |
digo1234 | 5:9936706721a8 | 74 | lcd.printf("2-Nao"); |
digo1234 | 5:9936706721a8 | 75 | flag_sele=0; |
digo1234 | 5:9936706721a8 | 76 | }*/ |
digo1234 | 5:9936706721a8 | 77 | flag_sim=0; |
digo1234 | 5:9936706721a8 | 78 | |
digo1234 | 5:9936706721a8 | 79 | } |
digo1234 | 5:9936706721a8 | 80 | |
digo1234 | 5:9936706721a8 | 81 | if(flag_nao==1) |
digo1234 | 5:9936706721a8 | 82 | { |
digo1234 | 5:9936706721a8 | 83 | lcd.cls(); |
digo1234 | 5:9936706721a8 | 84 | lcd.setAddress(0,0); |
digo1234 | 5:9936706721a8 | 85 | lcd.printf("operacao cancelada") ; |
digo1234 | 5:9936706721a8 | 86 | printf("operacao cancelada\r\n"); |
digo1234 | 5:9936706721a8 | 87 | flag_nao=0; |
digo1234 | 5:9936706721a8 | 88 | } |
digo1234 | 5:9936706721a8 | 89 | |
digo1234 | 5:9936706721a8 | 90 | led=!led; |
digo1234 | 5:9936706721a8 | 91 | wait(0.1); |
wim | 4:a3e4bb2053cb | 92 | } |
wim | 4:a3e4bb2053cb | 93 | |
wim | 4:a3e4bb2053cb | 94 | } |
wim | 3:f238b4f7874f | 95 | |
wim | 3:f238b4f7874f | 96 | |
wim | 0:a75049de1a82 | 97 |