📄 main.c
字号:
#include "SCH51.h"
#include "ExtDef.h"
#include "key.h"
#include "LCD.h"
#include "stdio.h"
#include "serial.h"
#include "string.h"
#define UART_Int_Enable() ES=1;
#define UART_Int_Disable() ES=0;
uchar xdata PORT _at_ 0x8002;
extern uchar xdata *inTxBuf,*outTxBuf,*inRxBuf,*outRxBuf; // buffer pointers,缓冲区指针
extern uchar TIflag;
extern uchar RIflag;
void OutputLED()
{
if(Key!=Nothing)
{
PORT = Key;
Key=Nothing; //信息已被处理,抛弃它
}
}
void OutputURAT()
{
// clrscr();
PrintStr("Hello World!");
}
void CMD_Process()
{
uchar *t;
if(RIflag)
{
// RIflag=0;
t=inRxBuf;
t--;
if(*t==0x08) // Backspace key
{
PrintStr("你按下了BackSpace键!You pressed key 'BackSpace'!");
PrintStr("\b");
}
else if(*t==0x1B)
{
PrintStr("你按下了Esc键!You pressed key 'Esc'!");
PrintStr("\x0c");
}
else if(*t==0x0D)
{
PrintStr("你按下了Enter键!You pressed key 'Enter'!");
PrintStr("\r\n");
PrintStr("\033[1;5;40;32m good!!! \033[0m Hello,NSFocus \n"); // "\033[0m " is the default setting(White background,Black font);
// "\033[1;40;32m" -->"40"indicates black background; "32"indicates green foreground.
/*
Foreground Background
---------------------------------------
30 40 black
31 41 red
32 42 green
33 43 yellow
34 44 blue
35 45 purple-red
36 46 green-blue
37 47 white
-------------------------
0 终端默认设置(一般的默认为黑底白字)
1 高亮显示
4 使用下划线
5 闪烁
7 反白显示
8 不可见
*/
}
else if(*t==0x09) // Tab key
{
PrintStr("你按下了Tab键! You pressed key 'Tab'!");
PrintStr("\t");
}
}
}
void OutputLCD()
{
uchar *t;
if(RIflag)
{
RIflag = 0;
t=inRxBuf;
t--;
if(*t==0x08) // Backspace key
{
cls();
Str_Write(0,0,"You pressed key 'BackSpce'!",1);
}
else if(*t==0x1B)
{
Str_Write(0,0,"You pressed key 'Esc'!",1);
cls();
}
else if(*t==0x0D)
{
cls();
Str_Write(0,0,"You pressed key 'Enter'!",1);
}
else if(*t==0x09) // Tab key
{
cls();
Str_Write(0,0,"You pressed key 'Tab'!",1);
}
}
}
void main(void)
{
SCH_Init_T2();
InitSerialBuffer();
InitSerial(5);
Init_LCD();
SCH_Add_Task(KEY_Update, 1, 2);
SCH_Add_Task(OutputLED, 1, 2);
SCH_Add_Task(OutputURAT, 1, 0);
SCH_Add_Task(CMD_Process, 2, 1);
SCH_Add_Task(OutputLCD, 2, 2);
SCH_Start();
while(1)
{
SCH_Dispatch_Tasks();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -