TMC32_QJB/Key/Key.c

823 lines
18 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
******************************************************************************
* @file Key.c
* @author jjj
* @version V1.0.0
* @date 06/13/2022
* @brief
******************************************************************************
*
*
* <h2><center>&copy; COPYRIGHT 2022 </center></h2>
******************************************************************************
**/
#include "global.h"
#include "Key.h"
#define IDLE 0
#define KEY_INPUT_MAX 11
uint8_t key_input[KEY_INPUT_MAX+5];
volatile uint8_t num_key_input=0;
volatile uint16_t keyValue_last=0;
volatile uint16_t key_processed = 0;
uint8_t gKeyAction = 0;
extern uint8_t gReceiveKey;
const uint16_t KEY_ROW[4] = {KEYA_ROW0,KEYA_ROW1,KEYA_ROW2,KEYA_ROW3};
KEY_STATUS stKey1={0,1,0,0,0},
stKey2={0,1,0,0,0},
stKey3={0,1,0,0,0},
stKey4={0,1,0,0,0},
stKey5={0,1,0,0,0},
stKey6={0,1,0,0,0},
stKey7={0,1,0,0,0},
stKey8={0,1,0,0,0},
stKey9={0,1,0,0,0},
stKey0={0,1,0,0,0},
stKeyFn={0,1,0,0,0},
stKeyDA={0,1,0,0,0},
stKeyDB={0,1,0,0,0},
stKeyC={0,1,0,0,0},
stKeyVA={0,1,0,0,0},
stKeyVB={0,1,0,0,0};
extern void LCD_Erase();
extern void LCD_Display();
extern void LCD_CharDisplay();
extern void JJJ_Prompt();
extern uint8_t HIDKBW(BarData *pCode);
extern uint8_t DisableCodeBarRead(BarData *pCode);
extern uint8_t DisableRaedALl(BarData *pCode);
extern uint8_t EnableCodeBarRead(BarData *pCode);
extern uint8_t EnableQRRead(BarData *pCode);
extern uint8_t DisableQRRead(BarData *pCode);
extern uint8_t USBVirtualCOM(BarData *pCode);
extern uint8_t DisableKeyboard(BarData *pCode);
extern uint8_t EnableKeyboard(BarData *pCode);
extern uint8_t DisableOneDimReadNoUpd(BarData *pCode);
extern uint8_t EnableOneDimReadNoUpd(BarData *pCode);
extern uint8_t KeyRestoreFactorySetting(BarData *pCode);
extern void GetChipSNStr(int commtype);
extern void Play_KeyVoiceOne(void);
extern void Play_KeyVoiceTwo(void);
extern void Play_KeyVoiceThree(void);
extern void Play_KeyVoiceFour(void);
extern void Play_KeyVoiceFive(void);
extern void Play_KeyVoiceSix(void);
extern void Play_KeyVoiceSeven(void);
extern void Play_KeyVoiceEight(void);
extern void Play_KeyVoiceNine(void);
extern void Play_KeyVoiceZero(void);
extern void Play_KeyVoiceMinus(void);
extern void Play_KeyVoiceDelete(void);
extern void Play_KeyVoiceVerify(void);
extern void Play_KeyVoiceClean(void);
extern void Play_KeyVoiceTooLong(void);
extern void Play_KeyVoiceGainMode(void);
extern void Play_JinYongOneCode(void);
extern void Play_QiYongOneCode(void);
extern void Play_JinYongTwoCode(void);
extern void Play_QiYongTwoCode(void);
extern void Play_JinYongKeyboard(void);
extern void Play_QiYongKeyboard(void);
extern void Delay_us(uint32_t us);
#define FUN_KEY_SCAN(GPIOx,COL,stKey,KEYx) \
{ \
if(GPIO_ReadInputDataBit(GPIOx,COL)) \
{ \
stKey.release_count++; \
if(stKey.release_count>KEY_SHAKE_COUNT) \
{ \
stKey.pressed = 0; \
stKey.press_count = 0; \
stKey.released = 1; \
stKey.release_count = KEY_SHAKE_COUNT; \
} \
} else { \
stKey.press_count++; \
if(stKey.press_count>KEY_SHAKE_COUNT) \
{ \
stKey.released = 0; \
stKey.release_count = 0; \
stKey.press_count = KEY_SHAKE_COUNT; \
return KEYx; \
} \
} \
return 0; \
}
#define FUN_KEYPRESS(x,KEYx,stKey,PLAY_KEYVOICEx) \
if(!stKey.pressed) \
{ \
stKey.hold_count = 0; \
} else { \
stKey.hold_count++; \
if(stKey.hold_count==KEY_HOLDCOUNT)stKey.hold_count = 0; \
} \
key_processed = KEYx; \
stKey.pressed = 1; \
stKey.released = 0; \
if(stKey.hold_count==0) \
{ \
if(gConfgBuf.statusKey==OFF)break; \
if(num_key_input<KEY_INPUT_MAX) \
{ \
key_input[num_key_input++] = x; \
LCD_Display(key_input,num_key_input); \
PLAY_KEYVOICEx; \
} else Play_KeyVoiceTooLong(); \
}
/**
* @function Key_Init
* @brief Key<65><79>ʼ<EFBFBD><CABC>
*/
void Key_Init(void)
{
GPIO_InitTypeDef GPIO_Board_Init;
memset((void *)&GPIO_Board_Init,0,sizeof(GPIO_InitTypeDef));
GPIO_Board_Init.Pin = KEYA_ROW0|KEYA_ROW1|KEYA_ROW2|KEYA_ROW3;
GPIO_Board_Init.Pull = GPIO_PULLUP;
GPIO_Board_Init.Speed = GPIO_HIGH_SPEED;
GPIO_Board_Init.Otype = GPIO_MODE_OUTPUT_OD;
GPIO_Board_Init.Mode = GPIO_MODE_OUT;
GPIO_Init(KEYA_GPIO_PORT, &GPIO_Board_Init);
GPIO_SetBits(KEYA_GPIO_PORT,KEYA_ROW0);
GPIO_SetBits(KEYA_GPIO_PORT,KEYA_ROW1);
GPIO_SetBits(KEYA_GPIO_PORT,KEYA_ROW2);
GPIO_SetBits(KEYA_GPIO_PORT,KEYA_ROW3);
GPIO_Board_Init.Pin = KEYA_COL2|KEYA_COL3;
GPIO_Board_Init.Mode = GPIO_MODE_IN;
GPIO_Board_Init.Pull = GPIO_PULLUP;
GPIO_Init(KEYA_GPIO_PORT, &GPIO_Board_Init);
GPIO_Board_Init.Pin = KEYC_COL0|KEYC_COL1;
GPIO_Board_Init.Mode = GPIO_MODE_IN;
GPIO_Board_Init.Pull = GPIO_PULLUP;
GPIO_Init(KEYC_GPIO_PORT, &GPIO_Board_Init);
num_key_input = 0;
}
/**
* @function Key1_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:key1
* @return KEY1 - key1 pressed
* @return 0 - no action
*/
uint16_t Key1_Scan(void)
{
FUN_KEY_SCAN(KEY1GPIO,KEY1PIN,stKey1,KEY1);
}
/**
* @function Key2_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:key2
* @return KEY2 - key2 pressed
* @return 0 - no action
*/
uint16_t Key2_Scan(void)
{
FUN_KEY_SCAN(KEY2GPIO,KEY2PIN,stKey2,KEY2);
}
/**
* @function Key3_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:key3
* @return KEY3 - key3 pressed
* @return 0 - no action
*/
uint16_t Key3_Scan(void)
{
FUN_KEY_SCAN(KEY3GPIO,KEY3PIN,stKey3,KEY3);
}
/**
* @function KeyDA_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:keyDA
* @return KEYDA - keyda pressed
* @return 0 - no action
*/
uint16_t KeyDA_Scan(void)
{
FUN_KEY_SCAN(KEYDAGPIO,KEYDAPIN,stKeyDA,KEYDA);
}
/**
* @function Key4_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:key4
* @return KEY4 - key4 pressed
* @return 0 - no action
*/
uint16_t Key4_Scan(void)
{
FUN_KEY_SCAN(KEY4GPIO,KEY4PIN,stKey4,KEY4);
}
/**
* @function Key5_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:key5
* @return KEY5 - key5 pressed
* @return 0 - no action
*/
uint16_t Key5_Scan(void)
{
FUN_KEY_SCAN(KEY5GPIO,KEY5PIN,stKey5,KEY5);
}
/**
* @function Key6_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:key6
* @return KEY6 - key6 pressed
* @return 0 - no action
*/
uint16_t Key6_Scan(void)
{
FUN_KEY_SCAN(KEY6GPIO,KEY6PIN,stKey6,KEY6);
}
/**
* @function KeyDB_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:keydb
* @return KEYDB - keydb pressed
* @return 0 - no action
*/
uint16_t KeyDB_Scan(void)
{
FUN_KEY_SCAN(KEYDBGPIO,KEYDBPIN,stKeyDB,KEYDB);
}
/**
* @function Key7_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:key7
* @return KEY7 - key7 pressed
* @return 0 - no action
*/
uint16_t Key7_Scan(void)
{
FUN_KEY_SCAN(KEY7GPIO,KEY7PIN,stKey7,KEY7);
}
/**
* @function Key8_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:key8
* @return KEY8 - key8 pressed
* @return 0 - no action
*/
uint16_t Key8_Scan(void)
{
FUN_KEY_SCAN(KEY8GPIO,KEY8PIN,stKey8,KEY8);
}
/**
* @function Key9_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:key9
* @return KEY9 - key9 pressed
* @return 0 - no action
*/
uint16_t Key9_Scan(void)
{
FUN_KEY_SCAN(KEY9GPIO,KEY9PIN,stKey9,KEY9);
}
/**
* @function KeyVA_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:keyva
* @return KEYVA - keyva pressed
* @return 0 - no action
*/
uint16_t KeyVA_Scan(void)
{
FUN_KEY_SCAN(KEYVAGPIO,KEYVAPIN,stKeyVA,KEYVA);
}
/**
* @function KeyFn_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:keyfn
* @return KEYF - keyFn pressed
* @return 0 - no action
*/
uint16_t KeyFn_Scan(void)
{
FUN_KEY_SCAN(KEYFnGPIO,KEYFnPIN,stKeyFn,KEYF);
}
/**
* @function Key0_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:key0
* @return KEY0 - key0 pressed
* @return 0 - no action
*/
uint16_t Key0_Scan(void)
{
FUN_KEY_SCAN(KEY0GPIO,KEY0PIN,stKey0,KEY0);
}
/**
* @function KeyC_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:key clean
* @return KEYC - key clean pressed
* @return 0 - no action
*/
uint16_t KeyC_Scan(void)
{
FUN_KEY_SCAN(KEYCGPIO,KEYCPIN,stKeyC,KEYC);
}
/**
* @function KeyVB_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:key Verify B
* @return KEYVB - key Verify B pressed
* @return 0 - no action
*/
uint16_t KeyVB_Scan(void)
{
FUN_KEY_SCAN(KEYVBGPIO,KEYVBPIN,stKeyVB,KEYVB);
}
/**
* @function Key_Scan
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>:scan all keys one time
* @return keyValue - some key pressed
* @return 0 - no action
*/
uint16_t Key_Scan(void)
{
volatile uint16_t keyValue;
GPIO_ResetBits(KEYA_GPIO_PORT,KEYA_ROW0);
Delay_us(2);
keyValue = Key1_Scan();
keyValue |=Key2_Scan();
keyValue |=Key3_Scan();
keyValue |=KeyDA_Scan();
GPIO_SetBits(KEYA_GPIO_PORT,KEYA_ROW0);
GPIO_ResetBits(KEYA_GPIO_PORT,KEYA_ROW1);
Delay_us(2);
keyValue |=Key4_Scan();
keyValue |=Key5_Scan();
keyValue |=Key6_Scan();
keyValue |=KeyDB_Scan();
GPIO_SetBits(KEYA_GPIO_PORT,KEYA_ROW1);
GPIO_ResetBits(KEYA_GPIO_PORT,KEYA_ROW2);
Delay_us(2);
keyValue |=Key7_Scan();
keyValue |=Key8_Scan();
keyValue |=Key9_Scan();
keyValue |=KeyVA_Scan();
GPIO_SetBits(KEYA_GPIO_PORT,KEYA_ROW2);
GPIO_ResetBits(KEYA_GPIO_PORT,KEYA_ROW3);
Delay_us(2);
keyValue |=KeyFn_Scan();
keyValue |=Key0_Scan();
keyValue |=KeyC_Scan();
keyValue |=KeyVB_Scan();
GPIO_SetBits(KEYA_GPIO_PORT,KEYA_ROW3);
return keyValue;
}
/**
* @function ShowVersion
* @brief show firmware version
*/
uint8_t ShowVersion(BarData *pCode)
{
ClearOutputLen();
SetOutputData((uint8_t *)"Fn89",4);
SetPackType(PACK_TYPEA);
SetOutputData(CVERSION,VERSIONLEN);
ReportData(Communication_Id);
return TMC_NONE;
}
uint8_t Fn88ShowDevicemod(BarData *pCode)
{
ClearOutputLen();
SetOutputData((uint8_t *)"DEVICEMOD",9);
SetPackType(PACK_TYPEA);
SetOutputData(DEVICEMOD,DEVICEMODLEN);
ReportData(Communication_Id);
return TMC_NONE;
}
uint8_t startShowDevicemod(void)
{
ClearOutputLen();
SetOutputData((uint8_t *)"DEVICEMOD",9);
SetPackType(PACK_TYPEA);
SetOutputData(DEVICEMOD,DEVICEMODLEN);
ReportData(Communication_Id);
return TMC_NONE;
}
uint8_t ChangeToCom(BarData *pCode)
{
if(USBVirtualCOM(pCode)==TMC_OK)
{
ResetChip(9);
}
}
uint8_t ChangeToHIDKBW(BarData *pCode)
{
if(HIDKBW(pCode)==TMC_OK)
{
ResetChip(7);
}
}
uint8_t EnOrDisOneDimCode(BarData *pCode)
{
if(gConfgBuf.CodeBar==ON)
{
DisableOneDimReadNoUpd(pCode);
Play_JinYongOneCode();
if(gCfgUpdateFlag!=UPDATEALCFG)gCfgUpdateFlag = UPDATEALCFG;
SetOutputData((uint8_t *)"BARCODEDISABLE",14);
ReportData(pCode->bartype);
}
else
{
EnableOneDimReadNoUpd(pCode);
Play_QiYongOneCode();
if(gCfgUpdateFlag!=UPDATEALCFG)gCfgUpdateFlag = UPDATEALCFG;
SetOutputData((uint8_t *)"BARCODEENABLE",13);
ReportData(pCode->bartype);
}
return TMC_NONE;
}
uint8_t EnOrDisTwoDimCode(BarData *pCode)
{
if(gConfgBuf.QR==ON)
{
gConfgBuf.QR = OFF;
if(gCfgUpdateFlag!=UPDATEALCFG)gCfgUpdateFlag = UPDATEALCFG;
Play_JinYongTwoCode();
SetOutputData((uint8_t *)"Fn59DISABLE",11);
ReportData(pCode->bartype);
} else
{
gConfgBuf.QR = ON;
if(gCfgUpdateFlag!=UPDATEALCFG)gCfgUpdateFlag = UPDATEALCFG;
Play_QiYongTwoCode();
SetOutputData((uint8_t *)"Fn59ENABLE",11);
ReportData(pCode->bartype);
}
return TMC_NONE;
}
uint8_t EnOrDisKey(BarData *pCode)
{
if(gConfgBuf.statusKey==ON)
{
gConfgBuf.statusKey = OFF;
if(gCfgUpdateFlag==0)gCfgUpdateFlag = UPDATECFG;
Play_JinYongKeyboard();
SetOutputData((uint8_t *)"KEYBOARDDISABLE",15);
ReportData(pCode->bartype);
}
else
{
gConfgBuf.statusKey = ON;
if(gCfgUpdateFlag==0)gCfgUpdateFlag = UPDATECFG;
Play_QiYongKeyboard();
SetOutputData((uint8_t *)"KEYBOARDENABLE",14);
ReportData(pCode->bartype);
}
return TMC_NONE;
}
uint8_t IncreaseVolume(BarData *pCode)
{
if(gConfgBuf.voiceGain<4)
{
gConfgBuf.voiceGain++;
if(gCfgUpdateFlag==0)gCfgUpdateFlag = UPDATECFG;
SpeakerOff();
Delay_us(800);
Delay_us(500);
SpeakerOn();
}
Play_KeyVoiceGainMode();
SetOutputData((uint8_t *)"INCREASEV",9);
return TMC_OK;
}
uint8_t DecreaseVolume(BarData *pCode)
{
if(gConfgBuf.voiceGain>1)
{
gConfgBuf.voiceGain--;
if(gCfgUpdateFlag==0)gCfgUpdateFlag = UPDATECFG;
SpeakerOff();
Delay_us(800);
Delay_us(500);
SpeakerOn();
}
Play_KeyVoiceGainMode();
SetOutputData((uint8_t *)"DECREASEV",9);
return TMC_OK;
}
uint8_t ShowSN(BarData *pCode)
{
num_key_input = 0;
LCD_Erase();
uint8_t *p_sn = (uint8_t *) TUSNADDR;
if(*(p_sn + SN_SFLAG_OFFS) == 'S' && *(p_sn + SN_NFLAG_OFFS) == 'N')
{
LCD_CharDisplay((p_sn + SN_NFLAG_OFFS+1),*(p_sn+SN_LEN_OFFS) - SN_SNFLAG_LEN);
} else
{
}
return TMC_NONE;
}
uint8_t Fn29ShowSN(BarData *pCode)
{
num_key_input = 0;
LCD_Erase();
SetOutputData((uint8_t *)"Fn29",4);
uint8_t *p_sn = (uint8_t *) TUSNADDR;
if(*(p_sn + SN_SFLAG_OFFS) == 'S' && *(p_sn + SN_NFLAG_OFFS) == 'N')
{
if(!gReceiveKey)
{
SetPackType(PACK_TYPEA);
SetOutputData((uint8_t *)"NOKEY",5);
ReportData(Communication_Id);
} else {
SetOutputData((p_sn + SN_NFLAG_OFFS+1),*(p_sn+SN_LEN_OFFS) - SN_SNFLAG_LEN);
ReportData(Communication_Id);
}
} else
{
SetPackType(PACK_TYPEA);
SetOutputData("ERR",3);
ReportData(Communication_Id);
}
return TMC_NONE;
}
/**
* @function Key_Action
* @brief ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>Ӧ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
*/
void Key_Action(void)
{
uint16_t keyValue;
gKeyAction = 0;
keyValue = Key_Scan();
if(keyValue==0)
{
keyValue_last = keyValue;
key_processed = 0;
return ;
}
gKeyAction = 1;
BarData data;
data.bartype = Communication_Id;
switch(keyValue)
{
case (KEYF|KEY5|KEY9):
//en/disable qr code
if(key_processed==(KEYF|KEY5|KEY9))break;
key_processed = (KEYF|KEY5|KEY9);
stKey9.pressed = 1;
stKey9.released = 0;
stKeyFn.pressed = 1;
stKeyFn.released = 0;
stKey5.pressed = 1;
stKey5.released = 0;
EnOrDisTwoDimCode(&data);
num_key_input = 0;
LCD_Erase();
break;
case (KEY1):
FUN_KEYPRESS(1,KEY1,stKey1,Play_KeyVoiceOne());
break;
case (KEY2):
FUN_KEYPRESS(2,KEY2,stKey2,Play_KeyVoiceTwo());
break;
case (KEY3):
FUN_KEYPRESS(3,KEY3,stKey3,Play_KeyVoiceThree());
break;
case (KEY4):
FUN_KEYPRESS(4,KEY4,stKey4,Play_KeyVoiceFour());
break;
case (KEY5):
FUN_KEYPRESS(5,KEY5,stKey5,Play_KeyVoiceFive());
break;
case (KEY6):
FUN_KEYPRESS(6,KEY6,stKey6,Play_KeyVoiceSix());
break;
case (KEY7):
FUN_KEYPRESS(7,KEY7,stKey7,Play_KeyVoiceSeven());
break;
case (KEY8):
FUN_KEYPRESS(8,KEY8,stKey8,Play_KeyVoiceEight());
break;
case (KEY9):
FUN_KEYPRESS(9,KEY9,stKey9,Play_KeyVoiceNine());
break;
case (KEY0):
FUN_KEYPRESS(0,KEY0,stKey0,Play_KeyVoiceZero());
break;
case (KEYF):
FUN_KEYPRESS(10,KEYF,stKeyFn,Play_KeyVoiceMinus());
break;
case (KEYC):
if(!stKeyC.pressed)
{
key_processed = KEYC;
stKeyC.pressed = 1;
stKeyC.released = 0;
LCD_Erase();
if(num_key_input>0)
{
num_key_input = 0;
Play_KeyVoiceClean();
CleanPlayList();
}
}
break;
case (KEYD):
case (KEYDA):
case (KEYDB):
if((!stKeyDA.pressed)&&(!stKeyDB.pressed))
{
stKeyDA.hold_count = 0;
} else {
stKeyDA.hold_count++;
if(stKeyDA.hold_count==KEY_HOLDCOUNT)stKeyDA.hold_count = 0;
}
key_processed = KEYD;
stKeyDA.pressed = 1;
stKeyDB.pressed = 1;
stKeyDA.released = 0;
stKeyDB.released = 0;
if(stKeyDA.hold_count==0)
{
if(gConfgBuf.statusKey==OFF)break;
if(num_key_input>0)
{
num_key_input--;
LCD_Display(key_input,num_key_input);
Play_KeyVoiceDelete();
CleanPlayList();
}
}
break;
case (KEYV):
case (KEYVA):
case (KEYVB):
if((!stKeyVA.pressed)&&(!stKeyVB.pressed))
{
key_processed = KEYV;
stKeyVA.pressed = 1;
stKeyVB.pressed = 1;
stKeyVA.released = 0;
stKeyVB.released = 0;
if(gConfgBuf.statusKey==OFF)break;
if(num_key_input>0)
{
Key_SendData();
Play_KeyVoiceVerify();
CleanPlayList();
}
num_key_input = 0;
LCD_Erase();
}
break;
default:
key_processed = keyValue;
break;
}
keyValue_last = keyValue;
}
/**
* @function TIMER6_IRQHandler
* @brief <20><><EFBFBD>̶<EFBFBD>ʱ<EFBFBD>ж<EFBFBD>
*/
void TIMER6_IRQHandler(void)
{
TIM_ClearITStatus(TIM6);
TIM_ITConfig(TIM6, DISABLE);
TIM_Cmd(TIM6,DISABLE);
Key_Action();
TIM_ITConfig(TIM6, ENABLE);
TIM_Cmd(TIM6,ENABLE);
}
/**
* @function Key_SendData
* @brief send data to computer
*/
void Key_SendData(void)
{
uint8_t i,j;
char dat[20];
j = 0;
for(i=0;i<num_key_input;i++)
{
if(key_input[i]==10)
dat[j++] = '-';
else dat[j++] = key_input[i] + '0';
dat[j] = 0;
}
// if(!gReceiveKey)
// {
// SetPackType(PACK_TYPEA);
// SetOutputData((uint8_t *)"NOKEY",5);
// ReportData(Communication_Id);
// } else {
// SetOutputData((uint8_t *)"KEY",3);
// SetOutputData((uint8_t *)dat, j);
// ReportData(Communication_Id);
// }
// SetOutputData((uint8_t *)"KEY",3);
SetOutputData((uint8_t *)dat, j);
SetOutputData((uint8_t *)"\r",2);
ReportData(Communication_Id);
}