unsigned char code KeyCodeMap[4][4] = { //矩陣按鍵編號到標準鍵盤鍵碼的映射表
{ '1', '2', '3', 0x26 }, //數字鍵1、數字鍵2、數字鍵3、向上鍵
{ '4', '5', '6', 0x25 }, //數字鍵4、數字鍵5、數字鍵6、向左鍵
{ '7', '8', '9', 0x28 }, //數字鍵7、數字鍵8、數字鍵9、向下鍵
{ '0', 0x1B, 0x0D, 0x27 } //數字鍵0、ESC鍵、 回車鍵、 向右鍵
};
void KeyAction(unsigned char keycode)
{
if ((keycode>='0') && (keycode<='9')) //輸入字符
{
NumKeyAction(keycode - '0');
}
else if (keycode == 0x26) //向上鍵,+
{
OprtKeyAction(0);
} else if (keycode == 0x0D) //回車鍵,計算結果
{
GetResult();
}
else if (keycode == 0x1B) //Esc鍵,清除
{
Reset();
LcdShowStr(15, 1, "0");
}
}
問:在LCD上可以直接keycode - '0'得出想要的數嗎,為什么要用字符,不用0x26 的格式
|