📄 demo.c
字号:
/*******************************************************************************
*
* Filename : Demo.c
*
* Author : Tony Kan
* Date : 2007/08/21
* Company : RAiO Technology Inc.
* Case : 320 x 240 Evaluation board
* Device : RA8806 + MXIC MX10E8050IQC at 18.432MHZ
*
*******************************************************************************/
#include "Demo.h"
#include "Picture.h"
#define XCK_FREQUENCY 0x08
#define IDLE_TIME 87
/******************************************************************************/
/*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
#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(MISC);
LCD_DataWrite(XCK_FREQUENCY);
LCD_CmdWrite(ITCR);
LCD_DataWrite(IDLE_TIME);
LCD_ON();
while(1)
{
LCD_Clear();
switch(state)
{
case 0x00:
Display_Text();
break;
case 0x01:
Display_Picture();
break;
case 0x02:
Display_Ratate_90();
break;
case 0x03:
Display_Touch();
break;
}
if(state == 0x03) state = 0;
else
{
Delay100ms(30);
state++;
}
}
}
void Display_Text(void)
{
uchar i;
Access_Page1();
Only_Show_Page1();
LCD_Text();
LCD_GotoXY(0,0);
LCD_CmdWrite(0xb0);
LCD_PrintStr(sRAiO1, cXSize);
LCD_PrintStr(sRAiO2, cXSize);
LCD_Inv();
LCD_CmdWrite(0xb0);
LCD_PrintStr(sRAiO3, cXSize);
LCD_NoInv();
LCD_PrintStr(sRAiO2, cXSize);
LCD_FontSize(10);
LCD_GotoXY(5,70);
LCD_CmdWrite(0xb0);
LCD_PrintStr(sRAiO5a, 10);
LCD_FontSize(5);
LCD_GotoXY(7,120);
LCD_CmdWrite(0xb0);
LCD_PrintStr(sRAiO5b, 13);
LCD_FontSize(0);
Delay100ms(2);
LCD_GotoXY(0,160);
LCD_CmdWrite(0xb0);
for(i=0;i<40;i++)
{
LCD_DataWrite(i);
Delay1ms(1);
}
LCD_Bold();
LCD_CmdWrite(0xb0);
for(i=40;i<80;i++)
{
LCD_DataWrite(i);
Delay1ms(1);
}
LCD_NoBold();
LCD_CmdWrite(0xb0);
for(i=40;i<120;i++)
{
LCD_DataWrite(i);
Delay1ms(1);
}
}
void Display_Picture(void)
{
int i;
LCD_Graphic();
LCD_GotoXY(0,0);
LCD_CmdWrite(0xb0);
for(i=0;i<9600;i++)
LCD_DataWrite(RAiO_pic[i]);
}
void Display_Ratate_90(void)
{
LCD_Text();
LCD_Rotate90();
COM_DIR_239_0();
LCD_LineDist_Adjust(8);
LCD_GotoXY(0,0);
LCD_CmdWrite(0xb0);
LCD_PrintStr(sRAiO6a, 159);
Delay100ms(2);
LCD_LineDist_Adjust(0);
LCD_GotoXY(20,0);
LCD_CmdWrite(0xb0);
LCD_PrintStr(sRAiO6b, 231);
}
void Display_Touch(void)
{
uchar Debounce_count = 0;
uchar temp2,X1,Y1,X2,Y2;
int Timer_count = 0;
LCD_LineDist_Adjust(0);
LCD_Rotate90_Disable();
COM_DIR_0_239();
LCD_FontSize(5);
LCD_Text();
LCD_GotoXY(4,12);
LCD_CmdWrite(0xb0);
LCD_PrintStr(sRAiO7a, 16);
LCD_GotoXY(4,45);
LCD_CmdWrite(0xb0);
LCD_PrintStr(sRAiO7b, 16);
LCD_FontSize(0);
LCD_GotoXY(0,220);
LCD_CmdWrite(0xb0);
LCD_PrintStr(sRAiO8, cXSize);
Access_Page1();
Only_Show_Page1();
LCD_CmdWrite(0xC0); // Enable Touch Panel Function
LCD_DataWrite(0xC4);
while(1)
{
Debounce_count = 0; // initial Debounce counter
LCD_CmdWrite(0x0f); // Clear int
LCD_DataWrite(0x00);
Delay1ms(10);
LCD_CmdWrite(0x0f);
temp2 = LCD_DataRead();
if((temp2 & 0x01) == 0x01) //Select Auto mode
{
X1 = ADC_X1();
Y1 = ADC_Y1();
Delay1ms(2);
//===================================================
// Debounce The Touch State
//===================================================
if((X1 > 0x18)&&(X1 < 0xF0)&&(Y1 > 0x1B)&&(Y1 < 0xEA))
{
do
{
X2 = ADC_X1(); // Get coordinate value X2 and Y2
Y2 = ADC_Y1();
Delay1ms(2);
if((X2 == X1)&&(Y2 == Y1)) // Coordinate value are same as last time?
{
X1 = X2; // if sames then update X1 and Y1
Y1 = Y2;
}
Debounce_count++; // Comapre counter increase 1
if(Debounce_count == 2) // Compare the coordinate value twice?
{
if((X1 != 0)||(Y1 != 0)) // if X1 = Y1 = 0, Do not show coordinate value
{
LCD_Text();
LCD_GotoXY(13, 112);
LCD_CmdWrite(0xb0);
LCD_ShowStr("X = ",1);
LCD_GotoXY(17, 112);
LCD_CmdWrite(0xb0);
Print_Hex(X1); // Show X-coordinate
LCD_GotoXY(21, 112);
LCD_CmdWrite(0xb0);
LCD_ShowStr("Y = ",1);
LCD_GotoXY(25, 112);
LCD_CmdWrite(0xb0);
Print_Hex(Y1); // Show Y-coordinate
Timer_count = 0;
}
Debounce_count = 0; // initial debounce counter
LCD_CmdWrite(0x0f); // Clear TP status
LCD_DataWrite(0x00);
break; // Exit do-while
}
LCD_CmdWrite(0x0f); // Clear TP status
LCD_DataWrite(0x00);
Delay1ms(10);
LCD_CmdWrite(0x0f); // Check the TP Status
temp2 = LCD_DataRead();
}while((temp2 & 0x01) == 0x01); // Exit this function for no touch
} // The end of if((X1 > 0x18)&&(X1 < 0xF0)&&(Y1 > 0x1B)&&(Y1 < 0xEA))
LCD_CmdWrite(0x0f); // Clear TP status
LCD_DataWrite(0x00);
}
else // When release a nonsense touch for 20 seconds, exit touch-panel mode
{
Delay1ms(1);
Timer_count++;
if(Timer_count == 350)
{
Timer_count = 0;
break;
}
}
}
}
uchar ADC_X1(void)
{
uchar temp;
LCD_CmdWrite(TPXR);
temp=LCD_DataRead();
Delay1ms(10);
return temp;
}
uchar ADC_Y1(void)
{
uchar temp;
LCD_CmdWrite(TPYR);
temp=LCD_DataRead();
Delay1ms(10);
return temp;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -