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

📄 demo.c

📁 RA8806源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*******************************************************************************
*
*	Filename :	Demo.c
*
*	Author :	Tony Kan
*	Author Date :	2007/08/21
*	Company :	RAiO Technology	Inc.
*	Case :		320 x 240
*	Device :	MXIC MX10E8050IQC at 18.432MHZ
*	Modifier :	
*	Modify Date :	
*	Visions : 	X
*	Compiled Using Keil C v7.50
*
*******************************************************************************/

#include "Demo.h"
#include "stdlib.h"
#include "gray_pic.h"
#include <intrins.h>
#include <absacc.h>

/******************************************************************************/
/*Main program area		  													  */
/******************************************************************************/
void main(void)
{
//	int i;
	extern uchar Key_Code1, Key_Code2, Key_Code3, Key_Num;
	
	P0 = 0xff;
	P1 = 0xff;
	P2 = 0xff;
#ifdef Parallel_8080
	P3 = 0xff;
#endif

#ifdef Parallel_6800
	P3 = 0x77;
#endif

#ifdef Parallel_8080_4bit
	P3 = 0xff;
#endif

#ifdef Real_8080
	P3 = 0xff;
#endif


	AUXR = B0000_0011;	//Enable MOVX for external interface

	LCD_Reset();
	LCD_Initial();

	LCD_CmdWrite(BTMR);	
	LCD_DataWrite(0x20);

	LCD_CmdWrite(ITCR);	
	LCD_DataWrite(0xff);

	Enable_KeyScan();
	Enable_LongKey();
	Enable_KeyScan_WakeUp();

	LCD_ON();
	LCD_Clear();

//	Test_Touch();
//	Touch_Panel_Function();
//	AutoRun_Function();
	Main_Function();
}

//====================================================
// Main Function Page
//====================================================

void Main_Function(void)
{ 
	int i, Count = 0;

	LCD_Clear();

#ifdef Show_First_Page
	Access_Page1();
	Only_Show_Page1();

	LCD_Graphic();
	LCD_GotoXY(0,20);
	LCD_CmdWrite(0xb0);
	for(i=0;i<7360;i++)
		LCD_DataWrite(Demo_1st_Page_pic_4[i]);
#endif
		
	while(1)
	{
		if(Get_Key())
		{
			Clr_KeyScan_INT_Flag();
			Count = 0;
			LCD_CmdWrite(KSDR0);
			Key_Code1 = LCD_DataRead();
			Delay2us(50);
		
			switch(Key_Code1)
			{
				case 0x01:
					Rotate_Function();
					break;

				case 0x11:
					Font_Size_Function();
					break;

				case 0x21:
					Full_Align_Function();
					break;

				case 0x31:
					Two_Layer_Function();
					break;

				case 0x02:
					Scrolling_Function();
					break;

				case 0x12:
					Disp_Pic_Function();
					break;

				case 0x22:
					Sleep_Function();
					break;

				case 0x32:
					Touch_Panel_Function();
					break;
			}
			
		}
#ifdef	Auto_Run
		Delay1ms(1);
		Count++;
		if(Count == 25000)
		{
			Count = 0;
			AutoRun_Function();
		}
#endif
	}
}

void Rotate_Function(void)
{
	uchar i,temp;
	int Count = 0;
	LCD_Clear();

	LCD_AlignOff();
	LCD_Text();
	LCD_LineDist_Adjust(8);
	LCD_GotoXY(0,0);
	LCD_CmdWrite(0xb0);
	for(i=0;i<159;i++)
	{
		LCD_DataWrite(sRAiO1[i]);
		Delay2us(20);
		//Delay1ms(15);
	}
	
	while(1)
	{
		if(Get_Key())
		{
			Clr_KeyScan_INT_Flag();
			Count = 0;
			LCD_CmdWrite(KSDR0);
			Key_Code1 = LCD_DataRead();
			Delay2us(50);
		
			switch(Key_Code1)
			{
				case 0x01:
					LCD_Clear();
					LCD_Rotate90();
					SEG_DIR_0_319();
					COM_DIR_239_0();
					LCD_Text();
					LCD_GotoXY(0,0);
					LCD_CmdWrite(0xb0);
					for(i=0;i<159;i++)
					{
						LCD_DataWrite(sRAiO1[i]);
						Delay1ms(15);
					}
					break;

				case 0x11:
					LCD_Clear();
					LCD_Rotate90_Disable();
					SEG_DIR_319_0();
					COM_DIR_239_0();
					LCD_Text();
					LCD_GotoXY(0,0);
					LCD_CmdWrite(0xb0);
					for(i=0;i<159;i++)
					{
						LCD_DataWrite(sRAiO1[i]);
						Delay1ms(15);
					}
					break;

				case 0x21:
					LCD_Clear();
					LCD_Rotate90();
					SEG_DIR_319_0();
					COM_DIR_0_239();
					LCD_Text();
					LCD_GotoXY(0,0);
					LCD_CmdWrite(0xb0);
					for(i=0;i<159;i++)
					{
						LCD_DataWrite(sRAiO1[i]);
						Delay1ms(15);
					}
					break;

				case 0x31:
					LCD_Clear();
					LCD_Rotate90_Disable();
					SEG_DIR_0_319();
					COM_DIR_0_239();
					LCD_Text();
					LCD_GotoXY(0,0);
					LCD_CmdWrite(0xb0);
					for(i=0;i<159;i++)
					{
						LCD_DataWrite(sRAiO1[i]);
						Delay1ms(15);
					}
					break;

				case 0x02:
					LCD_CmdWrite(WCCR);
					temp = LCD_DataRead();
					temp ^= cSetb4;
					LCD_CmdWrite(WCCR);
					LCD_DataWrite(temp);

					LCD_Clear();
					LCD_Text();
					LCD_GotoXY(0,0);
					LCD_CmdWrite(0xb0);
					for(i=0;i<159;i++)
					{
						LCD_DataWrite(sRAiO1[i]);
						Delay2us(50);
					}
					break;

				case 0x22:
					LCD_CmdWrite(CHWI);
					temp = LCD_DataRead();
					if(temp < 15)
						temp = temp + 1;
					else
						temp = 15;

					LCD_CmdWrite(CHWI);
					LCD_DataWrite(temp);
					break;

				case 0x32:
					LCD_CmdWrite(CHWI);
					temp = LCD_DataRead();
					if(temp > 0)
						temp = temp - 1;
					else
						temp = 0;

					LCD_CmdWrite(CHWI);
					LCD_DataWrite(temp);
					break;

				case 0x80:
					LCD_Rotate90_Disable();
					SEG_DIR_0_319();
					COM_DIR_0_239();
					LCD_LineDist_Adjust(0);
					LCD_NoBold();
					Main_Function();
					break;
			}
			
		}
#ifdef	Auto_Run
		Delay1ms(1);
		Count++;
		if(Count == 25000)
		{
			Count = 0;
			AutoRun_Function();
		}
#endif
	}
}

