/*
在数组内可以有标号吗?我需要一些标号如key_tab_1的偏移量填充在数组内,标号之间的偏移量 是不等长的,该怎样实现啊?
*/
void find(void) //00H
{
}
void setup(void) //01H setup current time
{
}
void dec_min(void) //02H 60-0
{
}
void inc_min(void) //03H 0-60 increase current minutes
{
}
void dec_hour(void) //04H 24-0
{
}
void inc_hour(void) //05H 0-24 increase current hours
{
}
void dec_receive(void) //06H decrease receive channel total
{
}
void inc_receive(void) //07H increase receive channel total
{
}
void EN_CHN20(void) //08H decrease channel volue
{
}
void EN_CHN10(void) //09H increase channel volue
{
}
void DIS_CHN20(void) //0AH decrease channel volue
{
}
void DIS_CHN10(void) //0BH increase channel volue
{
}
void voltage_select(void) //0CH
{
}
void coding(void) //0DH be used to coding
{
}
void select_chan20(void) //0EH be used to coding
{
}
void select_chan10(void) //0FH be used to coding
{
}
void operation_error(void) //10H display "E"(ERROR)
{
}
void enable_set(void) //11H set enable intput channel
{
}
void disable_set(void) //12H set disable intput channel
{
}
void hide_display(void) //13H hide_display
{
}
void prev_find(void) //14H -- finding
{
}
void next_find(void) //15H ++ finding
{
}
void voltage_change(void) //16H voltage to change
{
}
//_______________________________________________________________
/*
code key_tab_1[];//定义键表的结构类型
code key_tab_2[];
code key_tab_3[];
code key_tab_4[];
code key_tab_5[];
code key_tab_6[];
code key_tab_7[];
code key_tab_8[];
code key_tab_9[];
code key_tab_a[];
code key_tab_b[];
*/
typedef struct //定义键表的结构类型
{
unsigned char key_code; //当前键值
unsigned char next_state; //下个状态索引号
void (*CurrentOperate)(); //当前状态应该执行的功能操作
} KbdTabStruct;
KbdTabStruct code key_tab[9+4+4+4+5+1+1+1+4+4+4+4]= //结构型的数组
{
#ifndef key_tab_2
#define key_tab_2 //定义标号
#endif
/*
key_tab_2:
key_tab_3:
key_tab_4:
key_tab_5:
key_tab_6:
key_tab_7:
key_tab_8:
key_tab_9:
key_tab_a:
key_tab_b:
*/
{0x01,key_tab_0,(*operation_error)},//display "E"(ERROR) (*operation_error)为函数指针
{0x02,key_tab_b,(*coding)}, //coding
{0x03,key_tab_1,(*setup)}, //setup current time
{0x04,key_tab_4,(*find)}, //find
{0x05,key_tab_0,(*hide_display)}, //hide display
{0x06,key_tab_8,(*enable_set)}, //enable_set, enable input to set
{0x07,key_tab_9,(*disable_set)}, //disable_set, disable input to set
{0x08,key_tab_a,(*voltage_select)}, //SELECT LOW/HIGH
{0xff,0x0000,0x0000},
#ifdef key_tab_1 //如果已定义则取消其定义,在下面重定义
#undef key_tab_1 //
key_tab_1:{
0x01,key_tab_1,(*dec_min), //continue to decrease minutes, --
0x03,key_tab_2,(*setup), //main key
0x05,key_tab_1,(*inc_min), //continue to increase minutes ++
0xff,0x0000,0x0000
},
#endif
#ifdef key_tab_2
#undef key_tab_2
key_tab_2:{
0x01,key_tab_2,(*dec_hour), //continue to decrease hours --
0x03,key_tab_3,(*setup), //main key
0x05,key_tab_2,(*inc_hour), //continue to add HOURS ++
0xff,0x0000,0x0000
},
#endif
#ifdef key_tab_3
#undef key_tab_3
key_tab_3:{
0x01,key_tab_3,(*dec_receive), //continue to decrease receive channel total
0x03,key_tab_0,(*setup), //main key
0x05,key_tab_3,(*inc_receive), //continue to increase receive channel total ++
0xff,0x0000,0x0000,
}
#endif
#ifdef key_tab_4
#undef key_tab_4
key_tab_4:{
0x01,key_tab_4,(*prev_find), //--
0x04,key_tab_4,(*find), //
0x05,key_tab_4,(*next_find), //++
0x08,key_tab_4,(*voltage_change), //SELECT LOW/HIGH
0xff,0x0000,0x0000,
}
#endif
#ifdef key_tab_5
#undef key_tab_5
key_tab_5:{
0xff,0x0000,0x0000
},
#endif
#ifdef key_tab_6
#undef key_tab_6
key_tab_6:{
0xff,0x0000,0x0000
},
#endif
#ifdef key_tab_7
#undef key_tab_7
key_tab_7:{
0xff,0x0000,0x0000
},
#endif
#ifdef key_tab_8
#undef key_tab_8
key_tab_8:{
0x01,key_tab_8,(*EN_CHN20), //decrease channel total--
0x05,key_tab_8,(*EN_CHN10), //increase channel total++
0x06,key_tab_8,(*enable_set), //enable alarm signal enter
0xff,0x0000,0x0000
},
#endif
#ifdef key_tab_9
#undef key_tab_9
key_tab_9:{
0x01,key_tab_9,(*DIS_CHN20), //decrease channel total--
0x05,key_tab_9,(*DIS_CHN10), //increase channel total++
0x07,key_tab_9,(*disable_set), //disable alarm signal enter
0xff,0x0000,0x0000,
}
#endif
#ifdef key_tab_a
#undef key_tab_a
key_tab_a:{
0x01,key_tab_a,(*coding), //
0x05,key_tab_a,(*coding), //
0x08,key_tab_2,(*disable_set), //voltage_select LOW/HIGH
0xff,0x0000,0x0000,
}
#endif
#ifdef key_tab_b
#undef key_tab_b
key_tab_b:{
0x01,key_tab_b,(*select_chan20), //decrease channel--
0x02,key_tab_b,(*coding), //coding
0x05,key_tab_b,(*select_chan10), //increase channel++
0xff,0x0000,0x0000,
}
#endif
}; |
|