Example #1
0
void LCDFill (unsigned char xs,unsigned char ys,unsigned char width,unsigned char height, unsigned char color)
{
    unsigned char i,j;

    for (i=0;i < height;i++)	// Number of horizontal lines
    {
		LCDSetXY(xs,ys+i);		// Goto start of fill area (Top Left)
		LCDSend(PRAMWR);		// Write to display

		for (j=0;j < width;j++)	// pixels per line
			LCDSend(color);
    }
}
Example #2
0
void LCDInit(void)
{
	int i;

	LCDReset();

	LCDSend(PSWRESET);			// software reset
	SpinDelay(100);
	LCDSend(PSLEEPOUT);			// exit sleep mode
	LCDSend(PBSTRON);			// booster on
	LCDSend(PDISPON);			// display on
	LCDSend(PNORON);			// normal on
	LCDSend(PMADCTL);			// rotate display 180 deg
	LCDSend(0xC0);

	LCDSend(PCOLMOD);			// color mode
	LCDSend(0x02);				// 8bpp color mode

    LCDSend(PSETCON);			// set contrast
    LCDSend(0xDC);

	// clear display
    LCDSetXY(0,0);
	LCDSend(PRAMWR);			// Write to display
	i=LCD_XRES*LCD_YRES;
	while(i--) LCDSend(WHITE);
  
  // test text on different colored backgrounds
	LCDString(" The quick brown fox  ",	(char *)&FONT6x8,1,1+8*0,WHITE  ,BLACK );
	LCDString("  jumped over the     ",	(char *)&FONT6x8,1,1+8*1,BLACK  ,WHITE );
	LCDString("     lazy dog.        ",	(char *)&FONT6x8,1,1+8*2,YELLOW ,RED   );
	LCDString(" AaBbCcDdEeFfGgHhIiJj ",	(char *)&FONT6x8,1,1+8*3,RED    ,GREEN );
	LCDString(" KkLlMmNnOoPpQqRrSsTt ",	(char *)&FONT6x8,1,1+8*4,MAGENTA,BLUE  );
	LCDString("UuVvWwXxYyZz0123456789",	(char *)&FONT6x8,1,1+8*5,BLUE   ,YELLOW);
	LCDString("`-=[]_;',./~!@#$%^&*()",	(char *)&FONT6x8,1,1+8*6,BLACK  ,CYAN  );
	LCDString("     _+{}|:\\\"<>?     ",(char *)&FONT6x8,1,1+8*7,BLUE  ,MAGENTA);
  
	// color bands
	LCDFill(0, 1+8* 8, 132, 8, BLACK);
	LCDFill(0, 1+8* 9, 132, 8, WHITE);
	LCDFill(0, 1+8*10, 132, 8, RED);
	LCDFill(0, 1+8*11, 132, 8, GREEN);
	LCDFill(0, 1+8*12, 132, 8, BLUE);
	LCDFill(0, 1+8*13, 132, 8, YELLOW);
	LCDFill(0, 1+8*14, 132, 8, CYAN);
	LCDFill(0, 1+8*15, 132, 8, MAGENTA);

}
Example #3
0
void LCDSetPixel(unsigned char x, unsigned char y, unsigned char color)
{
	LCDSetXY(x,y);				// Set position
	LCDSend(PRAMWR);			// Now write the pixel to the display
	LCDSend(color);				// Write the data in the specified Color
}
Example #4
0
int LCDClearData(BYTE add1)
{
#ifdef _WINDOWS
    UNUSED(add1);
#else
	BYTE i; 
	BYTE j; 
	BYTE data; 
	BYTE status; 	
		
	for(j=0;j<7;j++){
		LCDSetXY(add1,0,j);
		RestartI2C();
	    IdleI2C();
	
		//****write the address of the device for communication***
	    data = SSPBUF;        //read any previous stored content in buffer to clear buffer full status
	    do
	    {
	    status = WriteI2C( add1 | 0x00 );    //write the address of slave
	        if(status == -1)        //check if bus collision happened
	        {
	            data = SSPBUF;        //upon bus collision detection clear the buffer,
	            SSPCON1bits.WCOL=0;    // clear the bus collision status bit
				//LATAbits.LATA1 =1;
	        }
	    }
	    while(status!=0);        //write untill successful communication
		//R/W BIT IS '0' FOR FURTHER WRITE TO SLAVE
		do
	    {
	    status = WriteI2C(modeLCD_DATA_TILL_STOP);    //write the address of slave
	        if(status == -1)        //check if bus collision happened
	        {
	            data = SSPBUF;        //upon bus collision detection clear the buffer,
	            SSPCON1bits.WCOL=0;    // clear the bus collision status bit
				//LATAbits.LATA1 =1;
	        }
	    }
	    while(status!=0);        //write untill successful communication
		//***WRITE THE THE DATA TO BE SENT FOR SLAVE***
		//write string of data to be transmitted to slave
	   	for (i=0;i<128;i++ )                 // transmit data 
		{
		  	if ( SSP1CON1bits.SSPM3 )      // if Master transmitter then execute the following
			{
				//temp = putcI2C1 ( *wrptr );
				//if (temp ) return ( temp );   	
				if ( WriteI2C1( 0 ) )    // write 1 byte
				{
				  return ( -3 );             // return with write collision error
				}
				IdleI2C1();                  // test for idle condition
				if ( SSP1CON2bits.ACKSTAT )  // test received ack bit state
				{
				  return ( -2 );             // bus device responded with  NOT ACK
				}                            // terminate putsI2C1() function
			}	  	          
		}         
	    
		
	//---TERMINATE COMMUNICATION FROM MASTER SIDE---
	     IdleI2C();
	}
#endif
	return 0;
}