void Font_Size_Function(void)
{
	uchar i,temp, FontSize;
	int Count = 0;
	LCD_Clear();

	LCD_Text();
	LCD_FontSize(0);
	LCD_GotoXY(0,0);
	LCD_CmdWrite(0xb0);
	for(i=0;i<8;i++)
	{
		LCD_DataWrite(sRAiO1[i]);
		Delay2us(50);
	}

	while(1)
	{
		if(Get_Key())
		{
			Clr_KeyScan_INT_Flag();
			Count = 0;
			LCD_CmdWrite(KSDR0);
			Key_Code1 = LCD_DataRead();
			Delay2us(50);
		
			switch(Key_Code1)
			{
				case 0x01:
					LCD_Clear();
					
					LCD_CmdWrite(FVHT);
					FontSize = LCD_DataRead();
					temp = FontSize >> 6;
					if(temp < 3)
						temp++;
					else
						temp = 3;
					temp = temp << 6;
					FontSize = ((FontSize & 0x3f) | (temp & 0xc0));
					LCD_CmdWrite(FVHT);
					LCD_DataWrite(FontSize);

					LCD_Text();
					LCD_GotoXY(0,0);
					LCD_CmdWrite(0xb0);
					for(i=0;i<8;i++)
					{
						LCD_DataWrite(sRAiO1[i]);
						Delay1ms(1);
					}
					break;

				case 0x11:
					LCD_Clear();

					LCD_CmdWrite(FVHT);
					FontSize = LCD_DataRead();
					temp = FontSize >> 6;
					if(temp > 0)
						temp--;
					else
						temp = 0;
					temp = temp << 6;
					FontSize = ((FontSize & 0x3f) | (temp & 0xc0));
					LCD_CmdWrite(FVHT);
					LCD_DataWrite(FontSize);

					LCD_Text();
					LCD_GotoXY(0,0);
					LCD_CmdWrite(0xb0);
					for(i=0;i<8;i++)
					{
						LCD_DataWrite(sRAiO1[i]);
						Delay1ms(1);
					}
					break;

				case 0x21:
					LCD_Clear();

					LCD_CmdWrite(FVHT);
					FontSize = LCD_DataRead();
					temp = (FontSize >> 4) & 0x03;
					if(temp < 3)
						temp++;
					else
						temp = 3;
					temp = temp << 4;
					FontSize = ((FontSize & 0xcf) | (temp & 0x30));
					LCD_CmdWrite(FVHT);
					LCD_DataWrite(FontSize);

					LCD_Text();
					LCD_GotoXY(0,0);
					LCD_CmdWrite(0xb0);
					for(i=0;i<8;i++)
					{
						LCD_DataWrite(sRAiO1[i]);
						Delay1ms(1);
					}
					break;

				case 0x31:
					LCD_Clear();

					LCD_CmdWrite(FVHT);
					FontSize = LCD_DataRead();
					temp = (FontSize >> 4) & 0x03;
					if(temp > 0)
						temp--;
					else
						temp = 0;
					temp = temp << 4;
					FontSize = ((FontSize & 0xcf) | (temp & 0x30));
					LCD_CmdWrite(FVHT);
					LCD_DataWrite(FontSize);

					LCD_Text();
					LCD_GotoXY(0,0);
					LCD_CmdWrite(0xb0);
					for(i=0;i<8;i++)
					{
						LCD_DataWrite(sRAiO1[i]);
						Delay1ms(1);
					}
					break;

				case 0x02:
					LCD_CmdWrite(WCCR);
					temp = LCD_DataRead();
					temp ^= cSetb4;
					LCD_CmdWrite(WCCR);
					LCD_DataWrite(temp);

					LCD_Text();
					LCD_GotoXY(0,0);
					LCD_CmdWrite(0xb0);
					for(i=0;i<8;i++)
					{
						LCD_DataWrite(sRAiO1[i]);
						Delay1ms(1);
					}
					break;

				case 0x12:
					LCD_CmdWrite(WLCR);
					temp = LCD_DataRead();
					temp ^= cSetb0;
					LCD_CmdWrite(WLCR);
					LCD_DataWrite(temp);
					break;

				case 0x22:
					LCD_CmdWrite(WLCR);
					temp = LCD_DataRead();
					temp ^= cSetb1;
					LCD_CmdWrite(WLCR);
					LCD_DataWrite(temp);
					break;

				case 0x03:
					LCD_CmdWrite(BTMR);
					temp = LCD_DataRead();
					if(temp > 4)
						temp = temp - 5;
					else
						temp = 0;

					LCD_CmdWrite(BTMR);
					LCD_DataWrite(temp);
					break;

				case 0x13:
					LCD_CmdWrite(BTMR);
					temp = LCD_DataRead();
					if(temp < 251)
						temp = temp + 5;
					else
						temp = 255;

					LCD_CmdWrite(BTMR);
					LCD_DataWrite(temp);
					break;

				case 0x80:
					LCD_CmdWrite(BTMR);
					LCD_DataWrite(0x80);
					LCD_FontSize(0);
					LCD_NoBold();
					LCD_NoGInv();
					LCD_NoBlk();
					Main_Function();
					break;
			}
			
		}
#ifdef	Auto_Run
		Delay1ms(1);
		Count++;
		if(Count == 25000)
		{
			Count = 0;
			AutoRun_Function();
		}
#endif
	}
}

