proyectotecnicas / Mbed 2 deprecated intento-menu

Dependencies:   TextLCD mbed

main.cpp

Committer:
josedaparte
Date:
2015-11-29
Revision:
1:db98edccd932
Parent:
0:20ec80029ebe

File content as of revision 1:db98edccd932:

#include "mbed.h"
#include "AnalogIn.h"
#include "TextLCD.h"

Serial pc(USBTX, USBRX);
AnalogIn externo(PTC2);
AnalogIn interno(PTB3);
InterruptIn sw1(SW1);
DigitalIn sw3(SW3);
DigitalIn llave(PTA1);

 
TextLCD lcd(PTD3, PTA12, PTA4, PTA5, PTC8, PTC9, TextLCD::LCD16x2);

int sel = 0;
int temp = 26;
char tipo;

void menu (){
             if(llave == 0){                         //modo auto
                                        wait(1);
                                        lcd.cls();
                                        do{
                                            lcd.locate(0,0);
                                            lcd.printf("temperatura");                                       
                                            }while(sw1 == 1 && sw3 == 1);
                                                if(sw3 == 0){
                                                  lcd.cls();
                                                  wait(.5);
                                                  pc.printf("ingrese temperatura\r\n");
                                                  pc.scanf("%d", &temp);
                                                  pc.printf("se seteo la temperatura a %.0d\r\n", temp);
                                                    }
                                                   else{
                                                        lcd.cls();
                                                        do{
                                                        lcd.locate(0,0);    
                                                        lcd.printf("tipo de banio");
                                                            }while(sw1 == 1 && sw3 == 1);
                                                                if(sw3 == 0){
                                                                    wait(.20);
                                                                    pc.scanf("%c", &tipo);
                                                                    pc.printf("el tipo de banio es %c\r\n", tipo);
                                                                    }
                                                                    else{
                                                                        lcd.cls();
                                                                        do{
                                                                            lcd.locate(0,0);
                                                                            lcd.printf("horarios");
                                                                             wait(.20);
                                                                            }while(sw1 == 1 && sw3 == 1);
                                                                               if(sw3 == 0){
                                                                                   wait(.20);
                                                                                   }
                                                                                   else{
                                                                                        wait(.15);
                                                                                        lcd.cls();
                                                                                        do{ 
                                                                                            lcd.locate(0,0);
                                                                                            lcd.printf("reloj");
                                                                                            wait(.20);
                                                                                            }while(sw1 == 1 && sw3 == 1);
                                                                                                if(sw3 == 0){
                                                                                                    wait(1);
                                                                                                    }
                                                                                                    else{
                                                                                                        lcd.cls();
                                                                                                        do{
                                                                                                            lcd.locate(0,0);
                                                                                                            lcd.printf("salir");
                                                                                                            wait(0.20);
                                                                                                            }while(sw1 == 1 && sw3 == 1);
                                                                                                                if(sw3 == 0){
                                                                                                                    wait(.20);
                                                                                                                    return;
                                                                                                                    }
                                                                                                                    else{                                                                                                                      
                                                                                                                       menu();
                                                                                                                        }}}}}}
            else{
                lcd.cls();
                lcd.printf("move la llave");
                lcd.locate(0,1);
                lcd.printf("pequenio puto");
                }   //llave fin else principal
        }           //llave de fin funcion        
int main() {
  
    pc.baud(115200);

    float casinterno;
    float casexterno;
    float tinterno;
    float texterno;
    int comp;

    while(1){
        sw1.fall(&menu);
        lcd.cls();
        
        if(llave == 0){
            lcd.locate(8,1);
            lcd.printf("Auto");
            }else {
                    lcd.locate(8,1);
                    lcd.printf("man");
                    }
        casexterno = externo.read() * 3.3;
        texterno = (casexterno + 0.2) * 100 / 5;
        
        casinterno = interno.read() * 3.3;
        tinterno = (casinterno + 2) * 100 / 8;
        lcd.locate(0,0);
        lcd.printf("int %.0f set %d",tinterno, temp);
        lcd.locate(0,1);
        lcd.printf("ext %.0f ", texterno);
        comp = tinterno;
        if(comp == temp)
            pc.printf("las temperaturas son iguales\n\r");
        else
            pc.printf("temperaturas distintas\n\r");
        wait(1);
    }
}