#include "mcc_generated_files/mcc.h"

void processButtonTouch(enum mtouch_button_names button)
{
    switch(button)
    {
        case Button0: LED1_SetLow();break;
        case Button1: LED2_SetLow();break;
        case Button2: LED3_SetLow();break;
        case Button3: LED4_SetLow();break;
        case Button4: LED5_SetLow();break;
        default: break;
    }
}

void processButtonRelease(enum mtouch_button_names button)
{
    switch(button)
    {
        case Button0: LED1_SetHigh();break;
        case Button1: LED2_SetHigh();break;
        case Button2: LED3_SetHigh();break;
        case Button3: LED4_SetHigh();break;
        case Button4: LED5_SetHigh();break;
        default: break;
    }
}

void processProximityActivate(enum mtouch_proximity_names prox)
{
    if(prox == Proximity0)
        LED0_SetLow();
}

void processProximityNotActivate(enum mtouch_proximity_names prox)
{
    if(prox == Proximity0)
        LED0_SetHigh();
}

/*
                         Main application
 */
void main(void)
{
    // initialize the device
    SYSTEM_Initialize();

    // When using interrupts, you need to set the Global and Peripheral Interrupt Enable bits
    // Use the following macros to:

    // Enable the Global Interrupts
    INTERRUPT_GlobalInterruptEnable();

    // Enable the Peripheral Interrupts
    INTERRUPT_PeripheralInterruptEnable();

    // Disable the Global Interrupts
    //INTERRUPT_GlobalInterruptDisable();

    // Disable the Peripheral Interrupts
    //INTERRUPT_PeripheralInterruptDisable();

    MTOUCH_Button_SetPressedCallback(processButtonTouch);
    MTOUCH_Button_SetNotPressedCallback(processButtonRelease);
    MTOUCH_Proximity_SetActivatedCallback(processProximityActivate);
    MTOUCH_Proximity_SetNotActivatedCallback(processProximityNotActivate);

    while (1)
    {
        // Add your application code
        MTOUCH_Service_Mainloop();
    }
}