void Full_Align_Function(void)
{
	uchar i,temp;
	int Count = 0;
	LCD_Clear();

	LCD_AlignOff();
	LCD_Text();
	LCD_LineDist_Adjust(8);
	LCD_GotoXY(0,0);
	LCD_CmdWrite(0xb0);
	for(i=0;i<181;i++)
	{
		LCD_DataWrite(sRAiO2[i]);
		Delay2us(50);
	}

	while(1)
	{
		if(Get_Key())
		{
			Clr_KeyScan_INT_Flag();
			Count = 0;
			LCD_CmdWrite(KSDR0);
			Key_Code1 = LCD_DataRead();
			Delay2us(50);
		
			switch(Key_Code1)
			{
				case 0x01:
					LCD_Clear();
					LCD_AlignOn();
					LCD_Text();
					LCD_GotoXY(0,0);
					LCD_CmdWrite(0xb0);
					for(i=0;i<181;i++)
					{
						LCD_DataWrite(sRAiO2[i]);
						Delay2us(50);
					}
					break;

				case 0x11:
					LCD_Clear();
					LCD_AlignOff();
					LCD_Text();
					LCD_GotoXY(0,0);
					LCD_CmdWrite(0xb0);
					for(i=0;i<181;i++)
					{
						LCD_DataWrite(sRAiO2[i]);
						Delay2us(50);
					}
					break;

				case 0x21:
					LCD_Clear();
					LCD_Rotate90();
					COM_DIR_239_0();
					LCD_Text();
					LCD_GotoXY(0,0);
					LCD_CmdWrite(0xb0);
					for(i=0;i<181;i++)
					{
						LCD_DataWrite(sRAiO2[i]);
						Delay2us(50);
					}
					break;

				case 0x31:
					LCD_Clear();
					LCD_Rotate90_Disable();
					COM_DIR_0_239();
					LCD_Text();
					LCD_GotoXY(0,0);
					LCD_CmdWrite(0xb0);
					for(i=0;i<181;i++)
					{
						LCD_DataWrite(sRAiO2[i]);
						Delay2us(50);
					}
					break;

				case 0x02:
					LCD_CmdWrite(WCCR);
					temp = LCD_DataRead();
					temp ^= cSetb2;
					LCD_CmdWrite(WCCR);
					LCD_DataWrite(temp);
					break;

				case 0x12:
					LCD_CmdWrite(WCCR);
					temp = LCD_DataRead();
					temp ^= cSetb1;
					LCD_CmdWrite(WCCR);
					LCD_DataWrite(temp);
					break;

				case 0x03:
					LCD_CmdWrite(BTMR);
					temp = LCD_DataRead();
					if(temp > 4)
						temp = temp - 5;
					else
						temp = 0;

					LCD_CmdWrite(BTMR);
					LCD_DataWrite(temp);
					break;

				case 0x13:
					LCD_CmdWrite(BTMR);
					temp = LCD_DataRead();
					if(temp < 251)
						temp = temp + 5;

⌨️ 快捷键说明

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