?? copy of main.c
字號:
{
delayMs(10);
if (scanKey1())
{
key1Check = key1Save;
if ((key1Check & 0x01) == 0)
{
procKey();
}
}
}
}
}
//===============================================
bit scanKey1 (void)
{
key1Save = 0x00;
key1Save |= KEY1;
return (key1Save ^ key1Check);
}
//===============================================
void procKey (void)
{
lcdClear();
dispString(0, 0, 1, "系┃1:背光2:聲響");
dispString(1, 0, 1, "統┃3:日歷4:溫控");
dispString(2, 0, 1, "設┃5:機控6:通訊");
dispString(3, 0, 1, "置┃7:其他8:關于");
beepBl();
key1Times++;
if (key1Times == 9)
{
key1Times = 1;
}
switch(key1Times)
{
case 1: convertChar(0, 2, 6);
break;
case 2: convertChar(0, 5, 6);
break;
case 3: convertChar(1, 2, 6);
break;
case 4: convertChar(1, 5, 6);
break;
case 5: convertChar(2, 2, 6);
break;
case 6: convertChar(2, 5, 6);
break;
case 7: convertChar(3, 2, 6);
break;
case 8: convertChar(3, 5, 6);
break;
}
}
//===============================================
void lcdInit (void)
{
MPU_RESET = LOW;
delayMs(40);
MPU_RESET = HIGH;
delayMs(1);
MPU_PS_CH = HIGH;
lcdWriteCommand(cFunctionSetE);
lcdWriteCommand(cFunctionSetB);
lcdClear();
lcdWriteCommand(cEntryModeSet);
lcdWriteCommand(cDisplayOnCtrl);
}
//===============================================
void lcdClear (void)
{
lcdWriteCommand(cClearDisplay);
}
//===============================================
void lcdWriteCommand (uchar Command)
{
checkLcdBusy();
MPU_RS_CH = LOW;
MPU_RW_CH = LOW;
LCD_DATA = Command;
MPU_ENABLE = HIGH;
delayMs(1);
MPU_ENABLE = LOW;
}
//===============================================
void lcdWriteData (uchar Data)
{
checkLcdBusy();
MPU_RS_CH = HIGH;
MPU_RW_CH = LOW;
LCD_DATA = Data;
MPU_ENABLE = HIGH;
delayMs(1);
MPU_ENABLE = LOW;
}
//===============================================
void checkLcdBusy (void)
{
LCD_DATA = 0xff;
MPU_RS_CH = LOW;
MPU_RW_CH = HIGH;
MPU_ENABLE = HIGH;
while (BUSY_FLAG);
MPU_ENABLE = LOW;
}
//===============================================
void displayPhoto (uchar *bmp, uchar bmpCls)
{
lcdPosX = 0x80;
halfScr = 2;
for (;halfScr != 0; halfScr--)
{
lcdPosY = 0x80;
halfLineCnt = 32;
for (;halfLineCnt != 0; halfLineCnt--)
{
basicBlock = 16;
wrPosition ();
for (; basicBlock != 0; basicBlock--)
{
if (bmpCls == OFF)
{
lcdWriteData (*bmp++);
}
else if (bmpCls == ON)
{
lcdWriteData (0x00);
}
}
lcdPosY++;
}
lcdPosX = 0x88;
}
lcdWriteCommand(cFuncDrawOn);
lcdWriteCommand(cFunctionSetB);
}
//===============================================
void convertChar (uchar CX, CY, width)
{
displayPhoto(OFF,ON);
lcdPosY = 0x80;
if (CX == 0)
{
CX = 0x80;
halfLineCnt = 16;
}
else if (CX == 1)
{
CX = 0x80;
halfLineCnt = 32;
}
else if (CX == 2)
{
CX = 0x88;
halfLineCnt = 16;
}
else if (CX == 3)
{
CX = 0x88;
halfLineCnt = 32;
}
lcdPosX = CX + CY;
for (; halfLineCnt != 0; halfLineCnt--)
{
basicBlock = width;
wrPosition();
for (;basicBlock != 0; basicBlock--)
{
if (halfLineCnt > 16)
{
lcdWriteData(0x00);
}
else
{
lcdWriteData (0xff);
}
}
lcdPosY++;
}
lcdWriteCommand(cFuncDrawOn);
lcdWriteCommand(cFunctionSetB);
}
//===============================================
void wrPosition (void)
{
lcdWriteCommand(cFunctionSetE);
lcdWriteCommand(lcdPosY);
lcdWriteCommand(lcdPosX);
lcdWriteCommand(cFunctionSetB);
}
//===============================================
void dispString (uchar X, Y, speed, uchar *msg)
{
if (X == 0)
{
X = 0x80;
}
else if (X == 1)
{
X = 0x90;
}
else if (X == 2)
{
X = 0x88;
}
else if (X == 3)
{
X = 0x98;
}
Y = X + Y;
lcdWriteCommand(Y);
while (*msg)
{
lcdWriteData(*msg++);
delayMs(speed);
}
}
//===============================================
void beepBl (void)
{
uchar i;
for (i = 0; i < 100; i++)
{
delayMs (2);
BEEP = !BEEP;
}
BEEP = 1;
}
//===============================================
void delayMs (uchar ms)
{
uchar i;
while (--ms)
{
for (i = 0; i < 125; i++);
}
}
//===============================================
void delaySec (uchar sec)
{
uchar i;
while (--sec)
{
for (i = 0; i < 200; i++)
{
delayMs (6);
}
}
}
//===============================================
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -