beep keypad

Dependencies:   TextLCD mbed

Fork of Autus by Umair Aftab

main.cpp

Committer:
redplam
Date:
2014-04-12
Revision:
5:780a0888c3f2
Parent:
4:0cd0c7fe0682

File content as of revision 5:780a0888c3f2:

#include "mbed.h"
#define     BAUDRATE0       1200

#include "keypad.h"
#include "buzz.h"
#include "TextLCD.h"


//#include "esc.h"
//1 ESC esc1(PTC9);
PwmOut led_blue(PTC9);
TextLCD lcd(PTE29, PTE30, PTC1, PTD0, PTD5, PTA13, TextLCD::LCD20x2);   // rs, e, d4-d7 ok
Serial pc(PTE22,PTE23);
DigitalOut r0(PTD7);
DigitalOut fan_in_peltier(PTC11);                                       // Peltier FAN inside  the camber
DigitalOut fan_out_peltier(PTC10);                                      // Peltier FAN outside of the chamber
Ticker timer1ms;
unsigned int led_blue_pulsewidth;
/*
DigitalOut r1(PTD7);
DigitalOut r2(PTD6);
DigitalOut r3(PTE31);
DigitalOut r4(PTA17);
DigitalOut r5(PTC9);
DigitalOut r6(PTC11);
DigitalOut r7(PTC8);
DigitalOut r8(PTC10);
DigitalOut r9(PTA5);
DigitalOut r10(PTC6);
DigitalOut r11(PTC17);
DigitalOut r12(PTC5);

*/
int main(void)
{wait(2);
    pc.printf("hello");

    /*

    r1=0;
    r2=0;
    r3=0;
    r4=0;
    r5=0;
    r6=0;
    r7=0;
    r8=0;
    r9=0;
    r10=0;
    r11=0;
    r12=0;

    wait(5.0);
    r1=1;
    wait(5.0);
    r1=0;
    r2=1;
    wait(5.0);
    r2=0;
    r3=1;
    wait(5.0);
    r3=0;
    r4=1;
    wait(5.0);
    r4=0;
    r5=1;
    wait(5.0);
    r5=0;
    r6=1;
    wait(5.0);
    r6=0;
    r7=1;
    wait(5.0);
    r7=0;
    r8=1;
    wait(5.0);
    r8=0;
    r9=1;
    wait(5.0);
    r9=0;
    r10=1;
    wait(5.0);
    r10=0;
    r11=1;
    wait(5.0);
    r11=0;
    r12=1;
    wait(5.0);
    r12=0;
    wait(5.0);
    */
    /*1 esc1.setThrottle(10);
            esc1.pulse();
            wait_ms(20);  // 20ms is the default period of the ESC pwm */
    led_blue.period_us(1000);

    timer1ms.attach(&timer1, 0.001); //interrupt attached function(timer) with interval (1 ms)
    pc.baud( BAUDRATE0 );
    char key;
    // lcd.cls();
    lcd.setCursor(TextLCD::CurOff_BlkOn);
    lcd.locate(0,0);
    lcd.printf("Hello 123456");
    wait(5.0);
    led_blue_pulsewidth=50;

    while(1) {

        led_blue.period_us(1000);
        //led_blue.pulsewidth_us(led_blue_pulsewidth);
        //  lcd.cls();
        key = Keypad();
        lcd.cls();
        lcd.locate(0,1);
        lcd.printf("Temp is %2.1fC\n\r", key);
       // if ((led_blue_pulsewidth >= 0 )&&( led_blue_pulsewidth <= 10000)) {
            if (key==61) {
                led_blue_pulsewidth=led_blue_pulsewidth+100;
                led_blue.pulsewidth_us(led_blue_pulsewidth);
            };
            if (key==58) {
                led_blue_pulsewidth=led_blue_pulsewidth-100;
                led_blue.pulsewidth_us(led_blue_pulsewidth);
            };
     //   };
if (key==61) {fan_in_peltier=0;fan_out_peltier=1;};
if (key==58) {fan_out_peltier=0;fan_in_peltier=1;};

        //if (key!=NULL)
        //{}
        pc.printf("k\n");

        wait(0.1);
        //  if(key != 100) {
        //      pc.printf("keypad = %f\n", key);
        //
    }
    //     lcd.printf("%c\n\r",&key);
    //wait(0.2);

}