#include <stdio.h>
#include "..\..\lib\vp2k.h"
#include "..\..\lib\vp2k_lcd.h"

int main()
{
    int quit=0;
    int key;
    unsigned char string[20];
     
    InitLib();
    LCD_Init();
    
    LCD_PutsAt(0,0,"F6 to quit",0);
    LCD_PutsAt(0,1,"Others to start",0);
    
    while(!quit)
    {
        if(IsKey())
        {
            LCD_Clear();
            LCD_PutsAt(0,0,"F6 to quit",0);
            LCD_PutsAt(0,1,"Others to start",0);
            key=ReadKey();
            switch(key)
            {
                case 0xF01:
                    sprintf(string,"F1[%04Xh]",key);
                    break;
                case 0xF02:
                    sprintf(string,"F2[%04Xh]",key);
                    break;
                case 0xF03:
                    sprintf(string,"F3[%04Xh]",key);
                    break;
                case 0xF04:
                    sprintf(string,"F4[%04Xh]",key);
                    break;
                case 0xF05:
                    sprintf(string,"F5[%04Xh]",key);
                    break;
                case 0xF06:
                    sprintf(string,"F6[%04Xh]",key);
                    break;
                case 0xF07:
                    sprintf(string,"Up[%04Xh]",key);
                    break; 
                case 0xF08:
                    sprintf(string,"Down[%04Xh]",key);
                    break; 
                case 0xF09:
                    sprintf(string,"Left[%04Xh]",key);
                    break; 
                case 0xF0A:
                    sprintf(string,"Right[%04Xh]",key);
                    break; 
                case 0xF0B:
                    sprintf(string,"Shift[%04Xh]",key);
                    break;                    
                case 8:
                    sprintf(string,"backspace[%04Xh]",key);
                    break;
                case 0x0D:
                    sprintf(string,"Enter[%04Xh]",key);
                    break;
                default://0~9,+,-,A~Z,@,#,$,%
                    sprintf(string,"%c[%04Xh]",key,key);
                    break;
            
            }
            Print("%s\n\r",string);       
            LCD_PutsAt(0,2,string,0);
            if(key==F6_KEY) quit=1;
        }

    }//while loop
    LCD_PutsAt(0,3,"....Test ended",0);
    StopOutWave1();
    return 0;
}

