
#include "terasic_includes.h"
#include "i2c.h"
#include "multi_touch.h"
#include "gui.h"

void GUI_VPG(MTC_INFO *pTouch);


int main()
{
   //const alt_u32 TouchI2cAddr = 0x10; 
    // touch
    MTC_INFO *pTouch;
    int X1, Y1, X2, Y2;
    alt_u8 Event, TouchNum;
    const bool bVPG = ((IORD(KEY_BASE, 0x00) & 0x01) == 0x00)?TRUE:FALSE;
    
    printf("Terasic Painter Demo\r\n");
    IOWR(LED_BASE, 0x00, 0x0F); // high-active
     
    
    pTouch = MTC_Init(MULTI_TOUCH_BASE, MULTI_TOUCH_IRQ);
    if (!pTouch){
        printf("Failed to init multi-touch\r\n");
    }else{
        printf("Init touch successfully\r\n");
#if 0   
        // tuning ack waiting duration       
        while(1){
        if (!MTC_Test(pTouch))
            printf("MTC test NG\r\n");
        }
#endif        
    }    
    
     if (bVPG)
        GUI_VPG(pTouch); // enter vpg mode when users press KEY0
    GUI(pTouch);
#if 0    
    while(1){
        
        // touch
        if (MTC_GetStatus(pTouch, &Event, &TouchNum, &X1, &Y1, &X2, &Y2)){
            MTC_ShowEventText(Event);
            printf(", Point Number:%d, (%d,%d),(%d,%d)\r\n", TouchNum, X1,Y1, X2, Y2);
        }        
    }
#endif
          

  return 0;
}





