怎样在点阵屏上绘图——基于LCD12864三 下载本文

DisplayPoint +=1;

if ((DisplayPoint) == (MaxItems)) {

DisplayPoint = 0; } } }

else {

for (n = 0;n

LOCATE(n+1,1);

PRINT(MenuPoint[DisplayPoint].DisplayString);

if ((DisplayPoint) == UserChoose) {

BOX(1,n*16+1,126,(n+1)*16-2,1,1); }

DisplayPoint +=1;

if ((DisplayPoint) == (MaxItems)) {

DisplayPoint = 0;

} } }

//BOX(0,0,127,63,2,2); }

/************************************************************** * 函数说明:获得键值函数 *

**************************************************************/ short GetKeyNum(void) {

short TempKeyNum = 0;

TempKeyNum = F_Key_Scan(); //获取按键值 *P_IOA_Dir = 0x01ff;

*P_IOA_Attrib = 0x01ff; *P_IOA_Data = 0x01ff;

return TempKeyNum; }

/************************************************************** * 函数说明:主函数 *

**************************************************************/ int main()

{

short KeyNum = 0xff;

SystemInitialation(); //系统初始化

ShowMenu(); while(1) {

ClearWatchDog(); //喂狗

KeyNum = GetKeyNum(); //获取按键值

/*******************目录操作*********************/

/*************************************** * [按键说明] * * ----------------------------------- *

* [K1] UP(向上) *

* [K5] Down(向下) * * [K2] Esc(后退) * * [K6] Enter(确定) * * [K3] 返回根目录 *

***************************************/ if (KeyNum != 0xff) {

ShowMenu();

switch(KeyNum)

{

case UP:

UserChoose --;

if (UserChoose < 0) {

UserChoose = MaxItems-1; }

break;

case Esc:

if (MenuPoint[0].ParentMenus != &Null) {

MenuPoint = MenuPoint[0].ParentMenus; UserChoose = 0; DisplayStart = 0; }

break;

case Down:

UserChoose ++;

if (UserChoose == MaxItems) {

UserChoose = 0; } break;

case Enter:

if (MenuPoint[UserChoose].Subs != NullSubs) {

(*MenuPoint[UserChoose].Subs)(); }

else if (MenuPoint[UserChoose].ChildrenMenus != &Null) {

MenuPoint = MenuPoint[UserChoose].ChildrenMenus; UserChoose = 0; DisplayStart = 0; }

break;

case Reset:

MenuPoint = MainMenu; UserChoose = 0; DisplayStart = 0; break; }

if ((UserChoose < DisplayStart) || (UserChoose > (DisplayStart+3)))

{

DisplayStart = UserChoose; }