⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demo.c

📁 RA8803液晶控制器的程序
💻 C
字号:
/*******************************************************************************
*                                                                            
*	Filename:	Demo.c
* 
*   	Author:		Duke Chang
*   	Company:    	RAiO Technology Inc.
*	Case:		320x240 
*	Device:		MXIC MX10E8050IQC at 18.432MHz
*   	Date:       	2005/10/1
*	Modifier:	Duke Chang
*	Modify Date:    2005/10/13
*   	Visions:   	1.0
*   	Compiled Using Keil C v7.50
*	
*******************************************************************************/

#include "Demo.h"

/******************************************************************************/
/*Main program area		  													  */
/******************************************************************************/
void main(void)
{
	uchar state;

	P0 = 0xff;
	P1 = 0xff;
	P2 = 0xff;
#ifdef Parallel_8080
	P3 = 0xff;
#endif

#ifdef Parallel_6800
	P3 = 0x77;
#endif
	
	AUXR = B0000_0011;	//Enable MOVX for external interface

	LCD_Reset();
	LCD_Initial();
	state = 0;

	while(1)	
	{		
		switch(state)
		{
			case 0:
				Test_Font();
				break;	
			case 1:
				Test_Pattern();
				break;	
			case 2:	
				Test_Font();
				Test_Touch();
				break;

		}	
		state++;
		if(state==3) state=0;						
	}				
}

/******************************************************************************/
/*Sub program area		  													  */
/******************************************************************************/

//==============================================================================
//Subroutine:	Test_Pattern
//Function:		
//==============================================================================
void Test_Pattern(void)
{
	uchar x, y;
	uchar pat, temp, count;

	LCD_ON();
	LCD_Graphic();

	for(pat=0; pat<10; pat++)	
	{			
		switch(pat)
		{
			case 0:	temp = 0xff;
				break;	
			case 1:	temp = 0x00;
				break;
			case 2:	temp = 0x55;
				break;
			case 3:	temp = 0xaa;
				break;	
			case 4:	temp = 0xcc;
				break;	
			case 5:	temp = 0x33;
				break;	
			case 6:	temp = 0xF0;
				break;	
			case 7:	temp = 0x0F;
				break;
			case 8:	temp = 0x0F;
				break;
			case 9:	temp = 0xFF;
				break;				
		}								
		count = 0;
		LCD_GotoXY(0, 0);
		Delay100us(1);
		for(y=0 ; y<cYSize ; y++)
		{ 
			for(x=0 ; x<cXSize/2 ; x++)
			{
				LCD_DataWrite(temp);
				if(pat==9)	LCD_DataWrite(~temp);
				else LCD_DataWrite(temp);
			}
			count++;
			if((pat==8)&&(count==4))
			{	temp = ~temp;
				count=0;
			}

			else if((pat==9)&&(count==8))
			{	temp = ~temp;
				count=0;
			} 
		}
		LCD_CmdWrite(MAMR, B1001_0001);
		Delay100ms(10);
	}
}

//==============================================================================
//Subroutine:	Test Display/Inverse/Blink/Cursor
//Function:		
//==============================================================================
void Test_Touch(void)
{
	uchar temp, X1, X2, Y1, Y2;
	uint Timeout;

	ADC_On();
	LCD_GotoXY(0, 210);
	for(temp=0 ; temp<22 ; temp++)
	{	LCD_DataWrite(sRAiO5[temp]);
	}

	Timeout=0;
	while(1)
	{
		temp = ADC_Touch();
		if(temp==0x01)
		{
			Timeout=0;
			X1 = ADC_X();
			Y1 = ADC_Y();
			Delay1ms(2);
			temp = ADC_Touch();
			if(temp==0x01)
			{
				X2 = ADC_X();
				Y2 = ADC_Y();
//				Delay1ms(2);
			
				LCD_GotoXY(0, 210);
				if((X1==X2) && (Y1==Y2))
				{	
					LCD_Bold();
					for(temp=0 ; temp<11 ; temp++)
					{	LCD_DataWrite(sRAiO7[temp]);
					}
//					Delay10ms(1);
					LCD_GotoXY(13, 210);
					Print_Hex(Y1);
					LCD_GotoXY(21, 210);
					Print_Hex(X1);
					LCD_NoBold();
				}
			}
		}
		else
		{
			LCD_GotoXY(0, 210);
			for(temp=0 ; temp<11 ; temp++)
			{	LCD_DataWrite(sRAiO6[temp]);
			}
			Timeout++;
			if(Timeout==0x08FF) break;
		}
	}
}
//==============================================================================
//Subroutine:	Test_Font, 8x18, 8x16m 16x16, Bold
//Function:		
//==============================================================================
void Test_Font(void)
{
	uchar temp;

	LCD_ON();
	LCD_Clear();
	LCD_Text();
	LCD_AlignOff();

	LCD_GotoXY(0, 0);
	LCD_PrintStr(sRAiO1, cXSize);
	Delay10ms(2);

	LCD_PrintStr(sRAiO2, cXSize);
	Delay10ms(2);

	LCD_Inv();
	LCD_PrintStr(sRAiO3, cXSize);
	Delay10ms(2);

	LCD_NoInv();
	LCD_GotoXY(10, 75);
	LCD_FontSize(0x05);
	for(temp=0 ; temp<11 ; temp++)
	{	LCD_DataWrite(sRAiO4[temp]);
		Delay100us(2);
	}
	Delay10ms(2);

	LCD_FontSize(0x00);
	LCD_GotoXY(0, 120);
	for(temp=0x30 ; temp<=0x7F ; temp++)
	{	LCD_DataWrite(temp);
	}
	Delay10ms(2);

	LCD_GotoXY(0, 160);
	LCD_Bold();
	for(temp=0x30 ; temp<=0x7F ; temp++)
	{	LCD_DataWrite(temp);
	}

	LCD_NoBold();
	Delay100ms(20);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -