///////////////////////////////////////////////////
// BitsyXGPIOTest.cpp
// 720020-1180x
//
// Applied Data Systems
//
// This test application is part of the BitsyXGPIO
// class
///////////////////////////////////////////////////
#include <windows.h>
#include "BitsyXGPIO.h"

int WINAPI WinMain(	HINSTANCE hInstance,
				   HINSTANCE hPrevInstance,
				   LPTSTR    lpCmdLine,
				   int       nCmdShow)
{
	int i;
	
	RETAILMSG(TRUE, (_T("+BitsyXGPIOTest\r\n")));

	// create as both output (default)
	BitsyXGPIO *gp = new BitsyXGPIO();

	for(int i = 0 ; i < 30 ; i++)
	{
		for(int state = 0 ; state < 4 ; state++)
		{
			RETAILMSG(TRUE, (_T("Writing 0x%02x\r"), state));
			gp->Write(state);
			Sleep(500);
		}
	}

	// change to input
	gp->SetDirection(0);

	RETAILMSG(TRUE, (_T("\r\n")));
	for(i = 0 ; i < 600 ; i++)
	{
		RETAILMSG(TRUE, (_T("Read value: 0x%02x\r"), gp->Read()));
		Sleep(10);
	}

	// do a series of reads

	delete gp;

	RETAILMSG(TRUE, (_T("\r\n-BitsyXGPIOTest\r\n")));

	return 0;
}