/*
***********************************************************************************************
* 				Interface a QVGA 320*240 262k color LCD module to PIC24FJ128GA010
*
* Hardware :	PIC24_Eval1 & FG020214_BO
* File:			..\PIC24_Eval1\SSD1289\main.c
* Functions: 	Simple RGB demonstration display on FG020214 262k color Graphical LCD Display
*				Pure color display in R,G,B for dead-point inspection
* 				Display a still image from Flash space as well.
*				This program tells how faster can a PIC24 running comparing to PIC18
* Date: 		3 Nov 2007
* Version:		1.0a
* Programmer: 	John Leung at TechToys Co.(www.TechToys.com.hk)
***********************************************************************************************
*/

#include <p24fj128ga010.h>
#include "SSD1289.h"
#include "women.h"

#define USE_AND_OR					//use & | mask for configuration bits for Timer1
#include <timer.h>

//JTAG OFF, WDT OFF (refer to p24FJ128GA010.h for arguments available)
_CONFIG1(JTAGEN_OFF & FWDTEN_OFF )
//configure fast RC oscillator with PLL and RC15 pin for Fosc/2 function		
_CONFIG2(FNOSC_FRCPLL & OSCIOFNC_OFF)

#define Delay	TMR1 = 0; while(TMR1<0xFFFF);	//65536*16us tick = 1sec (16us tick configured in cDispInitPort())

/*
********************************************************************************************************************
* 														MAIN
********************************************************************************************************************
*/
int main(void)
{

	INT8U x;
	INT16U y;

	CLKDIV = 0x0000;				//system initialization for a Fosc of 32MHz (combined with _CONFIG2 macro)
	cDispInit();					//Initialize LCD in white color

	for(;;)
	{
	for(x=0;x<240;x++) cDispSetPixel(x, 32, RGB16(0,0,31));
	for(x=0;x<240;x++) cDispSetPixel(x, 33, RGB16(0,0,31));
	for(x=0;x<240;x++) cDispSetPixel(x, 34, RGB16(0,0,31));
	for(x=0;x<240;x++) cDispSetPixel(x, 35, RGB16(0,0,31));
	cDisprStrAt(10, 155, "Hello World!", 2, RGB16(3,10,3));	
	//display a picture if iPod woman!	
	cDisprPatAt(60,64, &women[0]);	
		
	Delay;
	
		for(x=0;x<240;x++)
		{
			for(y=180;y<320;y++)
			cDispSetPixel(x,y,RGB16(x%32,y%64,(x+y)%32));
		}
			Delay;
			cDispClr(RGB16(31,0,0));	//pure red
			for(y=0;y<65535;y++);
			Delay;
			cDispClr(RGB16(0,63,0));	//pure green
			for(y=0;y<65535;y++);
			Delay;
			cDispClr(RGB16(0,0,31));	//pure blue
			for(y=0;y<65535;y++);
			Delay;
	}

	return (0);
}




