#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <time.h>
#include "..\LCM.h"

int _tmain(int argc, _TCHAR* argv[])
{
	int i = 0 ;
	//Init LCM library
	if (!LCM_Init () )
	{
		printf ("LCM Init fail\n") ;
		return -1 ;
	}

	//Text test
	LCM_TextOut ("Text Output\nABCDEFGHIJabcdefghij\n") ;
	Sleep (2000) ;
	LCM_TextOut ("Text Output\n1234567890~!@#$%^&*?\n") ;
	Sleep (2000) ;

	//Cursor test
	LCM_TextOut ("Cursor On and \nSet cursor position\n") ;
	for (i = 0 ; i < 20 ; i++) {	
		LCM_Cursor (TRUE, i, i % 2) ;
		Sleep (100) ;
	}

	LCM_TextOut ("Cursor OFF\n") ;
	LCM_Cursor (FALSE) ;
	Sleep (2000) ;

	//Backlight test
	LCM_TextOut ("Backlight off") ;
	LCM_Backlight (FALSE) ;
	Sleep (2000) ;

	LCM_TextOut ("Backlight On") ;
	LCM_Backlight (TRUE) ;
	Sleep (2000) ;

	//Keypad test
	for (i = 1500 ; i > 0 ; i-=5)
	{
		int Key = LCM_GetKeyPad () ;
		char str[128] ;

		sprintf (str, "Keypad test in\n       %02d.%02d seconds", i / 100, i % 100) ;

		if      (Key == 1)	LCM_TextOut ("Keypad test   \nS1") ;
		else if (Key == 2)	LCM_TextOut ("Keypad test   \n    S2") ;
		else if (Key == 4)	LCM_TextOut ("Keypad test   \n         S3") ;
		else if (Key == 8)	LCM_TextOut ("Keypad test   \n              S4") ;
		else				LCM_TextOut (str) ;
		Sleep (50) ;
	}

	return 0 ;
}