3 key touch panel from Seeed

Dependencies:   MPR121

Fork of Seeed_Grove_I2C_Touch_Example by Seeed

main.cpp

Committer:
sam_grove
Date:
2013-07-26
Revision:
0:6f4bcfe86ac2
Child:
1:684222fa16bb

File content as of revision 0:6f4bcfe86ac2:

#include "mbed.h"
#include "MPR121.h"

// TODO: put IC in low power mode when disabled

DigitalOut myled(LED1);
DigitalOut off(LED4);
Timer t;

LogUtil logger;

I2C i2c(p28, p27);
InterruptIn irq(p26);
MPR121 touch_pad(i2c, irq, MPR121::ADDR_VSS );

int main() 
{       
    touch_pad.init();
    touch_pad.enable();
    t.start();
    while(1)
    {
        if(touch_pad.isPressed())
        {
            uint16_t button_val = touch_pad.buttonPressed();
            LOG("button = 0x%04x\n", button_val);
            myled = (button_val>0) ? 1 : 0;
        }
//        if(t.read_ms() > 5000)
//        {
//            touch_pad.disable();
//            off = 1;
//            wait(5.0f);
//            off = 0;
//            touch_pad.enable();
//            t.reset();
//        }
            
    }
}